Exploration -result -set control

Dear Tomasz & seniors,

i done exploration using below code ,it's match with chart..but small issue..
mean once buy generated every minute the buy signal continue upto sell generate then vice versa..

i expect/need once buy generated it will stay in buy upto sell generate..
(pls see picture..i dont kow how to exactly explain the issue)

_SECTION_BEGIN("crossover e15 e60");

E15 = EMA(o, 15);
E60 = EMA(o, 60);

BTrig = Cross(e15, e60);
STrig = Cross(e60, e15);


BT = Flip(BTrig, STrig);
ST = Flip(STrig, BTrig);

B_High = ValueWhen(Btrig, H, 1);
S_Low = ValueWhen(STrig, L, 1);


Buy = BT AND H > B_High;
Short = ST AND L < S_Low;





ShortPrice =C ;
Cover =C;
CoverPrice =C;
BuyPrice=C;
Sell=C;
SellPrice=C;

SetPositionSize( 100, spsShares );
E=Equity(1);

Filter= 1 AND  (Buy OR Short) ; //AND BARCOMPLETE ; //AND ( C > 200) ; ; // OR AAA);

AddColumn(IIf(Buy,BuyPrice,Null)," Buy Signal ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Short,ShortPrice,Null)," Sell Signal ",6.2,1.2,colorOrange); 
AddColumn(C , "close");



explore%20error

Study the ExRem() function

https://www.amibroker.com/guide/afl/exrem.html
General use is like this

buy = ExRem( buy, sell );
sell = ExRem( sell, buy );

It is meant to remove excess signals.

1 Like

The previous post misses the point or actual main problem of 1st post's code.

First of all Equity function removes excessive signals already so there is no need for ExRem.

Secondly the actual main problem of the code of post 1 is that @madhan uses Close array as Sell and Cover signal. Sell and Cover rather expect True (1) / False (0) condition as proper signal array but not just price array. It is not wrong adding just price alone to Signal variables but it does not make sense. Why does it make no sense? If you just assign Close to Cover and Sell then Cover and Sell are always true if Buy/Short are true as Close price is greater zero (false) for entire array. In the same way you could just write Sell = Cover = 1; and would have same effect. Sell = Cover = 1; means there is Sell/Cover at every bar of Buy/Short signal (if no delay is set).

So, I do not think that you do want such exit signals, @madhan, do you? So of course you get continuous buy and short rows in explorer since there is immediate exit after entry.

So if you do not want Sell = Cover = 1; then create proper sell cover rules returning true or false. E.g.

Sell = Cross(Ma(C,20), C); 

BTW, @madhan
you write "Sell signal" in AddColumn but actually Short in Amibroker terms is entry signal. So Short is not Buy exit!

Correction:

AddColumn(IIf(Short,ShortPrice,Null)," Short Signal ",6.2,1.2,colorOrange); 

And just another BTW,
if you want to output exit signals in explorer too then you would have to add them to Filter containing "Buy or Short" already.

Filter = Buy or Sell or Short or Cover;

And adding columns for Sell and Cover.


Note:
Explorer is not supposed to be backtester.
If you want to do backtest then remove Equity function + explorer code and apply Backtest button of analysis.

2 Likes

Dear Fxshrat..
i got solution as per ur advice ,modified the code "sell=short" ,excess signals removed..
one more help...
explore window set every 1 min ,while get "buy/sell signal" it's not updated in explore window automatically , mean manually click "date/time' column to refresh signal/exploration result..

how to do it automatically refresh? pls see picture.
explore

There is function SetSortColumns for programmatically sorting analysis results. In your picture datetime column seems to be second column. So if you want to sort in descending order then add -2 otherwise add 2 instead.

E.g.

SetSortColumns(-2);
1 Like

Dear Fxshart..yes, works well..
one more i need to every time click explore button to refresh latest "signal "..
i set 1 min in setting for "long&short"
but it's not refersh automatically..

pls help

http://www.amibroker.com/kb/2014/10/03/how-to-setup-perodic-scans/

To enable continuous screening, mark Auto-repeat (AR) Scan/Explore option and enter the repeat interval.

repeat

Dear Travick, i tried this but i am not able to..
and not able to change 5 min to 1min in" AR Interval" column also..

pls help..

Type your interval in that textbox and hit the enter key.
After that, manual click Exploration button once.

1 Like

yes, as per ur advice changed 1min from 5 min with "enter"
Yes, it's work like charm..

Thanks for Travick & Fxshart for continues support to this forum to unknown ...

:grin:

@madhan, the solution to your first post is not the post mentioning SetSortColumns. But if there is solution then it rather is the 3rd post explaining why Sell = Cover = C; are not proper exit rules and being the reason for your first picture's result list. And telling that Short not being exit rule to Buy entry. And noting that explorer is not supposed to be backtester substitute.

Questions about SetSortColumns and Autorepeat are just follow up questions which not really got something to do with your original issue.

1 Like

Dear fxshart.. my first post issues resolved as per your advice ..mean excess signal removed..got proper ouput in explorer..

yes ,the " setsortcoloumns" is the additional query of explorer..

Thanks again once..

Sorry but you still don't understand. You should mark post that is actual solution to first intial post of thread. You marked SetSortColumns post as solution to 1st post which is misleading as it is also shown below of first post. It is misleading to other readers facing similar problem. Do you understand now?

Oh!! sorry, i got your point.i removed "solution' mark on that post..
hereafter will do proper...

Thanks

Dear fxshrat ,travick,milosz,beppe & other senoior experts,
below explore afl works fine but the alert output always say " Buy signal"only even sell signal generated..

what is the issue..pls correct the code..

_SECTION_BEGIN("crossover e15 e60");


E15 = EMA(o, 15);
E60 = EMA(o, 60);

BTrig = Cross(e15, e60);
STrig = Cross(e60, e15);


BT = Flip(BTrig, STrig);
ST = Flip(STrig, BTrig);

B_High = ValueWhen(Btrig, H, 1);
S_Low = ValueWhen(STrig, L, 1);


Buy = BT AND H > B_High;
Short = ST AND L < S_Low;



ShortPrice =C ;
Cover =C; 
CoverPrice =C;
BuyPrice=C;
Sell=short;
SellPrice=C;

SetPositionSize( 100, spsShares );
E=Equity(1);

Filter= 1 AND  (Buy OR Sell) ; 

AddColumn(IIf(Buy,BuyPrice,Null)," E15/60Buy @ ", 6.2,1.2,colorGreen); 
AddColumn(IIf(Sell,SellPrice,Null)," E60/15Sell @ ",6.2,1.2,colorOrange);

AddColumn(C , "close");

SetSortColumns(-2);


if (SelectedValue(Buy)==1) Say("BUY Signal Now ");
if (SelectedValue(Sell)==1) Say("Sell Signal Now");

Thanks

Dear Fxshrat & senior experts,please look into my post no:15 ,
me to resolve the issue.

Thanks