Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Referencing Previous Instance(s) Of Condition
Collapse
X
-
Countif for Multiple Timeframe Strategies
I've noticed in the help that the Countif function (as well as MRO/LRO functions) is caveated in that it will not work with multiple instruments or timeframes. Is this still the case, and if so, do you offer an alternative approach? Converting boolean expressions to doubles, setting these 1/0 values to a dataseries and then using the SUM function on this dataseries to count the occurances didn't work as expected.
Regards,
Whitmark
Comment
-
For clarification, consider the following example where Low[0] and Close[0] are from an hourly series (BarsInProgress = 0) and user defined variable YestDailyLow is assigned during a Daily series bar close event (BarsInProgress = 1). One would think the way to invoke a CountIf would be:
But I can see how an extended lookback might not correctly evaluate the BarsArray[1] values retained in the user defined variable YestDailyLow. Would it be helpful to retain the BarsArray[1] values in a dataseries aligned to the BarsArray[0] interval to make the CountIF work properly for multiple timeseries strategies? For example:Code:If (BarsInProgress == 0) { myCond = CountIF( delegate (return Low[0] <= YestDailyLow && Close[0] >= YestDailyLow;), 5) > 2); }
Will this work to address the caveat on the CountIf function?Code:If (BarsInProgress == 0) { myCond = CountIF( delegate (return Low[0] <= YestDailyLowSeries[0] && Close[0] >= YestDailyLowSeries[0] ;), 5) > 2); }
Regards,
Whitmark
Comment
-
Okay, but do I get points for trying? I'll cry "uncle" and use the brute force method below:
Any chance a "square peg" version of CountIf is on the development horizon? As you can image, having a function that can determine whether X conditions occured across Y events within Z bars can be pretty useful and something AmiBroker can apparently do across multiple timeframes. Thanks.Code:if (BarsInProgress == 0) { YestDailyLowSeries.Set( YestDailyLow ); int count = 0; for ( int i = 0, i < 5 && CurrentBar - 5 >= 0; i++ ) { if ( Low[i] <= YestDailyLowSeries[i] && Close[i] >= YestDailyLowSeries[i] ) Count++; } myCond = count > 2;
Regards,
WhitmarkLast edited by whitmark; 08-01-2007, 03:50 PM.
Comment
-
Any alternatives/workaround for this countif in multitimeframe
Ray,
Looking at Marks' post and your reply now....So what are the options for countif where multitimeframe is involved?. Can you pls suggest some alternatives if that means coding in c# thats fine..But I just need some ideas so that I can get the function created in C#.
Thanks.
Cheers,Padhu
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
110 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
59 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
37 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
41 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
78 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

.
Comment