Limit Exploration Results To A Count

Hello All,
My purpose is to restrict and get only first 3 results from exploration whenever it is run.

Could you please guide me which parameters can help me with it

Reading about AddSummaryRows( 16, 1.2 ); which gives the count, however how can a restriction if the value is > 3 then the exploration stops there it self be imposed.

In this example only first 3 results should have been printed
image

Filter = C > O;// add your initial filter here

/// output only n-recent true filter occurrences
/// @link https://forum.amibroker.com/t/limit-exploration-results-to-a-count/12622/2
n = 3;// set N most recent filter occurrences
cum_filt = Cum(Filter);
Filter = Filter AND cum_filt >= Max(1,LastValue(cum_filt)-(n-1));

SetSortColumns(-2, 1);

AddColumn(cum_filt, "Cum(Filter)", 1 );
AddColumn(O, "Open", 1.4 );
AddColumn(C, "Close", 1.4 );
7 Likes

Thank you so much for your guidance

1 Like

Hi @krishnakhanna,

Trying with this code provided by@fxshrat, but result not restricted.

using the below code. Can you please help.

Filter = Buy  ;
n = 5;// set N most recent filter occurrences
cum_filt = Cum(Filter);
Filter = Filter AND cum_filt >= Max(1,LastValue(cum_filt)-(n-1));

SetSortColumns(2, 1);

AddColumn(cum_filt, "Cum(Filter)", 1 );
AddColumn(O, "Open", 1.4 );
AddColumn(C, "Close", 1.4 );

When run this shows all signal.

Thanks and regards,

1 Like

No, what you say is incorrect (besides your Buy is unknown).
Anyway that code I've posted does not show all signals!
It shows n-most recent TRUE PER SYMBOL!

And BTW please do not remove original description and link from code you have not come up with yourself. I consider it disrespectful.

Buy = C > MA(C, 20);

Filter = Buy;// add your initial filter here

/// output n-recent true filter occurrences PER SYMBOL!
/// @link https://forum.amibroker.com/t/limit-exploration-results-to-a-count/12622/5
n = 5;// set N most recent filter occurrences
cum_filt = Cum(Filter);
Filter = Filter AND cum_filt >= LastValue(cum_filt)-n+1;

SetSortColumns(1, -2);

AddColumn(cum_filt, "Cum(Filter) old", 1 );
AddColumn(Cum(Filter), "Cum(Filter) new", 1 );
AddColumn(O, "Open", 1.4 );
AddColumn(C, "Close", 1.4 );

32

3 Likes

First of all SORRY.

I don't have any intention to disrespect you. You always help us to learn AFL in correct way. Actually for description and link ,I clearly wrote code provided by you.

There was a misunderstanding from my side with this result, when tested.
I thought it will restrict the number of signal generated from the strategy for MULTIPLE SYMBOL.

In future corresponds i will be much more careful about the original description and link.

Please accept my sincere apologies for the unintentional removing original description and link from code.

1 Like