Hi Gurus
I am working with Buy/Sell Pop up signal .
sometimes ,first buy signal(popup) is not working where as Alert for the same signal is working.
Please Help . Below is my code
_SECTION_BEGIN( "Main" );
_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 ); //Enable X-Axis (Date/Time Axis)
per = 0;
sec = 5;
Plot( Close, "Candles", colorDefault, styleCandle ); //Plot Candles
Plot( EMA( C, 20 ), "EMA20", colorYellow, styleThick );
Plot( EMA( C, 50 ), "EMA50", colorBlue, styleThick );
Buy=Sell=0;
Buy = Cross( EMA( Close, 20 ), EMA( Close, 50 ) );
Sell = Cross( EMA( Close, 50 ), EMA( Close, 20 ) );
PlotShapes( IIf( Buy, shapeSquare, shapeCircle ), colorGreen, 0, L, Offset = -10 );
PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorLime, 0, L, Offset = -20 );
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, 0, L, Offset = -15 );
PlotShapes( IIf( Sell, shapeSquare, shapeNone ), colorRed, 0, H, Offset = 40 );
PlotShapes( IIf( Sell, shapeSquare, shapeNone ), colorOrange, 0, H, Offset = 50 );
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorWhite, 0, H, Offset = -45 );
sellsignal = LastValue( Sell );
buysignal = LastValue( Buy );
BuyPrice = ValueWhen( Buy, Close );
SellPrice = ValueWhen( Sell, Close );
sellcount = 0;
buycount = 0;
AlertIf( Sell, "", Name() + " Sellprice=" + SellPrice, 2 );
AlertIf( Buy, "", Name() + " Buyprice=" + BuyPrice, 1 );
if(LastValue(Sell)!=0 AND sellcount == 0 )
{
PopupWindow( "sellprice=" + SellPrice, Name(), sec );
Say( "sell Order Placed" );
buycount = 0;
sellcount = 1;
}
if(LastValue(Buy)!=0 AND buycount == 0 )
{
PopupWindow( "buyprice=" + BuyPrice, Name(), sec );
Say( "buyOrder Placed" );
buycount = 1;
sellcount = 0;
}
_SECTION_END();