_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 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("Range");
SetChartOptions(2,chartWrapTitle);
TimeFrameSet(inDaily);
ATRdaily = ATR(7) ;
TimeFrameRestore() ;
ATRdaily = TimeFrameExpand(ATRdaily,inDaily);
TimeFrameSet(inDaily);
noise = Min(H-O,O-L);
expansion = Max(H-O,O-L);
range = H-L;
Avg1 = Param("Avg Period 1", 10, 1, 1000) ;
Avg2 = Param("Avg Period 1", 20, 1, 1000) ;
Clrnb = Clrnoise = ParamColor("Color Noise", colorLightOrange) ;
Layer = Param("Layer", -1, -5, 5) ;
showfill = ParamToggle("Show Fill", "No|Yes", 1) ;
showext = ParamToggle("Show Extension", "No|Yes", 1) ;
extend = Param("Extend By", 5, 0, 200, 1) ;
xst = BarCount - (extend) +1 ;
xed = BarCount -1 ;
showtext = ParamToggle("Show Text", "No|Yes", 1) ;
txtpos = BarCount + extend-5 ;
fil = Param("Text Filter", 1, 1, 10000, 1) ;
showoncrb = ParamToggle("Show On CRB", "No|Yes", 0) ;
Refo = ParamField("CRB Open", 7+0) ;
Refh = ParamField("CRB High", 7+1) ;
Refl = ParamField("CRB Low", 7+2) ;
Refc = ParamField("CRB Close", 7+3) ;
Refbi = ParamField("CRB BI", 7+4) ;
Refcrbbars = ParamField("CRB Bars", 7+5) ;
Refnbars = ParamField("TF Bars", 7+6) ;
Refdt = ParamField("CRB DT", 7+7) ;
xnoise = MA(noise,Avg1);
xexpansion = MA(expansion,Avg1);
xdrange = MA(range, Avg1);
ynoise = MA(noise,Avg2);
yexpansion = MA(expansion,Avg2);
ydrange = MA(range,Avg2);
anoise = (xnoise + ynoise) / 2;
aexpansion = (xexpansion + yexpansion) / 2;
adrange = (xdrange + ydrange) / 2;
TimeFrameRestore();
anoise = TimeFrameExpand(anoise,inDaily);
aexpansion = TimeFrameExpand(aexpansion,inDaily);
adrange = TimeFrameExpand(adrange,inDaily);
ro = O ;
rh = H ;
rl = L ;
rc = C ;
dt = DateTime() ;
if (showoncrb)
{
ro = Refo ;
rh = Refh ;
rl = Refl ;
rc = Refc ;
dt = Refdt ;
}
a=Day()!=Ref(Day(),-1);
Lod = LowestSince(a,L);
Hod = HighestSince(a,H);
dopen = TimeFrameGetPrice("O",inDaily);
Refadnh = adnh = dopen+anoise ;
Refadnl = adnl = dopen-anoise ;
Refadeh = adeh = dopen+aexpansion ;
Refadel = adel = dopen-aexpansion ;
Refadrh = adrh = Lod+adrange ;
Refadrl = adrl = Hod-adrange ;
if (showoncrb)
{
diffbars = Refnbars -Refcrbbars -1 ;
Crbst = BarCount - LastValue(Refcrbbars) -1;
// convert to crb
Refadnh = Ref(adnh, -diffbars) ;
Refadnl = Ref(adnl, -diffbars) ;
Refadeh = Ref(adeh, -diffbars) ;
Refadel = Ref(adel, -diffbars) ;
Refadrh = Ref(adrh, -diffbars) ;
Refadrl = Ref(adrl, -diffbars) ;
k = 0 ;
for ( i = Crbst ; i < BarCount ; i++)
{
Refbar = Refbi;
Refadnh = adnh[Refbar] ;
Refadnl = adnl[Refbar] ;
Refadeh = adeh[Refbar] ;
Refadel = adel[Refbar] ;
Refadrh = adrh[Refbar] ;
Refadrl = adrl[Refbar] ;
k++;
}
}
Plot(Refadnh,"",colorBlack, styleNoRescale);
Plot(Refadnl,"",colorBlack, styleNoRescale);
doblend = True ;
Clrblend = colorWhite ;
if (doblend)
{
Clrnb = ColorBlend(Clrnoise, Clrblend) ;
}
if (showfill)
PlotOHLC(Refadnh, Refadnh, Refadnl, Refadnl, "", Clrnb,styleCloud |styleNoRescale,0,0,0, Layer) ;
showtrigger = ParamToggle("Show Trigger", "No|Yes", 0) ;
showsltrigger = ParamToggle("Show SL Trigger", "No|Yes", 0) ;
Buy = Cross(rC,Refadnh);
Short = Cross(Refadnl,rC);
Cover = Cross(rC,Refadnl);
Sell = Cross(Refadnh,rC);
//AlertIf(Buy,"","Buy"+Name());
//AlertIf(Sell,"","Sell"+Name());
if(showext)
{
Hdlast = SelectedValue(Refadnh) ;
Ldlast = SelectedValue(Refadnl) ;
Hplot = LineArray(xst, Hdlast, xed, Hdlast) ;
Plot(Hplot, "", Clrnoise, styleLine|styleDots|styleNoLabel|styleNoRescale , 0,0,extend) ;
if (showtext)
PlotText(NumToStr(HdLast, 8.1), txtpos, HdLast+fil, colorBlack) ;
LPlot = LineArray(xst, Ldlast, xed, Ldlast) ;
Plot(LPlot, "", Clrnoise, styleLine|styleDots|styleNoLabel|styleNoRescale , 0,0,extend) ;
if (showtext)
PlotText(NumToStr(LdLast, 8.1), txtpos, LdLast+fil, colorBlack) ;
PlotOHLC(HPlot, HPlot, LPlot, LPlot, "", Clrnb, styleCloud|styleNoLabel|styleNoTitle|styleNoRescale, 0,0,extend,Layer ) ;
}