_SECTION_BEGIN("ADX + RSI + MACD");
// This combines three indicators into one timing Signal
//function ParamOptimize( description, default, minv, maxv, step )
// { return Optimize(description, Param(description,default, minv, maxv, step ), minv, maxv, step ); }
tgl = ParamToggle("Result", "AND logic|Compare");
SetPositionSize( 100, spsShares );
// rsi
RSI1= RSI(14)>30;
RSI2= RSI (14)<70;
// adx di lines
range = Param("ADX Periods", 10, 2, 200, 1 );
myPdi = PDI(range );
myMdi = MDI(range );
upAdx = IIf( myPdi > myMdi, 1, 0);
// macd
r1 = Param( "Macd Fast avg", 12, 2, 200, 1 );
r2 = Param( "Macd Slow avg", 26, 2, 200, 1 );
r3 = Param( "Macd Signal avg", 9, 2, 200, 1 );
myMacd = MACD(r1,r2);
mySignal = Signal(r1,r2,r3);
upMacd = IIf(myMacd > mySignal, 1, 0);
// switch test calculation and compare the results
if(tgl)
{
myBuy = RSI1 AND upAdx AND upMacd;
myShort = !RSI1 AND !upAdx AND !upMacd;
}
else
{
myBuy = IIf(RSI1 AND myMacd > mySignal AND myPdi > myMdi,1,0);
myShort = IIf(RSI2 AND myMacd < mySignal AND myPdi < myMdi,1,0);
}
Buy = Cover = ExRem(myBuy, myShort);
Short = Sell = ExRem(myShort, myBuy);
PlotShapes(Buy*shapeUpArrow,colorWhite,0,H,Offset=-40);
PlotShapes(Sell*shapeDownArrow,colorYellow,0,L,Offset=-40);
The above afl i found on internet..i want to have new position everydayd.. means no carryover position from yesterday.fresh intraday signal for buy and sell.. but it not giving fresh signals everytime macd get crossover..
can there be modification in the afl which checks if macd get crossed with signal and RSI>70 then it should generate fresg signal after confiriming two to three bars back.