A question for connoisseurs of Amibroker.

Here is a script for an example. When I run Explore on a stock portfolio (to get buy signals for tomorrow), it gives not only the necessary signals, but they too, for which positions have already been opened (for example, yesterday, the day before yesterday, etc.). How to Ignore Repeated Signals. I mean that, for example, the day before yesterday a position on XXX shares was already opened. But since the entry condition is still valid, even today we receive a signal to buy XXX. And how to make this signal no longer exist, since the position on XXX is already open and re-entry is not provided.

SetPositionSize(10, spsPercentOfEquity);
SetOption("MaxOpenPositions", 10);
SetOption("InitialEquity", 100000);
SetOption("UsePrevBarEquityForPosSizing", 1);
Equity(1, 0);
SetTradeDelays(0,1,0,0);
RoundLotSize = 1;

///////////////////////

Setup = BarCount > 20 AND
Close < MA(Close, 5);

lim = Close – ATR(10);
prior = ATR(10);

Buy = Ref(Setup, -1) AND Low < Ref(Lim, -1);
BuyPrice = Min(Ref(Lim, -1), Open);
PositionScore = prior;

Exit = Close > MA(Close, 5) AND BarCount > 20;
Sell = Exit;

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

Filter = Setup;
Shares = 100000/Lim;

//AddColumn(Filter, &quot;Buy&quot;, 1);
AddColumn(Lim, &quot;LimitPrice&quot;);
AddColumn(Shares, &quot;Shares&quot;, 1.0);
AddColumn(PositionScore, &quot;Priority&quot;, 1.5);

  Bundle of investment news: reports, Facebook and Chinese
Scroll to Top