• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 psquare, Today, 03:11 PM
4 responses
17 views
0 likes
Last Post psquare
by psquare
 
Started by ballboy11, Today, 03:20 PM
1 response
12 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by tonynt, Today, 02:18 PM
1 response
10 views
0 likes
Last Post NinjaTrader_JoshG  
Started by denalek2419, Today, 01:46 PM
3 responses
12 views
0 likes
Last Post NinjaTrader_ChristopherJ  
Started by REI140205, Today, 12:58 PM
1 response
11 views
0 likes
Last Post NinjaTrader_Jim  
Working...
X