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 Scotty33, Today, 10:15 AM
    0 responses
    5 views
    0 likes
    Last Post Scotty33  
    Started by mlprice12, Today, 09:40 AM
    3 responses
    18 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by saeed, Today, 09:46 AM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by set2win, Today, 09:32 AM
    4 responses
    15 views
    0 likes
    Last Post set2win
    by set2win
     
    Started by sidlercom80, 11-25-2021, 06:38 AM
    2 responses
    47 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X