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 Gkomi, Today, 10:02 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by JTizz, Today, 08:58 AM
    6 responses
    29 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by Bob49, Today, 08:40 AM
    0 responses
    19 views
    0 likes
    Last Post Bob49
    by Bob49
     
    Started by Malik_demoacct, Today, 08:31 AM
    0 responses
    17 views
    0 likes
    Last Post Malik_demoacct  
    Started by nkhoi, Today, 08:40 AM
    0 responses
    26 views
    0 likes
    Last Post nkhoi
    by nkhoi
     
    Working...
    X