NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 03-31-2010, 11:02 AM   #1
binwang2
Senior Member
 
Join Date: Jan 2009
Posts: 216
Thanks: 0
Thanked 1 time in 1 post
Default On SampleMultiTimeFrame

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,


binwang2 is offline  
Reply With Quote
Old 03-31-2010, 11:41 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

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.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-31-2010, 12:24 PM   #3
binwang2
Senior Member
 
Join Date: Jan 2009
Posts: 216
Thanks: 0
Thanked 1 time in 1 post
Default

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,
binwang2 is offline  
Reply With Quote
Old 03-31-2010, 12:38 PM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,569
Thanks: 262
Thanked 1,018 times in 999 posts
Default

This is correct BinWang2.
NinjaTrader_Bertrand is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 01:23 AM.