Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Switch from FXCM Strategy Trader to Ninja: Stochastic indicator is different

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

    Switch from FXCM Strategy Trader to Ninja: Stochastic indicator is different

    Hello,
    I’m trying to switch my FXCM Strategy trader EA to Ninjatrader platform but I’m experiencing some difficulties to apply my ST stochastic strategy to Ninja stochastic indicator.
    Although I set the same stochastic parameters in both Ninja trader and strategy trader Stochastic (Slow Stochastic = smoothing type=1) , and I apply the same historical price series, the result is different as described in the attached image.
    I tried to analyze strategy trader platform stochastic script (see below) and I realized that it might be related to the calculation of the average in the ST stochastic but I can’t identify it clearly.
    Could someone help me to get the same indicator as per Strategy trader platform?
    Thanks for the support
    ---------------------------------------------------------------------
    ………

    protected override void Construct(){
    m_cum1 = new Cum(this,m_data_stream);
    m_cum2 = new Cum(this,m_data_stream);
    m_cum3 = new Cum(this,m_data_stream);
    m_xaverage1 = new XAverage(this,m_data_stream);
    m_xaverageorig1 = new XAverageOrig(this,m_data_stream);
    m_num1 = new SeriesVar<Double>(this);
    m_den1 = new SeriesVar<Double>(this);
    }

    protected override void Initialize(){
    m_cum1.price = m_num1;
    m_cum2.price = m_den1;
    m_cum3.price = ofastd;
    m_xaverage1.price = ofastk;
    m_xaverage1.length = length1;
    m_xaverageorig1.price = ofastd;
    m_xaverageorig1.length = length2;
    m_ll = 0;
    m_hh = 0;
    m_num1.DefaultValue = 0;
    m_den1.DefaultValue = 0;
    m_num2 = 0;
    m_den2 = 0;
    m_barstogo1 = 0;
    m_barstogo2 = 0;
    }

    protected override void Destroy() {}

    protected override Double Execute(){
    Double _This = this[0];
    _This = 1;
    m_ll = Functions.Lowest(pricel, stochlength.Value);
    m_hh = Functions.Highest(priceh, stochlength.Value);
    m_num1.Value = (pricec.Value - m_ll);
    m_den1.Value = (m_hh - m_ll);
    if (Functions.DoubleGreater(m_den1.Value, 0)){
    ofastk.Value = ((m_num1.Value/((m_den1.Value)))
    *100);
    }
    else{
    ofastk.Value = 0;
    _This = (-1*1);

    }
    if ((smoothingtype.Value == 1)){m_barstogo1 = (length1.Value - Bars.CurrentBar);

    if ((Functions.DoubleGreater(m_barstogo1, 0) && Functions.DoubleGreater(Bars.CurrentBar, 0)))

    {
    m_num2 = ((m_cum1[0]
    + (m_barstogo1*m_num1[((Int32) (Math.Round(((Double) ((Bars.CurrentBar - 1))))))]))
    /((length1.Value)));
    m_den2 = ((m_cum2[0]
    + (m_barstogo1*m_den1[((Int32) (Math.Round(((Double) ((Bars.CurrentBar - 1))))))]))
    /((length1.Value)));

    }
    else{
    m_num2 = Functions.Average(m_num1, length1.Value);
    m_den2 = Functions.Average(m_den1, length1.Value);
    }
    if (Functions.DoubleGreater(m_den2, 0)){
    ofastd.Value = ((m_num2/((m_den2)))
    *100);
    }
    else{
    ofastd.Value = 0;
    _This = (-1*1);
    }
    m_barstogo2 = (length2.Value - Bars.CurrentBar);
    if ((Functions.DoubleGreater(m_barstogo2, 0) && Functions.DoubleGreater(Bars.CurrentBar, 0))){
    oslowd.Value = ((m_cum3[0]
    + (m_barstogo2*ofastd[((Int32) (Math.Round(((Double) ((Bars.CurrentBar - 1))))))]))
    /((length2.Value)));
    }
    else{
    oslowd.Value = Functions.Average(ofastd, length2.Value);
    }
    }
    else{
    if ((smoothingtype.Value == 2)){
    ofastd.Value = m_xaverage1[0];
    oslowd.Value = m_xaverageorig1[0];
    }
    }
    oslowk.Value = ofastd.Value;
    return _This;
    }
    }
    }
    Attached Files

    #2
    Hello,

    Welcome to our forums!

    Unfortunately I'm not familiar with enough with strategy traders functions to clearly identify.

    We'll leave this thread open for other community members to contribute.

    You may also want to contact a NinjaScript Consultant who has experience with both NinjaTrader and Strategy Trader:

    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bobby34, 02-07-2025, 06:21 AM
    5 responses
    43 views
    0 likes
    Last Post bobby34
    by bobby34
     
    Started by rtwave, 02-02-2025, 08:22 PM
    7 responses
    37 views
    0 likes
    Last Post rtwave
    by rtwave
     
    Started by Mountain_cast, Yesterday, 11:14 PM
    0 responses
    7 views
    0 likes
    Last Post Mountain_cast  
    Started by junkone, Yesterday, 08:44 PM
    1 response
    7 views
    1 like
    Last Post MiCe1999  
    Started by apgapg2, 02-08-2025, 10:04 AM
    2 responses
    33 views
    0 likes
    Last Post apgapg2
    by apgapg2
     
    Working...
    X