Kindly support to remove the excess signal when the RSI is touched 60.
I tried with Exrem and for loop function, but it is not working due to rsi is touching the level 60 in the samebar.
After that i tried with amibroker community, from this i tried with addtocompositive function. still the issue is not resloved.
Kindly support for Reslove this issue. ( Entry = Rsi() > 60 and Exit = Rsi() <60)
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
SetChartOptions(0,chartShowArrows|chartShowDates);
NEWDAY = Day() != Ref(Day(),-1);
EndDay = (Day()!= Ref(Day(), 1));
Squareoftime =ParamTime("Trade Exit","15:15:00");
Entry_End = ParamTime("Entry End","14:15:00");
MA20 = MA(C,20);
buycondition = O < MA20;
Shortcondition = O > MA20 ;
BUY1 = Ref(buycondition,-2) AND O > MA20;
Short1 = Ref(Shortcondition,-2) AND O < MA20;
RSIB = RSI(15) > 60;
RSIS = RSI(15) < 40;
AddToComposite( RSIB, "~RSIBuy", "V");
Graph0 = RSIBC = Foreign("~RSIcomp", "V");
AddToComposite( RSIS, "~RSIShort", "V");
Graph0 = RSISC = Foreign("~RSIcomp", "V");
Buy = RSIBC AND Buy1 AND (TimeNum() <= Entry_End) ;
Short = RSISC AND Short1 AND TimeNum() <= Entry_End;
Cover =BarsSince(Short) AND (TimeNum() >= Squareoftime) ;
Sell = BarsSince(Buy) AND (TimeNum() >= Squareoftime);
BuyPrice = C;
ShortPrice = C;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);
Moderator comment: YOU MUST USE CODE TAGS! I added them now, but won't accept any more posts without code tags!
Agreed. These are totally useless in that code. Typical "reason" is that user does not know what he is doing and trying to copy random pieces from the Internet, paste them in random order and be surprised it does not work.
Recommended reading for original poster:
As to "duplicate" orders - did you bother to read http://www.amibroker.com/guide/h_portfolio.html There are no duplicate orders because duplicate SIGNALS are filtered by the backtester. And no you don't need ExRem for the backtester.
You don't need to test if position is open to issue Sell or Cover because backtester does NOT sell or cover position that is not open. Hence all those BarsSince() calls are redundant and should be removed.
And follow advice given here:
To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?