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

Data-series calculations different in indicator, and strategy

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

    Data-series calculations different in indicator, and strategy

    [OK, PLEASE DISREGARD/DELETE - Turned out to be as simple as it works with onBarClose, just not OnPriceChange...]


    Hello,

    I am testing a new strategy on 8.0.16.2 64-bit. Instead of getting the strategy to call the indicator I already wrote, I thought it would be more efficient to port the simple code directly into the strategy. All it does is calculate a pivot. The confusing thing is, with the original indicator added to the chart and the strategy applied, even though they should be using the same code cut and pasted from the indicator to the strategy, and include the same additional data-series, the calculations are different. I am so far scratching my head as to why.

    In the indicator and strategy, a 4 hour data series is added in state.configure (AddDataSeries(Data.BarsPeriodType.Minute, 240).

    So, we have the primary data series on the chart and the additional one.

    In both the indicator and strategy a simple calculation is done in the additional series, such as the following

    Code:
    // do the calcs for the pivot bar series
    if (BarsInProgress == 1)
    {
    if (CurrentBar < 2)
    return;
    
    // we only update the pivots once we have a full prior bar
    if (IsFirstTickOfBar)
    {
    currentClose = Close[0];
    currentHigh = High[0];
    currentLow = Low[0];
    BarClose = Close[1];
    BarHigh = High[1];
    BarLow = Low[1];
    // calculate pivot points
    pp = (BarHigh + BarLow + BarClose) / 3;

    And the pp is plotted in the indicator, and on the strategy, I just output the value and some text at the value location.

    The problem is, in the indicator and strategy end up plotting wildly different values and I cannot figure out why. Should they not be the same? It is perhaps that the strategy, unlike the indicator is not processing the historical data (i.e. not starting it's calculations from the start of the chart, per the indicator)?
    Last edited by pjsmith; 11-21-2018, 04:06 AM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by RookieTrader, Today, 09:37 AM
2 responses
10 views
0 likes
Last Post RookieTrader  
Started by alifarahani, Today, 09:40 AM
1 response
6 views
0 likes
Last Post NinjaTrader_Jesse  
Started by Gerik, Today, 09:40 AM
1 response
6 views
0 likes
Last Post NinjaTrader_Gaby  
Started by KennyK, 05-29-2017, 02:02 AM
3 responses
1,285 views
0 likes
Last Post NinjaTrader_Clayton  
Started by AttiM, 02-14-2024, 05:20 PM
11 responses
186 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X