_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("Op %g, Hi %g, Lo %g, Cl %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("TEST");
function ParamOptimize( pname, defaultval, minv, maxv, step )
{
return Optimize( pname,
Param( pname, defaultval, minv, maxv, step ),
minv, maxv, step );
}
C1 = SelectedValue( TimeFrameGetPrice( "C", inDaily, -1 ));
O1 = SelectedValue( TimeFrameGetPrice( "O", inDaily, -1 ));
H1=SelectedValue( TimeFrameGetPrice( "H",inDaily, -1 ));
L1=SelectedValue( TimeFrameGetPrice( "L", inDaily, -1 ));
xxx=C1+((H1-L1)*0.25);
yyy=C1-((H1-L1)*0.25);
BT=xxx+((H1-L1)*0.25);
ST=yyy-((H1-L1)*0.25);
BT1=xxx+((H1-L1)*0.5);
ST1=yyy-((H1-L1)*0.5);
BT2=xxx+((H1-L1)*0.75);
ST2=yyy-((H1-L1)*0.75);
Buy=Cross(C,xxx);Sell=Cross(C,BT) OR Cross(C, yyy);
Short=Cross(yyy,C);Cover=Cross(ST,C) OR Cross(xxx, C);
Plot (yyy,"SELL",32,4);
Plot (xxx,"BUY",27,4);
Plot (BT,"BUY TARGET",40,styleDashed|styleNoLabel);
Plot (ST,"SELL TARGET",40,styleDashed|styleNoLabel);
Plot (BT1,"BUY TARGET",40,styleDashed|styleNoLabel);
Plot (ST1,"SELL TARGET",40,styleDashed|styleNoLabel);
Plot (BT2,"BUY TARGET",40,styleDashed|styleNoLabel);
Plot (ST2,"SELL TARGET",40,styleDashed|styleNoLabel);
BuyPrice = ValueWhen(Buy, Close);
ShortPrice = ValueWhen(Short, Close);
// In the cover and sell you will have to place 2 conditions. 1 for SL and 2nd for target
CoverPrice = ValueWhen(Cross(ST,C), ST); // if target hit
CoverPrice = ValueWhen(Cross(xxx, C), xxx); // if SL hit
// CoverPrice = valuewhen(Cross(ST,C) OR Cross(xxx, C), iif(Cross(ST,C), ST, xxx)); // Single line code
SellPrice = ValueWhen(Cross(C,BT), BT); // if target
SellPrice = ValueWhen(Cross(C, yyy), yyy); // if SL hitPlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,Low,-15);
Filter=Buy OR Cover OR Sell OR Short;
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,Low,-15);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,High,-15);
AddColumn (xxx, "BUY LEVEL", 1.1,colorWhite,colorBlue );
AddColumn (BT, "B TAR1", 1.1, colorWhite,bkcolor =IIf(H>BT, colorGreen,colorDefault));
AddColumn (BT1, "B TAR2", 1.1, colorWhite,bkcolor =IIf(H>BT1, colorGreen,colorDefault));
AddColumn (BT2, "B TAR3", 1.1, colorWhite,bkcolor =IIf(H>BT2, colorGreen,colorDefault));
AddColumn (yyy, "SELL LEVEL", 1.1, colorWhite,colorBlue );
AddColumn (ST, "S TAR1", 1.1, colorWhite,bkcolor =IIf(L<ST, colorRed,colorDefault));
AddColumn (ST1, "S TAR2", 1.1, colorWhite,bkcolor =IIf(L<ST1, colorRed,colorDefault));
AddColumn (ST2, "S TAR3", 1.1, colorWhite,bkcolor =IIf(L<ST2, colorRed,colorDefault));
Title ="\n"+EncodeColor(colorYellow)+" BUY "+WriteVal(xxx,1.2)+EncodeColor(colorRed)+" SELL "+WriteVal(yyy,1.2);
_SECTION_BEGIN("TITLE");
Title = EncodeColor(colorWhite) +"Op-"+WriteVal(Open,1.2)+" "+"Hi-"+WriteVal(High,1.2)+" "+"Lo-"+WriteVal(Low,1.2)+" "+" "+"Cl-"+WriteVal(Close,1.2) +
"\n"+EncodeColor(colorGreen)+" BUY "+WriteVal(xxx,1.2)+EncodeColor(colorYellow)+" T1 "+WriteVal(BT,1.2)+" T2 "+WriteVal(BT1,1.2)+" T3 "+WriteVal(BT2,1.2)+
"\n"+EncodeColor(colorRed)+" SELL "+WriteVal(yyy,1.2)
+EncodeColor(colorYellow)+" T1 "+WriteVal(ST,1.2)+" T2 "+WriteVal(ST1,1.2)+" T3 "+WriteVal(ST2,1.2);
_SECTION_END();