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 algospoke, 04-17-2024, 06:40 PM
    6 responses
    49 views
    0 likes
    Last Post algospoke  
    Started by arvidvanstaey, Today, 02:19 PM
    4 responses
    11 views
    0 likes
    Last Post arvidvanstaey  
    Started by samish18, 04-17-2024, 08:57 AM
    16 responses
    61 views
    0 likes
    Last Post samish18  
    Started by jordanq2, Today, 03:10 PM
    2 responses
    10 views
    0 likes
    Last Post jordanq2  
    Started by traderqz, Today, 12:06 AM
    10 responses
    21 views
    0 likes
    Last Post traderqz  
    Working...
    X