NexusFi: Find Your Edge


Home Menu

 





ZigZag indicator up and down arrows


Discussion in MultiCharts

Updated
    1. trending_up 4,186 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

ZigZag indicator up and down arrows

  #1 (permalink)
 ptcm 
Taiwan
 
Experience: Intermediate
Platform: MC
Posts: 77 since Jun 2010
Thanks Given: 8
Thanks Received: 17

Need some help on ZigZag indicator up and down arrows.

I have the ZigZag signals triggered at the right places except that now the indicators are showing "both" red down and blue up signal simultaneously.

I want to have only blue up when the reversal are turning back up at the bottom and vice versa (show down red at the tops).

I also want to get ride of the red Zigzag line.

Can someone please tell me how I could fix the code to achieve that ?

Thanks a lot in advance.




inputs:
Price( Close ),
RetracePnts( 5 ),
LineColor( Yellow ),
LineWidth( 1 ) ;

variables:
var0( 0 ),
var1( Price ),
var2( Date ),
var3( Time ),
var4( 0 ),
var5( false ),
var6( false ),
var7( false ),
var8( 0 ) ;



var0 = SwingHigh( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 <= 0 and var0 >= var1 + RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;
var4 = 1 ;
end
else
begin
condition1 = var4 = 1 and var0 >= var1 ;
if condition1 then
begin
var5 = true ;
var7 = true ;
end;
end ;
end
else
begin
var0 = SwingLow( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 >= 0 and var0 <= var1 - RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;
var4 = -1 ;
end
else
begin
condition1 = var4 = -1 and var0 <= var1 ;
if condition1 then
begin
var5 = true;
var7 = true ;
end ;
end;
end ;
end ;

if var5 then

begin
var1 = var0 ;
var2 = Date[1] ;
var3 = Time[1] ;
var5 = false ;
end ;

if var6 then

begin
var8 = TL_New( var2, var3, var1, var2[1], var3[1],
var1[1] ) ;
TL_SetExtLeft( var8, false ) ;
TL_SetExtRight( var8, false ) ;
{TL_SetSize( var8, LineWidth ) ;}
{TL_SetColor( var8, LineColor ) ;}
Value1=Arw_New(Date,Time,High,True);
Value1=Arw_New(Date,Time,Low,False);

var6 = false ;
end
else if var7 then

begin
TL_SetEnd( var8, var2, var3, var1 ) ;
var7 = false ;
end ;

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
ZombieSqueeze
Platforms and Indicators
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Cheap historycal L1 data for stocks
Stocks and ETFs
MC PL editor upgrade
MultiCharts
 
  #2 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

Here is the code for the ZigZag % indicator for Tradestation but I think it can work also for MultiCharts:

Traders' Tips - November 2003


[img]https://i.postimg.cc/tCWxV0JR/Zig-Zag-Indicator.jpg[/img]

Reply With Quote
  #3 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129


Here is the code for the ZigZag Pnts - indicator for Tradestation:

{ZigZag Pnts: Indicator}

inputs:
Price( Close ),
RetracePnts( 5 ),
LineColor( Yellow ),
LineWidth( 1 ) ;

variables:
NewSwingPrice( 0 ),
SwingPrice( Price ), { used as a convenient 2-element array }
SwingDate( Date ), { used as a convenient 2-element array }
SwingTime( Time ), { used as a convenient 2-element array }
TLDir( 0 ), { TLDir = -1 implies prev TL dn, +1 implies prev TL up }
SaveSwing( false ),
AddTL( false ),
UpdateTL( false ),
TLRef( 0 ) ;

{ Candidate swings are just-confirmed, 3-bar (Str=1), SwingHi's and SwingLo's }

NewSwingPrice = SwingHigh( 1, Price, 1, 2 ) ;
if NewSwingPrice <> -1 then
begin
if TLDir <= 0 and NewSwingPrice >= SwingPrice + RetracePnts then
{ prepare to add new up TL }
begin
SaveSwing = true ;
AddTL = true ;
TLDir = 1 ;
end
else if TLDir = 1 and NewSwingPrice >= SwingPrice then
{ prepare to update prev up TL }
begin
SaveSwing = true ;
UpdateTL = true ;
end ;
end
else
begin
NewSwingPrice = SwingLow( 1, Price, 1, 2 ) ;
if NewSwingPrice <> -1 then
begin
if TLDir >= 0 and NewSwingPrice <= SwingPrice - RetracePnts then
{ prepare to add new dn TL }
begin
SaveSwing = true ;
AddTL = true ;
TLDir = -1 ;
end
else if TLDir = -1 and NewSwingPrice <= SwingPrice then
{ prepare to update prev dn TL }
begin
SaveSwing = true;
UpdateTL = true ;
end ;
end ;
end ;

if SaveSwing then
{ save new swing and reset SaveSwing }
begin
SwingPrice = NewSwingPrice ;
SwingDate = Date[1] ;
SwingTime = Time[1] ;
SaveSwing = false ;
end ;

if AddTL then
{ add new TL and reset AddTL }
begin
TLRef = TL_New( SwingDate, SwingTime, SwingPrice, SwingDate[1], SwingTime[1],
SwingPrice[1] ) ;
TL_SetExtLeft( TLRef, false ) ;
TL_SetExtRight( TLRef, false ) ;
TL_SetSize( TLRef, LineWidth ) ;
TL_SetColor( TLRef, LineColor ) ;
AddTL = false ;
end
else if UpdateTL then
{ update prev TL and reset UpdateTL }
begin
TL_SetEnd( TLRef, SwingDate, SwingTime, SwingPrice ) ;
UpdateTL = false ;
end ;
-------------------------------------------------------------------------------------

[img]https://i.postimg.cc/QCsr4WQy/Zig-Zag-Pnts-Indicator.jpg[/img]

Reply With Quote
Thanked by:
  #4 (permalink)
 ptcm 
Taiwan
 
Experience: Intermediate
Platform: MC
Posts: 77 since Jun 2010
Thanks Given: 8
Thanks Received: 17

Thanks for the code. Any idea how I could modify it in such a way that the indicator can show up and down arrows at the turning points instead of lines ?

Thanks again.



Shaban View Post
Here is the code for the ZigZag Pnts - indicator for Tradestation:

{ZigZag Pnts: Indicator}

inputs:
Price( Close ),
RetracePnts( 5 ),
LineColor( Yellow ),
LineWidth( 1 ) ;

variables:
NewSwingPrice( 0 ),
SwingPrice( Price ), { used as a convenient 2-element array }
SwingDate( Date ), { used as a convenient 2-element array }
SwingTime( Time ), { used as a convenient 2-element array }
TLDir( 0 ), { TLDir = -1 implies prev TL dn, +1 implies prev TL up }
SaveSwing( false ),
AddTL( false ),
UpdateTL( false ),
TLRef( 0 ) ;

{ Candidate swings are just-confirmed, 3-bar (Str=1), SwingHi's and SwingLo's }

NewSwingPrice = SwingHigh( 1, Price, 1, 2 ) ;
if NewSwingPrice <> -1 then
begin
if TLDir <= 0 and NewSwingPrice >= SwingPrice + RetracePnts then
{ prepare to add new up TL }
begin
SaveSwing = true ;
AddTL = true ;
TLDir = 1 ;
end
else if TLDir = 1 and NewSwingPrice >= SwingPrice then
{ prepare to update prev up TL }
begin
SaveSwing = true ;
UpdateTL = true ;
end ;
end
else
begin
NewSwingPrice = SwingLow( 1, Price, 1, 2 ) ;
if NewSwingPrice <> -1 then
begin
if TLDir >= 0 and NewSwingPrice <= SwingPrice - RetracePnts then
{ prepare to add new dn TL }
begin
SaveSwing = true ;
AddTL = true ;
TLDir = -1 ;
end
else if TLDir = -1 and NewSwingPrice <= SwingPrice then
{ prepare to update prev dn TL }
begin
SaveSwing = true;
UpdateTL = true ;
end ;
end ;
end ;

if SaveSwing then
{ save new swing and reset SaveSwing }
begin
SwingPrice = NewSwingPrice ;
SwingDate = Date[1] ;
SwingTime = Time[1] ;
SaveSwing = false ;
end ;

if AddTL then
{ add new TL and reset AddTL }
begin
TLRef = TL_New( SwingDate, SwingTime, SwingPrice, SwingDate[1], SwingTime[1],
SwingPrice[1] ) ;
TL_SetExtLeft( TLRef, false ) ;
TL_SetExtRight( TLRef, false ) ;
TL_SetSize( TLRef, LineWidth ) ;
TL_SetColor( TLRef, LineColor ) ;
AddTL = false ;
end
else if UpdateTL then
{ update prev TL and reset UpdateTL }
begin
TL_SetEnd( TLRef, SwingDate, SwingTime, SwingPrice ) ;
UpdateTL = false ;
end ;
-------------------------------------------------------------------------------------

[img]https://i.postimg.cc/QCsr4WQy/Zig-Zag-Pnts-Indicator.jpg[/img]


Started this thread Reply With Quote
  #5 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129

Unfortunately I do not know how to insert arrows instead of lines, but the ZigZag indicator is not very reliable, because it often modifies the previous signal, it is as if a trader went back in time and could modify the signals: they would all be rich.

It's explained here:

https://www.multicharts.com/support/base/swing-identificator-gt-ziz-zag/

"Since the Zig Zag indicator can adjust its values based on subsequent changes in the underlying plot, it has perfect hindsight into what prices have done. Please don't try to create a trading system based on the Zig Zag indicator - its hindsight is much better than its foresight!"

Reply With Quote
  #6 (permalink)
 ptcm 
Taiwan
 
Experience: Intermediate
Platform: MC
Posts: 77 since Jun 2010
Thanks Given: 8
Thanks Received: 17

I have figured out the up and down arrow portion., but there's a unwanted orange zigzag line that I would like to remove. Can some one please tell me which line of code I need to delete to achieve that ?

thanks a lot.



The codes are shown below.

inputs:
period (6);

vars:
myMid (0),
myUpper (0),
myLower (0);

vars: zoneABmid (0);
vars: zoneCDmid (0);

Value0 = DonchianChannel(period, myMid, myUpper, myLower);

zoneABmid = (myMid+myUpper)/2;
zoneCDmid = (myMid+myLower)/2;



inputs:
Price( Close ),
RetracePnts( 5 ),
LineColor( black ),
LineWidth( 1 ) ;

variables:
var0( 0 ),
var1( Price ),
var2( Date ),
var3( Time ),
var4( 0 ),
var5( false ),
var6( false ),
var7( false ),
var8( 0 ) ;



var0 = SwingHigh( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 <= 0 and var0 >= var1 + RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;
var4 = 1 ;
end
else
begin
condition1 = var4 = 1 and var0 >= var1 ;
if condition1 then
begin
var5 = true ;
var7 = true ;
end;
end ;
end
else
begin
var0 = SwingLow( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 >= 0 and var0 <= var1 - RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;
var4 = -1 ;
end
else
begin
condition1 = var4 = -1 and var0 <= var1 ;
if condition1 then
begin
var5 = true;
var7 = true ;
end ;
end;
end ;
end ;

if var5 then

begin
var1 = var0 ;
var2 = Date[1] ;
var3 = Time[1] ;
var5 = false ;
end ;

if var6 then

begin
var8 = TL_New( var2, var3, var1, var2[1], var3[1],
var1[1] ) ;
TL_SetExtLeft( var8, false ) ;
TL_SetExtRight( var8, false ) ;
{TL_SetSize( var8, LineWidth ) ;}
{TL_SetColor( var8, LineColor ) ;}

if Close < Close[1] then begin
Value1=Arw_New(Date,Time,High,True);
End;

if Close > Close[1] then begin
Value1=Arw_New(Date,Time,Low,False);
End;

{Plot1(High);}

var6 = false ;
end
else if var7 then

begin
TL_SetEnd( var8, var2, var3, var1 ) ;
var7 = false ;
end ;

Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
 ptcm 
Taiwan
 
Experience: Intermediate
Platform: MC
Posts: 77 since Jun 2010
Thanks Given: 8
Thanks Received: 17

Can someone please tell me how I could set the orange line to be same color as background, so that it will disappear ? thanks a lot.

I can't figure out which line of code I have to delete to remove the orange zigzag line, so changing the color would be a workaround solution.

please help.




ptcm View Post
I have figured out the up and down arrow portion., but there's a unwanted orange zigzag line that I would like to remove. Can some one please tell me which line of code I need to delete to achieve that ?

thanks a lot.



The codes are shown below.

inputs:
period (6);

vars:
myMid (0),
myUpper (0),
myLower (0);

vars: zoneABmid (0);
vars: zoneCDmid (0);

Value0 = DonchianChannel(period, myMid, myUpper, myLower);

zoneABmid = (myMid+myUpper)/2;
zoneCDmid = (myMid+myLower)/2;



inputs:
Price( Close ),
RetracePnts( 5 ),
LineColor( black ),
LineWidth( 1 ) ;

variables:
var0( 0 ),
var1( Price ),
var2( Date ),
var3( Time ),
var4( 0 ),
var5( false ),
var6( false ),
var7( false ),
var8( 0 ) ;



var0 = SwingHigh( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 <= 0 and var0 >= var1 + RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;
var4 = 1 ;
end
else
begin
condition1 = var4 = 1 and var0 >= var1 ;
if condition1 then
begin
var5 = true ;
var7 = true ;
end;
end ;
end
else
begin
var0 = SwingLow( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 >= 0 and var0 <= var1 - RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;
var4 = -1 ;
end
else
begin
condition1 = var4 = -1 and var0 <= var1 ;
if condition1 then
begin
var5 = true;
var7 = true ;
end ;
end;
end ;
end ;

if var5 then

begin
var1 = var0 ;
var2 = Date[1] ;
var3 = Time[1] ;
var5 = false ;
end ;

if var6 then

begin
var8 = TL_New( var2, var3, var1, var2[1], var3[1],
var1[1] ) ;
TL_SetExtLeft( var8, false ) ;
TL_SetExtRight( var8, false ) ;
{TL_SetSize( var8, LineWidth ) ;}
{TL_SetColor( var8, LineColor ) ;}

if Close < Close[1] then begin
Value1=Arw_New(Date,Time,High,True);
End;

if Close > Close[1] then begin
Value1=Arw_New(Date,Time,Low,False);
End;

{Plot1(High);}

var6 = false ;
end
else if var7 then

begin
TL_SetEnd( var8, var2, var3, var1 ) ;
var7 = false ;
end ;


Started this thread Reply With Quote
  #8 (permalink)
 ptcm 
Taiwan
 
Experience: Intermediate
Platform: MC
Posts: 77 since Jun 2010
Thanks Given: 8
Thanks Received: 17

I have simplified the codes. Can some one please please tell me how I could remove or change the color of the Zigzag line ? The up and down arrows are good enough for me. A million thanks in advance. I've tried to examine each line, but I can't figure it out.



inputs:
period (2);


inputs:
Price( Close ),
RetracePnts( 11 ),
LineColor( Yellow ),
LineWidth( 1 ) ;

variables:
var0( 0 ),
var1( Price ),
var2( Date ),
var3( Time ),
var4( 0 ),
var5( false ),
var6( false ),
var7( false ),
var8( 0 ) ;



var0 = SwingHigh( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 <= 0 and var0 >= var1 + RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;


var4 = 1 ;


end
else
begin
condition1 = var4 = 1 and var0 >= var1 ;
if condition1 then
begin
var5 = true ;
var7 = true ;


end;
end ;
end
else
begin
var0 = SwingLow( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 >= 0 and var0 <= var1 - RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;
var4 = -1 ;
end
else
begin
condition1 = var4 = -1 and var0 <= var1 ;
if condition1 then
begin
var5 = true;
var7 = true;
end ;
end;
end ;
end ;

if var5 then

begin
var1 = var0 ;
var2 = Date[1] ;
var3 = Time[1] ;
var5 = false ;
end ;

if var6 then

begin

var8 = TL_New( var2, var3, var1, var2[1], var3[1],

var1[1] ) ;

TL_SetExtLeft( var8, false ) ;
TL_SetExtRight( var8, false ) ;
{TL_SetSize( var8, LineWidth ) ;}
{TL_SetColor( var8, LineColor ) ;}



if Close < Close[1] then begin
Value1=Arw_New(Date,Time,High,True);
End;

if Close > Close[1] then begin
Value1=Arw_New(Date,Time,Low,False);
End;

{Plot1(High);}

var6 = False ;
end
else if var7 then

begin

TL_SetEnd( var8, var2, var3, var1 ) ;

var7 = false ;
end ;

Started this thread Reply With Quote
  #9 (permalink)
 ptcm 
Taiwan
 
Experience: Intermediate
Platform: MC
Posts: 77 since Jun 2010
Thanks Given: 8
Thanks Received: 17

I am able to add these lines to make the unwanted zigzag line black which is the same color as the background. Just wondering if there's a reserved word color for transparent or how I can get a RGB color code to substitute transparent color ?

thanks


tl_setcolor(value1,black);
tl_setsize(value1,0);





inputs:
period (2);


inputs:
Price( Close ),
RetracePnts( 11 ),

LineColor( Yellow ),
LineWidth( 0 ) ;

variables:
var0( 0 ),
var1( Price ),
var2( Date ),
var3( Time ),
var4( 0 ),
var5( false ),
var6( false ),
var7( false ),
var8( 0 ) ;


tl_setcolor(value1,black);
tl_setsize(value1,0);



var0 = SwingHigh( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 <= 0 and var0 >= var1 + RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;


var4 = 1 ;


end
else
begin
condition1 = var4 = 1 and var0 >= var1 ;
if condition1 then
begin
var5 = true ;
var7 = true ;


end;
end ;
end
else
begin
var0 = SwingLow( 1, Price, 1, 2 ) ;
if var0 <> -1 then
begin
condition1 = var4 >= 0 and var0 <= var1 - RetracePnts ;
if condition1 then
begin
var5 = true ;
var6 = true ;
var4 = -1 ;
end
else
begin
condition1 = var4 = -1 and var0 <= var1 ;
if condition1 then
begin
var5 = true;
var7 = true;
end ;
end;
end ;
end ;

if var5 then

begin
var1 = var0 ;
var2 = Date[1] ;
var3 = Time[1] ;
var5 = false ;
end ;

if var6 then

begin

var8 = TL_New( var2, var3, var1, var2[1], var3[1],

var1[1] ) ;

tl_setcolor(value1,black);
tl_setsize(value1,0);

TL_SetExtLeft( var8, false ) ;
TL_SetExtRight( var8, false ) ;


{TL_SetSize( var8, LineWidth ) ;}
{TL_SetColor( var8, LineColor ) ;}



if Close < Close[1] then begin
Value1=Arw_New(Date,Time,High,True);
End;

if Close > Close[1] then begin
Value1=Arw_New(Date,Time,Low,False);
End;

{Plot1(High);}

var6 = False ;
end
else if var7 then

begin

TL_SetEnd( var8, var2, var3, var1 ) ;


var7 = false ;
end ;

Started this thread Reply With Quote
  #10 (permalink)
Shaban
Turin + Italy
 
Posts: 194 since Feb 2020
Thanks Given: 24
Thanks Received: 129


On this site:

WebHelp

there is the Reserved word: transparent, but maybe it is only for Tradestation 10, because in my Tradestation 8 it is not there (see image), maybe it is not even in Multicharts.

I wanted to ask you if you can write here the Function of Donchian Channel.
Thank you a lot.

[img]https://i.postimg.cc/RVv01MWq/Transparent-Reserved-word.jpg[/img]

[img]https://i.postimg.cc/d0ZQQ3xN/16-Colori-per-TS-8.jpg[/img]

Reply With Quote




Last Updated on June 11, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts