Trade when current price > ema

HI,

I want to buy when 15 mints candle open above EMA, 5,14,26 and for sell vice versa

Please helpp

See How to ask a good question.

Then post up your attempted code.

This forum is not a free coding service!

2 Likes

Dear TrendSurfer, I note that I deleted the original answer and corrected it with a newer, I think more correct. I hope this helps you.

_SECTION_BEGIN( "Plot Candles" );
GraphXSpace = Param( "GraphXSpace ", 2, 1, 20, 1 );
SetChartBkColor( ParamColor( "backColor ", colorBlack ) );

PlotCandle = ParamList( "Candlestick Style", "My Style|ED Style", 1 );

switch( PlotCandle )
{
case "My Style":
    SetChartBkColor( colorblack );
    SetBarFillColor( IIf( C > O, colorDarkBlue, colorDarkRed ) );
    Plot( C, "", IIf( C < O, colorGrey50, colorGrey50 ), styleCandle ) ;
    break;
case "ED Style":
    SetChartOptions( 0, chartShowDates );
    SetBarFillColor( IIf( C > O, ColorRGB( 0, 75, 0 ), IIf( C <= O, ColorRGB( 75, 0, 0 ), colorLightGrey ) ) );
    Plot( C, "", IIf( C > O, ColorRGB( 0, 255, 0 ), IIf( C <= O, ColorRGB( 255, 0, 0 ), colorLightGrey ) ), 64, 0, 0, 0, 0 );
    break;
}
_SECTION_END();

movag01 = ema(c,5); 
movag02 = ema(c,14);
movag03 = ema(c,26);

Plot(movag01,"mo5",colorLime,styleLine);
Plot(movag02,"mo14",colorRed,styleLine);
Plot(movag03,"mo26",colorYellow,styleLine);

buy = cross(O, movag01) AND cross(O,movag02) AND cross(O,movag03);
sell = cross(movag01,O) AND cross(movag02,O) AND cross(movag03,O); 


_SECTION_BEGIN("Plot dots on  price and arrows on candle");

// ---------Plot dots on  orice and arrows on candle --------------

BuyPrice = O;
SellPrice = O;

PricesOnInclude = ParamToggle("Plot Trade Prices (dots)","HIDE|SHOW",1); 
ArrowsOnInclude = ParamToggle("Plot Trade Arrows","HIDE|SHOW",1); 

if( PricesOnInclude ) 
{ 
PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone),colorblue,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowUpTriangle,shapeNone),colorbrightGreen,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowSmallCircle,shapeNone),colorbrightGreen,0,BuyPrice,0);
} 
if( ArrowsOnInclude ) 
{ 
PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorGold,0,H,IIf(Sell AND Sell,-30,-15));
PlotShapes(IIf(Sell,shapeHollowDownTriangle,shapeNone),colorOrange,0,H,IIf(Sell AND Sell,-30,-15));
PlotShapes(IIf(Sell,shapeHollowCircle,shapeNone),colorOrange,0,SellPrice,0);
} 
_SECTION_END();

You have mentioned Open above but in your code you are using Cross from this line

Cross() is an impulse not a state, so from the line of code you have written, it actually means that Open should Cross above the 3 different MA on the same bar.

Can you elaborate with a picture ?

Plainly translating it would be more like
Buy = O > movag01 AND O > movag02 AND O > movag03; but this would not make much sense alone.

thanks for revert..will check and confirm