![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Senior Member
Join Date: Jan 2009
Posts: 216
Thanks: 0
Thanked 1 time in 1 post
|
Hi NT experts,
In your sample code on SampleMultiTimeFrame, the condition is to process event on BarsInProgress =0: if (BarsInProgress != 0) return; However, the following code starts to evalaute values on BarsInProgress 1 and 2: if (SMA(BarsArray[1], 5)[0] > SMA(BarsArray[1], 50)[0] && SMA(BarsArray[2], 5)[0] > SMA(BarsArray[2], 50)[0]) I would assume SMA(BarsArray[1], 5)[0] would produce an error as it tries to get value from BarsArray[1] instead of 0. A realted question. What if no such contions as if (BarsInProgress != 0) return; Will this sample prouce same results? Regards, |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
With this check we ensure that OnBarUpdate() calls only would have an effect when being issued from the primary series, all other calls would cause a return out.
You can still check the BarsArray 1 and 2, as this is just a 'container' offering access to all the bars objects data points, however the call to check the specific array you need will only come from an OnBarUpdate() from the primary series. If not ensuring proper BIP calls, the orders for example good get routed to wrong objects, as the call is EnterLong() without including a specific BIP.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2009
Posts: 216
Thanks: 0
Thanked 1 time in 1 post
|
Thanks, Bertrand.
Let me paraphrase to see if my understanging is accurate: a) The data and calculation of secondary series are accessiable when processing event on primary series. b) the following should work under the condition (if (BarsInProgress != 0) return :EnterLongStop(0, true, int quantity, Highs[1][1],string signalName). The High of previous bar's high on seconary series will be correctly evaluated when submitted this order from primary series. Let me know if these are correct. Regards, |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
|
This is correct BinWang2.
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|