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.
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.
Thanks for replying. But this also doesnt work. Ok let me explain again. Take a example of 5 mint chart. Price cross up 50 EMA at 1.00 PM and MACD is grater than signal line then buy signal will appear. Or Price cross up 50 EMA at 1.00 PM and Macd Cross up Signal Line at 1.30 PM , then a buy signal would appear.
Now suppose price remains above 50 EMA but at 1.45 PM Macd cross Down Signal Line , and then at 2 PM, it again cross up Signal Line. Because price is already above 50 ema , then a double buy signal will appear at 2 PM. Now there will be two buy signals, one which generated at 1.30 PM, 2nd which generated at 2 PM.
What I want that there should be only one buy signal for the fresh cross of macd above signal line, after the price crossed above 50 ema.
Now lets talk abt your afl . I copy pasted your afl conditions as following
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates,colorRed);
Plot(C,"Price",IIf(C>O,colorSeaGreen,colorBrown),styleCandle);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}
Plot(EMA(Close,50),"50EMA",colorRed,style=styleThick);
_SECTION_END();
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;
AddColumn(Close,"Close",1.4);
AddColumn(Buy,"buy",1.2);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0, L, Offset=-20);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorBlue, 0,L, Offset=-30);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25);
Just watch Nifty futures on 29th July 2011, on 1.05 PM Nifty Future closed above 50 ema, and Macd was above signal line. There should be a Buy signal. But no buy signal appeared. Then price crossed up 50 ema again at 1.25 PM and 1.45 PM while MACD was above signal line but again no buy signal apperaed. Im attaching image