NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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 06-21-2012, 09:44 AM   #1
RodS7
Member
 
Join Date: Mar 2012
Location: DFW, TX
Posts: 40
Thanks: 3
Thanked 7 times in 4 posts
Default OnBarUpdate Error

I am getting the following error message in a multi-timeframe strategy:

" **NT** Error on calling 'OnBarUpdate' method for strategy 'ZLReMTF/e610e684089b44a2b751f1e4043ed90d': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceExit() method in the context of a multi-time frame and instrument strategy."


The code associated with BarsSinceExit is:


if(BarsInProgress == 0)
{
TimeSinceExitOK = BarsSinceExit() >= 1 || BarsSinceExit() == -1;
TimeSinceEntryOK = BarsSinceEntry() >= 1 || BarsSinceEntry() == -1;
}


Anyone have any ideas?


Rod
RodS7 is offline  
Reply With Quote
Old 06-21-2012, 09:52 AM   #2
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,778
Thanks: 158
Thanked 565 times in 556 posts
Default

Hello,

BarsSinceExit() has an overload for the barsInProgressIndex that needs to be specified in an multi series script.

BarsSinceExit(int barsInProgressIndex, string signalName, int exitsAgo)

For example,

if(BarsSinceExit(1, "mySignal", exitago) == 1)

Where 1 is the BIP
NinjaTrader_Matthew is offline  
Reply With Quote
Old 06-21-2012, 10:11 AM   #3
RodS7
Member
 
Join Date: Mar 2012
Location: DFW, TX
Posts: 40
Thanks: 3
Thanked 7 times in 4 posts
Default

I must be doing something wrong...

I am getting the same error


I have changed my code as follows
TimeSinceExitOK = BarsSinceExit(1,"ZLRe1",0) >= 1 || BarsSinceExit(1,"ZLRe1",0) == -1;
TimeSinceEntryOK = BarsSinceEntry(1,"ZLRe1",0) >= 1 || BarsSinceEntry(1,"ZLRe1",0) == -1;
In your post, you used the barsInProgressIndex of 1. That is not the primary data, is it?
RodS7 is offline  
Reply With Quote
Old 06-21-2012, 10:18 AM   #4
NinjaTrader_Matthew
NinjaTrader Customer Service
 
NinjaTrader_Matthew's Avatar
 
Join Date: Apr 2010
Location: Denver, CO, USA
Posts: 4,778
Thanks: 158
Thanked 565 times in 556 posts
Default

barsInProgressIndex of 1 would be the second data series.


The primary series is 0. Do you continue to receive errors if you use 0 as the bIP Index?
NinjaTrader_Matthew is offline  
Reply With Quote
Old 06-21-2012, 10:26 AM   #5
RodS7
Member
 
Join Date: Mar 2012
Location: DFW, TX
Posts: 40
Thanks: 3
Thanked 7 times in 4 posts
Default

my mistake - I had changed to '0' but I had missed one instance of BarsSinceExit in the code

problem solved

thanks
RodS7 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnBarUpdate() Error Zeos6 General Programming 29 03-28-2011 04:02 PM
Error on calling OnBarUpdate juanfer Strategy Analyzer 3 03-24-2011 10:37 AM
Error: OnBarUpDate cannot be null Taddypole Indicator Development 1 02-24-2011 05:35 AM
Error On Calling OnbarUpdate neb1998 Strategy Development 1 01-27-2011 02:58 PM
Error OnBarUpdate for strategy eurostoxx trader Strategy Development 1 07-06-2010 06:36 AM


All times are GMT -6. The time now is 09:32 AM.