// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
_SECTION_END();

SetChartOptions(0, chartShowDates | chartWrapTitle);
GfxTextOut("5 Candle Calculation", 43, 60);

E5 = EMA(Close, 5);
E34 = EMA(Close, 34);

BTrig = Cross(E5, E34);
STrig = Cross(E34, E5);

BT = Flip(BTrig, STrig);
ST = Flip(STrig, BTrig);

B_High = ValueWhen(Btrig,(H + (H*.001)), 1);
S_Low = ValueWhen(STrig, (L - (L*.001)), 1);

BuyPrice=ValueWhen(Btrig, (H + .001), 1);
SellPrice=ValueWhen(STrig, (L -.001), 1);

Buytarget = (BuyPrice*2)-Ref(L, -5);
Buysl=Ref(L,-5);

Selltarget= (SellPrice*2)-(Ref(H, -5));
Sellsl=Ref(H, -5);

Buy = BT AND H > B_High;
Sell= Buytarget OR Buysl;

Filter = Buy OR Sell;

Short = ST AND L < S_Low;
Cover=Selltarget OR Sellsl;

//if(Buy=1)
//{
GfxTextOut("Buy@-- " + ( WriteVal(B_High) ), 43, 100 );
GfxTextOut("Target-- " + ( WriteVal(Buytarget) ), 40, 120 );
GfxTextOut("Sl--" + ( WriteVal(Buysl) ), 40, 140 );
//}
//if(Sell=1)
//{
GfxTextOut("Sell@-- " + ( WriteVal(S_Low ) ), 43, 180 );
GfxTextOut("Target-- " + ( WriteVal(Selltarget) ), 40, 200 );
GfxTextOut("Sl--" + ( WriteVal(Sellsl) ), 40, 220 );
//}

Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

_N(Title = StrFormat("{{NAME}} ({{INTERVAL}}), {{DATE}} : {{OHLCX}}, Vol=%1.0f\n{{VALUES}}", V));
COL1=IIf(EMA(Close,5)>EMA(Close,34) AND Low > EMA(Close,34),colorBlue,IIf(EMA(Close,5)<EMA(Close ,34) AND High<EMA(Close,34),colorRed,colorBlack));
Plot( C, "Close", COL1, styleNoTitle | ParamStyle("Style") | styleCandle );

PlotShapes(IIf(Buy==1, shapeUpArrow , shapeNone), colorGreen, 0,Low, Offset=-20);
PlotShapes(IIf(Sell==1, shapeStar, shapeNone), colorRed, 0,High, Offset=30);
PlotShapes(IIf(Short==1, shapeDownArrow, shapeNone), colorRed, 0,High, Offset=-20);
PlotShapes(IIf(Cover==1, shapeStar, shapeNone), colorGreen, 0,Low, Offset=-30);