Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coding for ZigZag Trend Indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Coding for ZigZag Trend Indicator

    Hi All. I'm new to NinjaTrader and don't have any coding or script knowledge. Would someone be able to help convert this indicator code so it works with NinjaTrader? Your assistance is appreciated

    {It is based on the Zig Zag indicator and it returns 1 for a confirmed
    uptrend, and -1 for a confirmed downtrend.}

    {****************************************}

    vr:=Input("Field (0=Ind/tor, 1=Open, 2=High, 3=Low, 4=Close)",0,4,0);
    amnt:=Input("Reversal amount",0.001,1000,10);
    md:=Input("Method (1=Percent, 2=Points)",1,2,1);

    {****************************************}

    vr:=If(vr=1,OPEN,If(vr=2,HIGH,If(vr=3,LOW,If(vr=4, CLOSE,P))));
    zz0:=If(md=1, Zig(vr,amnt,%), Zig(vr,amnt,$));
    zz1:=Ref(zz0,-1);
    zz2:=Ref(zz0,-2);

    {****************************************}

    tr:=ValueWhen(1,zz0>zz1 AND zz1<zz2, zz1);
    pk:=ValueWhen(1,zz0<zz1 AND zz1>zz2, zz1);
    PU:=If(md=1,tr+Abs(tr)*amnt/100,tr+amnt);
    PD:=If(md=1,pk-Abs(pk)*amnt/100,pk-amnt);

    res:=If(vr>=PU AND zz0>zz1,1,
    If(vr<=PD AND zz0<zz1,-1,0));
    res:=If(res<>0,res,ValueWhen(1,res<>0,res));
    res

    #2
    Hello TraderYoda,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    We do not provide programming services however, one of the Support Forum members may be willing to tackle this. If not, I will come back to this and provide any details I can.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    579 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    334 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    554 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X