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 04-08-2008, 12:51 PM   #1
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default MRO logic question

Greetings,

I've got this line of code in a strategy, it seems to work fine:

LO_CONSTRAINT = MRO(delegate {return VarStoch(3, 5, 3, 3).VarStoK[0] >= 97;}, 1, NEW_RISE);

The next line uses this value in the following command:

HI_CONSTRAINT = MRO(delegate {return VarStoch(3, 5, 3, 3).VarStoK[0] < 97;}, 1, NEW_RISE - (LO_CONSTRAINT + 1));

This returns a value of "0", which it should not. I simply want to "go back" to the "LO_CONSTRAINT" value (+1 bar) FROM the "NEW_RISE" value and calculate the last time the VarStoK value was < 97...where is the logic error here?

Thus for example if "NEW_RISE" is bar #500 and "LO_CONSTRAINT" is 15 bars before that (#485) I want to get the "HI_CONSTRAINT" value to be the last true conditional measured back from bar #484...hope that makes sense...thanks in advance for any advice.
Burga1 is offline  
Reply With Quote
Old 04-08-2008, 11:33 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Hi Burga1,

I feel you may be misinterpreting how the lookBackPeriod parameter is used. Whatever value you pass in is in relation to where you currently are on the chart. You will always start MRO at CurrentBar (the last bar of the chart). You pass in lookBackPeriod as a value that it will look back in relation to CurrentBar and NOT as an absolute bar you want it to look back to.

For instance, the last bar of the chart is bar # current bar. This bar can also be seen as 0 from a backward view. The lookBackPeriod will be 10. This implies 10 bars look through the 10 previous bars from the last bar. The absolute bar number it will lookback to is CurrentBar - 10, but you would pass in 10 as the lookBackPeriod.

Hope that helps.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-09-2008, 09:26 AM   #3
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

OK, thank you. I think I am misinterpreting. What if I wanted to look for an MRO within a certain time frame? For example if I check for a conditional FROM 20 bars back to 10 bars back? Thus only for those 10 bars that are now in a "past" timeframe (compared to CurrentBar)...Possible?
Burga1 is offline  
Reply With Quote
Old 04-09-2008, 08:18 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

I would suggest creating your own loop to do that in your situation then. A for loop or a while loop should do the trick rather than hacking about trying to force MRO to work in the context you want.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-09-2008, 08:56 PM   #5
Burga1
Senior Member
 
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
Default

OK, sounds good...I'll give it a try.
Burga1 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
simple order management logic problem Willl Strategy Development 3 03-27-2008 11:13 AM
Daily charts not implementing logic correctly Lost Trader Indicator Development 6 03-19-2008 05:03 PM
Ninjascript logic and Live Orders ohowie General Programming 3 01-19-2008 09:10 AM
Order Pending Logic Oli Automated Trading 12 04-02-2007 03:13 AM
Order logic and OnBarUpdate MrBaffalo Strategy Development 2 01-29-2007 04:54 AM


All times are GMT -6. The time now is 10:52 PM.