Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Convert mt4 Trix TC2 indicator to Ninja

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

    Convert mt4 Trix TC2 indicator to Ninja

    Hi All,
    Could some one please try to convert this mt4 Trix Trend Cycle 2 indicator into Ninja trader code.

    #property link ""
    #property indicator_separate_window
    #property indicator_buffers 1
    #property indicator_color1 Red
    //
    //
    //
    //
    //
    extern int TrixPeriod = 4;
    extern int TrendCycle = 4;
    //
    //
    //
    //
    //
    double stcBuffer[];
    double trix_buffer1[];
    double trix_buffer2[];
    double trix_buffer3[];
    double cdBuffer[];
    double fastKBuffer[];
    double fastDBuffer[];
    double fastKKBuffer[];

    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    //
    //
    //
    //
    //
    int init()
    {
    IndicatorBuffers(8);
    SetIndexBuffer(0,stcBuffer);
    SetIndexBuffer(1,trix_buffer1);
    SetIndexBuffer(2,trix_buffer2);
    SetIndexBuffer(3,trix_buffer3);
    SetIndexBuffer(4,cdBuffer);
    SetIndexBuffer(5,fastKBuffer);
    SetIndexBuffer(6,fastDBuffer);
    SetIndexBuffer(7,fastKKBuffer);
    IndicatorShortName("Trix TC2 ("+TrixPeriod+","+TrendCycle+")");
    return(0);
    }
    int deinit()
    {
    return(0);
    }
    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    //
    //
    //
    //
    //
    int start()
    {
    double alphaCD = 2.0 / (1.0 + 3.0);
    int counted_bars = IndicatorCounted();
    int limit,i;
    if(counted_bars < 0) return(-1);
    if(counted_bars>0) counted_bars--;
    limit = Bars-counted_bars;
    //
    //
    //
    //
    //
    for(i=0; i<limit; i++) trix_buffer1[i]=iMA(NULL,0,TrixPeriod,0,MODE_SMMA,(PRICE_CLOSE+PR ICE_HIGH+PRICE_LOW),i);
    for(i=0; i<limit; i++) trix_buffer2[i]=iMAOnArray(trix_buffer1,0,TrixPeriod,0,MODE_SMMA, i);
    for(i=0; i<limit; i++) trix_buffer3[i]=iMAOnArray(trix_buffer2,0,TrixPeriod,0,MODE_EMA,i );
    //
    //
    //

    for(i = limit; i >= 0; i--)
    {
    cdBuffer[i] = cdBuffer[i+1]+alphaCD*(trix_buffer3[i]-trix_buffer3[i+1]);
    //
    //
    //
    //
    //

    double lowCd = minValue(cdBuffer,i);
    double highCd = maxValue(cdBuffer,i)-lowCd;
    if (highCd > 0)
    fastKBuffer[i] = 100*((cdBuffer[i]-lowCd)/highCd);
    else fastKBuffer[i] = fastKBuffer[i+1];
    fastDBuffer[i] = fastDBuffer[i+1]+0.5*(fastKBuffer[i]-fastDBuffer[i+1]);

    //
    //
    //
    //
    //

    double lowStoch = minValue(fastDBuffer,i);
    double highStoch = maxValue(fastDBuffer,i)-lowStoch;
    if (highStoch > 0)
    fastKKBuffer[i] = 100*((fastDBuffer[i]-lowStoch)/highStoch);
    else fastKKBuffer[i] = fastKKBuffer[i+1];
    stcBuffer[i] = stcBuffer[i+1]+0.5*(fastKKBuffer[i]-stcBuffer[i+1]);
    }
    return(0);
    }

    //+------------------------------------------------------------------+
    //| |
    //+------------------------------------------------------------------+
    //
    //
    //
    //
    //
    double minValue(double& array[],int shift)
    {
    double minValue = array[shift];
    for (int i=1; i<TrendCycle; i++) minValue = MathMin(minValue,array[shift+i]);
    return(minValue);
    }
    double maxValue(double& array[],int shift)
    {
    double maxValue = array[shift];
    for (int i=1; i<TrendCycle; i++) maxValue = MathMax(maxValue,array[shift+i]);
    return(maxValue);
    }

    thanks.

    #2
    onemore, if no one is able or wants to convert this for you, you could always try contacting one of our 3rd party consultants.
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    603 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    349 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    104 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    560 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    560 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X