Hello All,
I face a problem that I am not able to fix and explain. Would like to ask a question here and see if anything I am missing, thanks.
Here is my system, and I try to visualize the signal. As you can see, there are two Buy signals generated. I have already applied the exrem, if not, it would look like this:
Also, I try to run the scan and backtest, and duplicate signal is on scan but not on the backtest.
Then I tried to trace the variable in my code and found the reason:
MA1 = MA(O, period);
MA2 = MA(O, period2);
POver = Cross(MA1, MA2);
PUnder = Cross(MA2, MA1)
AverageP = (H + L + C + C )/4 ;
AH = round(AverageP + (H - L));
AL = round(AverageP - (H - L));
Upper = ValueWhen(POver, ref(AH,-1));
Lower = ValueWhen(PUnder, ref(AL,-1));
UpperBarsSince = BarsSince(POver);
LowerBarsSince = BarsSince(PUnder);
UpperBarsSince = UpperBarsSince +1;
LowerBarsSince = LowerBarsSince + 1;
Buy1 = H >= Upper;
Buy1 = Buy1 AND Sum(Buy1, UpperBarsSince) <= 1 AND UpperBarsSince < LowerBarsSince;
Short1 = L <= Lower;
Short1 = Short1 AND Sum(Short1, LowerBarsSince) <= 1 AND LowerBarsSince < UpperBarsSince;
Buy = Buy1;
BuyPrice = Max(O, Upper);
Short = Short1;
ShortPrice = Min(O, Lower);
cover1 = Buy;
Cover = cover1;//
sell1 = Short;
Sell = sell1;
CoverPrice = IIf(cover1, BuyPrice, O);
SellPrice = IIf(sell1, ShortPrice, O);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);
My 2nd Buy signal is generated becoz one of my conditions, POver = Cross(MA1, MA2), is true again after the first Buy signal. As the Buy1 turns true again(repeated signal), so Buy is true again too. But my question is, EXREM should have removed these repetitive signals? it does autally but why this one is missing?
Thanks a lot.