Need help with Simple EMA+MACD AFL

singhboy

Active Member
#1
Hi Every1, I need help with this buy sell conditions signals on chart.
When price cross 50 EMA up side and MACD line is above Signal Line , buy signal should appear.
this can be like
Buy = cross (c, ema(c,50),) and macd() > signal() ;

But this generate signal only when two conditions are met on same candle. While I want that if price crossed 50 ema on this candle and macd cross up after 1 or 2 candles buy signal should appear later, means after crossing 50 EMA whenever the MACD cross signal line up, the buy signal should appaer.
And it should not be like that if price is already above 50 EMA and then MACD cross above signal line, then there should be no signal. Buy signal should be for fresh price cross above 50 EMA and then whenever MACD cross signal line upside. Thanks bros
 

hitesh

Active Member
#2
Hi Every1, I need help with this buy sell conditions signals on chart.
When price cross 50 EMA up side and MACD line is above Signal Line , buy signal should appear.
this can be like
Buy = cross (c, ema(c,50),) and macd() > signal() ;

But this generate signal only when two conditions are met on same candle. While I want that if price crossed 50 ema on this candle and macd cross up after 1 or 2 candles buy signal should appear later, means after crossing 50 EMA whenever the MACD cross signal line up, the buy signal should appaer.
And it should not be like that if price is already above 50 EMA and then MACD cross above signal line, then there should be no signal. Buy signal should be for fresh price cross above 50 EMA and then whenever MACD cross signal line upside. Thanks bros
This should work:

Buy1 = Cross (C, EMA(C,50) AND MACD() > Signal() );
Buy2 = C > EMA(C,50) AND Cross(MACD(), Signal() );

Buy = Buy1 OR Buy2;
 

singhboy

Active Member
#3
Buy2 = C > EMA(C,50) AND Cross(MACD(), Signal() );

In this condition brother, if price remains above 50 ema but macd cross up and down 6 times, then 3 times buy signals will appear. While I have written that Buy signal should appear only for fresh cross of price above 50 ema. Means If price crossed 50 ema and whenever later macd cross upside, a buy signal should appear. Later If macd keep on crossing up and down, no signal should appear.
 
#5
how about this.

cema = Cross (C,EMA(C,50));
Buy = IIf ( Cross(MACD(), Signal())&& Sum(cema ,5),True,False);

//Sum(cema ,5)=true if Close crossed EMA in the past 5 bars.
 

myamit

Well-Known Member
#7
Hi Every1, I need help with this buy sell conditions signals on chart.
When price cross 50 EMA up side and MACD line is above Signal Line , buy signal should appear.
this can be like
Buy = cross (c, ema(c,50),) and macd() > signal() ;

Buy signal should be for fresh price cross above 50 EMA and then whenever MACD cross signal line upside. Thanks bros
Hello Singhboy,

You can try following...

B1 = Cross (C, EMA(C,50));
S1 = Cross (EMA(C,50),C);
B1 = Flip(B1,S1);
B2 = MACD() > Signal();
B2 = ExRem(B2,S1);

Buy = B1 AND B2;

Feel free if you need any further help.
 
#8
Re: Nedd help this formula error

_SECTION_BEGIN("7-34 cross");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot(Close,"Price",colorWhite, styleCandle);
Plot(EMA(Close,7),"7EMA",colorGreen,style=styleThi ck);
Plot(EMA(Close,34),"34EMA",colorRed,style=styleThi ck);
Buy=Cross(EMA(Close,7),EMA(Close,34));
Sell=Cross(EMA(Close,34),EMA(Close,7));
Short=Sell;
Cover=Buy;
shape = Buy * shapeSmallUpTriangle + Sell * shapeSmallDownTriangle;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );
_SECTION_END();
 
#10
Hello Singhboy,

You can try following...

B1 = Cross (C, EMA(C,50));
S1 = Cross (EMA(C,50),C);
B1 = Flip(B1,S1);
B2 = MACD() > Signal();
B2 = ExRem(B2,S1);

Buy = B1 AND B2;
 
Last edited:

Similar threads