Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 samuelsilvaimi, Yesterday, 07:15 PM
    1 response
    24 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by ezrollin, Yesterday, 10:01 PM
    0 responses
    13 views
    0 likes
    Last Post ezrollin  
    Started by bob999, Yesterday, 09:15 PM
    0 responses
    20 views
    0 likes
    Last Post bob999
    by bob999
     
    Started by The_Righteous_One, Yesterday, 08:40 PM
    0 responses
    18 views
    0 likes
    Last Post The_Righteous_One  
    Started by Genesis2021, Yesterday, 04:58 PM
    0 responses
    18 views
    0 likes
    Last Post Genesis2021  
    Working...
    X