• 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 jjnc2006, Today, 07:36 PM
0 responses
5 views
0 likes
Last Post jjnc2006  
Started by futurenick, Today, 06:26 AM
1 response
11 views
0 likes
Last Post nkhoi
by nkhoi
 
Started by NinjaCustomer, Today, 12:29 PM
1 response
9 views
0 likes
Last Post NinjaTrader_ShawnB  
Started by Steve L, Today, 11:32 AM
0 responses
7 views
0 likes
Last Post Steve L
by Steve L
 
Started by prabbala, Today, 10:41 AM
0 responses
4 views
0 likes
Last Post prabbala  
Working...
X