PDA

View Full Version : NT7 - CurrentBar internal pointers updated earlier


Shansen
05-31-2010, 03:20 AM
All,

In relation to the below NT7 Code breaking change, please confirm the change only serves to sync multiple series.

CurrentBar internal pointers are now updated earlier. This ensures that accessing bars across multiple series will be in sync regardless of which BarsInProgress context you may be working out of.
o For historical, pointers for all bar series with the same timestamp will be updated before
OnBarUpdate() will be triggered.
o For real-time, pointers for all bar series of the same instrument will be updated before
OnBarUpdate() will be triggered.

In the event a Strategy is designed to execute realtime in the last few seconds of a bar (with CalculateOnBarClose = false), to get meaningful results from the Strategy Analyzer (where OnBarUpdate() is only called on the close of each historical bar) does execution information still have to refer to the prior bar? For example, VariableWhatever = High[Historical ? 1 : 0];

Regards
Shannon

NinjaTrader_Bertrand
05-31-2010, 08:42 AM
Shannon, this is correct in backtesting you would refer to High[0] and in realtime trading with COBC = false this would be referred to High[1] still.

Shansen
06-05-2010, 07:26 PM
Bertrand,

Thank you for the reply. Unfortunately it is 100% contrary to my understanding.

Where CalculateOnBarClose = false....

In the attached diagram, a realtime strategy is designed to execute just prior to bar close enter approximately at bar close (circled red) and set the High and Low of the current bar as variables.

Now, where this strategy is run on historical data, the strategy is executed at bar close. Entry will be at the open of the subsequent bar (circled red). Should the High of execution bar be set as High[1] (as per diagram) or High[0]?

I'm of the believe that it should be High[0] but am receiving errors from TraceOrders.

Regards
Shannon

NinjaTrader_Josh
06-07-2010, 09:05 AM
Shannon,

Your diagram is inaccurate. When you are backtesting the bar you have marked with High[1] and Low[1] is not [1] indexed. That is the [0] index at the point in time the strategy is processing that bar. What it decides to do as an action for trading is then done on the next bar. When you get to the next bar and placed the trade then the bars you are referencing do become [1] indexes, but until then, they are [0] for programming purposes.

CalculateOnBarClose = false in realtime will show [0] on the bar you are checking and then it will be able to place trades on that same bar as well.