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

need to convert this indicator from mql to Ninja code??

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

    need to convert this indicator from mql to Ninja code??

    hi traders..
    i need to convert this code to ninjatrade code??

    #property indicator_separate_window
    #property indicator_buffers 3
    #property indicator_color2 Aqua
    #property indicator_color3 Red
    #property indicator_style2 STYLE_SOLID
    #property indicator_style3 STYLE_SOLID
    #property indicator_width2 2
    #property indicator_width3 2

    //-------------------------------------------------------------------
    extern int period=8;
    extern bool alarm=true;
    extern bool EhlersFormula = true;
    //-------------------------------------------------------------------

    double ExtBuffer0[];
    double ExtBuffer1[];
    double ExtBuffer2[];
    double alertBar;
    double last;

    int init()
    {

    SetIndexStyle(0,DRAW_NONE);
    SetIndexStyle(1,DRAW_HISTOGRAM);
    SetIndexStyle(2,DRAW_HISTOGRAM);
    IndicatorDigits(Digits+1);

    SetIndexBuffer(0,ExtBuffer0);
    SetIndexBuffer(1,ExtBuffer1);
    SetIndexBuffer(2,ExtBuffer2);

    IndicatorShortName("smFisherTransform3" +" ("+period+")");
    SetIndexLabel(1,NULL);
    SetIndexLabel(2,NULL);

    return(0);
    }


    int start()
    {
    int limit;
    int counted_bars=IndicatorCounted();
    double prev,current,old;
    double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;
    double price;
    double MinL=0;
    double MaxH=0;


    if(counted_bars>0) counted_bars--;
    limit=Bars-counted_bars;


    //for(int i=0; i<Bars; i++)
    for(int i=0; i<limit; i++)
    {
    MaxH = High[Highest(NULL,0,MODE_HIGH,period,i)];
    MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)];
    price = (High[i]+Low[i])/2;

    if (EhlersFormula == false) {
    if(MaxH-MinL == 0) Value = 0.33*2*(0-0.5) + 0.67*Value1;
    else Value = 0.33*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;
    }
    else
    {
    if(MaxH-MinL == 0) Value = 0.5*2*(0-0.5) + 0.5*Value1;
    else Value = 0.25*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.75*Value1;
    //else Value = 0.5*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.5*Value1; //original Ehlers
    }

    if (EhlersFormula == false)
    Value=MathMin(MathMax(Value,-0.999),0.999);
    else
    if (EhlersFormula == true) {
    if (Value > 0.9999) Value = 0.9999;
    if (Value < -0.9999) Value = -0.9999;

    }

    if (EhlersFormula == false) {
    if(1-Value == 0) ExtBuffer0[i]=0.5+0.5*Fish1;
    else ExtBuffer0[i]=0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;
    }
    else
    {
    if(1-Value == 0) ExtBuffer0[i]=0.25+0.75*Fish1;
    else ExtBuffer0[i]=0.25*MathLog((1+Value)/(1-Value))+0.75*Fish1; //original Ehlers is 0.25/0.5...?
    }

    Value1=Value;
    Fish1=ExtBuffer0[i];
    }


    bool up=true;
    //for(i=Bars; i>=0; i--) {
    for(i=limit; i>=0; i--) {
    current=ExtBuffer0[i];
    prev=ExtBuffer0[i+1];

    if (((current<0)&&(prev>0))||(current<0)) up= false;
    if (((current>0)&&(prev<0))||(current>0)) up= true;

    if(!up) {
    ExtBuffer2[i]=current;
    ExtBuffer1[i]=0.0;
    if (alarm == true) {
    if (i==0 && prev != 2 && ExtBuffer1[i] == 0 && Bars>alertBar) {
    Alert("ForexTrend Changing Down on ",Period()," ",Symbol());
    alertBar = Bars;
    last = 2;
    }
    }
    }

    else {
    ExtBuffer1[i]=current;
    ExtBuffer2[i]=0.0;
    if (alarm == true) {
    if (i==0 && last != 1 && ExtBuffer2[i] == 0 && Bars>alertBar) {
    Alert("ForexTrend Changing Up on ",Period()," ",Symbol());
    alertBar = Bars;
    last = 1;
    }
    }
    }
    }

    return(0);
    }

    #2
    Hello Gozila,

    Thank you for your post.

    NinjaTrader does not offer custom development of Indicators and Strategies.

    We have a comprehensive help guide that goes through the available NinjaScripts items and even some basic tutorials on creating your own script.

    * http://www.ninjatrader.com/support/h...nt7/index.html

    Our support forum is a wealth of knowledge from our user base and even includes some reference items on how to code particular items.

    * http://www.ninjatrader.com/support/forum/

    Lastly, you are always welcome to send in a support request on any items that you may need assistance with.

    I will leave this thread open if any of our other users are willing to assist you in the development of this.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SantoshXX, Today, 03:09 AM
    0 responses
    13 views
    0 likes
    Last Post SantoshXX  
    Started by DanielTynera, Today, 01:14 AM
    0 responses
    2 views
    0 likes
    Last Post DanielTynera  
    Started by yertle, 04-18-2024, 08:38 AM
    9 responses
    42 views
    0 likes
    Last Post yertle
    by yertle
     
    Started by techgetgame, Yesterday, 11:42 PM
    0 responses
    14 views
    0 likes
    Last Post techgetgame  
    Started by sephichapdson, Yesterday, 11:36 PM
    0 responses
    2 views
    0 likes
    Last Post sephichapdson  
    Working...
    X