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 zstheorist, Today, 07:52 PM
0 responses
7 views
0 likes
Last Post zstheorist  
Started by pmachiraju, 11-01-2023, 04:46 AM
8 responses
150 views
0 likes
Last Post rehmans
by rehmans
 
Started by mattbsea, Today, 05:44 PM
0 responses
6 views
0 likes
Last Post mattbsea  
Started by RideMe, 04-07-2024, 04:54 PM
6 responses
33 views
0 likes
Last Post RideMe
by RideMe
 
Started by tkaboris, Today, 05:13 PM
0 responses
6 views
0 likes
Last Post tkaboris  
Working...
X