Dear all.
Found this afl on net.I have deleted stochastics part and changed the ema values as per our requirement.
Though it is working i think something is missing.Experts pl. check this and add/repair it if it is necessary.
Thanks & regards.
Found this afl on net.I have deleted stochastics part and changed the ema values as per our requirement.
Though it is working i think something is missing.Experts pl. check this and add/repair it if it is necessary.
Thanks & regards.
Code:
_SECTION_BEGIN("MA-MACD-STOCH");
//////////////////// MA 3-5////////////////////////////////
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot(Close,"Price",colorWhite, styleCandle);
Plot(EMA(Close,3),"3EMA",colorGreen,style=styleThick);
Plot(EMA(Close,5),"5EMA",colorRed,style=styleThick);
BMA=Cross(EMA(Close,3),EMA(Close,5));//BUY MA COND
SMA=Cross(EMA(Close,5),EMA(Close,3));//SELL MA COND
BBMA=BarsSince(BMA);//How many Bars ago ma bullish crossover happened
BSMA=BarsSince(SMA);//How many Bars ago ma bearish crossover happened
///////////////////////MACD////////////
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
ml = MACD(r1, r2);
sl = Signal(r1,r2,r3);
BMCD=Cross(ml,sl);//BUY MACD COND
SMCD=Cross(sl,ml);//Sell MACD CONDITION
BBMCD=BarsSince(BMCD);//How many Bars ago MACD bullish crossover happened
BSMCD=BarsSince(SMCD);//How many Bars ago MACD bearish crossover happened
Buy= BMA AND (BBMCD-BBMA<3) ;
//EXPLANATION
////(BBMCD-BMAB<3)=diff between MA BUY cross and MACD BUY cross <=3 bars)
Sell=SMA AND (BSMCD-BSMA<3) ;
//EXPLANATION
////(BSMCD-BSAB<3)=diff between MA SELL cross and MACD sell cross <=3 bars)
shape = Buy * shapeSmallUpTriangle + Sell * shapeSmallDownTriangle;
PlotShapes( shape, IIf( Buy, colorBrightGreen, colorRed ), 0, IIf( Buy, Low, High ) );
Filter=Buy OR Sell;
AddColumn(IIf(Buy,1,IIf(Sell,-1,Null)),"B/S",0,colorDefault,IIf(Buy,colorGreen, IIf(Sell,colorRed,Null)));
_SECTION_END();