Hi all Amibroker fans,
When a sell signal is given by the hit of an applystop there is no new buy after that occurred.
In the simplied code you could see the buy signal and the test signal which are exactly the same, but the Buy shows only the first signal and redundant signals are removed by the Buy = ExRem(Buy, Sell) function.
There is no regular Sell function (Sell=0), only a take profit stop and a take loss stop.
After the applystop generates an sell signal sell==3 there is no new buy signal but there are losts of new buy oppertunities when test == 1.
Please turn on the intrepertation window for easy testing yourself.
Can anyone PLEASE help me to solve this problem ?
// Please Put "ON" interpertation window
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
SetTradeDelays(0,0,0,0); // No delays
DEMA10 = DEMA((Open+Close)/2,10); // DOUBLE EXPONENTIAL MOVING AVARGE MIDDLE OPEN AND CLOSE
SellVol = IIf ( (H==L), 0, V*(H-C)/(H-L) ); // SellING Volume
AvgVol = MA (Volume,30); // MOVING AVAREGE VOLUME LAST 30 DAYS
DayPctSellVol = SellVol / Volume; // TODAY'S SELLING VOLUME IN PERCENT
Buy = DayPctSellVol > 0.9 AND avgVol > 500000 AND Close < DEMA10; // Selling vol > 90%, Avg > 50000, Close < DEMA10
Test = DayPctSellVol > 0.9 AND avgVol > 500000 AND Close < DEMA10; // same as buy but repeating signal for test purpose
Sell = 0;
// Exit only by ApplyStop and not with regular sell rule.
ApplyStop( stopTypeLoss, stopModePercent, 15 ); // 15% max loss from EntryPrice
Equity(1,0);// check quotes every bar
ApplyStop( stopTypeProfit, stopModePercent, 2 ); // 2% profit target from EntryPrice
Equity(1,0);// check quotes every bar
Buy = ExRem (Buy, Sell);
Sell = ExRem (Sell, Buy);
EntryPrice = ValueWhen(Buy,Close);
ExitPrice = ValueWhen(Sell,Close);
printf ("DayPctSellVol: "+NumToStr(DayPctSellVol*100,1.2)+"\n");
printf ("AvgVol: "+NumToStr(AvgVol,1.0)+"\n");
printf ("EntryPrice: "+NumToStr(EntryPrice,1.2)+"\n");
printf ("ExitPrice: "+NumToStr(ExitPrice,1.2)+"\n");
printf ("Buy: "+NumToStr(Buy,1.0)+"\n");
printf ("Test: "+NumToStr(Test,1.0)+"\n");
printf ("Sell: "+NumToStr(Sell,1.0)+"\n");
printf ("Result: "+NumToStr(((ExitPrice/Entryprice)-1)*100,1.2)+" Procent"+"\n");
PlotShapes(Buy*shapeUpArrow,colorBrightGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
Plot(DEMA10,"DEMA10",colorYellow);
First Buy
Sell=0 AplyStop = true.
Next Buy oppertunity. Test==1 Buy signal is not 1. Why ?