Exploration filter code

Hello,
The filter code below is supposed to limit the number of rows in an exploration to 5. First up, do you agree the code is correct? Why do I ask? Because it works on one pc but not on another....very strange. That is, I get more than five rows on one pc and only five on another. Any thoughts appreciated as to what could cause the difference.

Filter = c > 100;
/// output only n-recent true filter occurrences
n = 5;// set N most recent filter occurrences
cum_filt = Cum(Filter);
Filter = Filter AND cum_filt >= Max(1,LastValue(cum_filt)-(n-1));

First of all the posted code is taken from here

If you get different results then

  1. analysis settings may be different (so instead use same APX project file)
  2. different data
  3. ...

Further information to be found here
https://www.amibroker.com/kb/2015/01/28/why-analysis-results-and-chart-output-may-differ/

Thanks for the reply...had no idea the code came from the source you mentioned. It was emailed to me from a friend.

Regards

When posting code that is not your own you are supposed to give credit to original author.
These are forum rules.
You need to teach your "friend" NOT to remove copyright notes and @link statements from original formula taken from the forum.
People like @fxshrat spend time writing code for free - show some respect and appreciation to those who actually give their time to others and at minimum acknowledge original author, click on "heart" to like their post and mark post as "solution". This takes less then a second.

5 Likes