//////////////chart & back ground color////////////////////
SetChartBkGradientFill(colorBlack,colorBlack,colorBlack);
//Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
Plot( Close, "C", colorWhite, styleCandle);
separator = Day() != Ref( Day(), -1 );
Plot( separator, "", colorPink, styleHistogram | styleOwnScale | styleNoLabel | styleNoRescale, 0, 1, 0, -2, 5 );
starttime = 091500;
endtime = 151500;
separator = Day() != Ref( Day(), -1 );
insession = timenum() >= starttime && timenum() <= 151000;
endsession = timenum() >= endtime;
endsession = ( endsession - Ref( endsession, -1 ) ) == 1 ;//OR Ref( separator, 1 );
startsession = timenum() >= starttime;
startsession = ( startsession - Ref( startsession, -1 ) ) == 1;
timelmits = insession && !endsession;
Plot( endsession, "", colorWhite, styleHistogram | styleOwnScale | styleNoLabel | styleNoRescale, 0, 1, 0, -2, 1 );
Plot( startsession, "", colorViolet, styleHistogram | styleOwnScale | styleNoLabel | styleNoRescale, 0, 1, 0, -2, 1 );
GraphXSpace=85;
//////////////////////
ema1 = EMA( C, 5 );
ema2 = EMA( C, 10 );
Plot(ema1,"",colorBlue,styleThick);
Plot(ema2,"",colorRed,styleThick);
Buy = Cross(ema1,ema2 );
Short = Cross( ema2, ema1 );
Equity(1);
Sell = Cover = 0; // 0 or False means exit only by ApplyStop
ApplyStop( stopTypeLoss, stopModePercent, 5 ); // 5% max loss from short/buy price
ApplyStop( stopTypeProfit, stopModePercent, 5 ); // 5% profit target from short/buy price
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
PlotShapes( IIf( Buy , shapeUpArrow,0) , colorGreen ,layer = 0, yposition = HaLow, offset = -8);
PlotShapes( IIf( SHORT , shapeDownArrow,0) , colorRed ,layer = 0, yposition = HaHigh, offset = -8);
//PlotShapes( IIf( SELL , shapeHollowDownArrow,0) , colorRed ,layer = 0, yposition = HaHigh, offset = -8);
//PlotShapes( IIf( COVER, shapeHollowUpArrow,0) , colorGreen ,layer = 0, yposition = HaLow, offset = -8);
The above code produces the chat as below:
My problem are as below:
- Why I am not getting the Buy and Short signals?
- How to plot the exit signals by the applystop codes?
please help me to correct my coding errors to get the desired output.