![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
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?
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Nov 2007
Posts: 388
Thanks: 0
Thanked 0 times in 0 posts
|
OK, sounds good...I'll give it a try.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |