_SECTION_BEGIN("PreDHLCDayHLRN");
PreDHLC = ParamToggle("Show PreDHLC","Show|Hide",1);
if (PreDHLC == 1) {
LV_Datenum=LastVisibleValue(DateNum()); //Calculate Date Number of Last Visible Bar
//Hor0 = Param("Hor0",900,0,1368,1);
//Ver0 = Param("Ver0",30,0,768,1);
CurrentDayBars=BarsSince(DateNum()<LV_Datenum); //Calculate number of bars for last visible day
PDay_Datenum=Ref(DateNum(),-CurrentDayBars); //Calculate Date number of previous day
P2Day_Datenum=BarsSince(DateNum()<LastValue(PDay_Datenum));//Calculate Date number of day before previous day
z=P2Day_Datenum-CurrentDayBars;
// Calculation of Last Visible Day High
// Day High = Higher of Highest Open or Highest Close during the day
Hi0=IIf(HHV(C,CurrentDayBars)> HHV(O,CurrentDayBars),HHV(C,CurrentDayBars),HHV(O,CurrentDayBars));
//Hi0bar=HHVBars(Hi0,CurrentDayBars);
x20=BarCount-LastValue(CurrentDayBars)-5;
x21=BarCount-1;
y20=LastVisibleValue(Hi0);
y21=y20;
Line2 = LineArray( x20, y20, x21, y21,1 );
Plot( Line2, "day high line", TDClrs,styleThick|styleNoTitle|styleNoLabel,0,0,5);
PlotText("DH " + y21, LastValue(BarIndex())+6, y21, TDClrs);
//Calculation of Last Visible Day Day Low
//Li0=LLV(L,CurrentDayBars);
//Day Low = Lower of Lowest Open or Lowest Close during the day
Li0=IIf(LLV(C,CurrentDayBars)< LLV(O,CurrentDayBars),LLV(C,CurrentDayBars),LLV(O,CurrentDayBars));
Li0bar=LLVBars(Li0,CurrentDayBars);
x30=BarCount-LastValue(CurrentDayBars)-4;
//x31=BarCount-1;
y30=LastVisibleValue(Li0);
y31=y30;
Line3 = LineArray( x30, y30, x21, y31, 1 );
Plot( Line3, "day low line", TDClrs,styleThick|styleNoTitle|styleNoLabel,0,0,5 );
PlotText("DL " + y31, LastValue(BarIndex())+6, y31, TDClrs);
//Calculation of Day Open
//Day Open = Open of Fis
dao=Ref(Open,-CurrentDayBars+1);
x101=BarCount-1-LastValue(CurrentDayBars-1);
y101=LastValue(dao);
y111=y101;
Line1=LineArray( x101, y101, x21, y111, 1 );
Plot( Line1, "DO Line", ParamColor("Open line", colorWhite),styleThick|styleNoTitle|styleNoLabel ,0,0,0);
PlotText("DO " + y101, LastValue(BarIndex())-20, y111, TDCLRs);
//Calculation of Previous Day High
//Hi=Ref(HHV(H,z),-CurrentDayBars);
Hi=IIf(Ref(HHV(C,z),-CurrentDayBars) > Ref(HHV(O,z),-CurrentDayBars), Ref(HHV(C,z),-CurrentDayBars), Ref(HHV(O,z),-CurrentDayBars));
Hibar=Ref(HHVBars(Hi,z),-CurrentDayBars)+CurrentDayBars;
x0=BarCount-1-LastValue(Hibar)-4;
//x1=BarCount-1;
y0=LastValue(Hi);
y1=y0;
Line = LineArray( x0, y0, x21, y1, 1 );
Plot( Line, "high line", ParamColor("PDH", PDHClr),styleThick|styleNoTitle|styleNoLabel,0,0,5 );
PlotText("PDH " + y0, LastValue(BarIndex())+4, y1, PDHClr);
//Calculation of Previous Day LOW
//Lo=Ref(LLV(L,z),-CurrentDayBars);
Lo=IIf(Ref(LLV(C,z),-CurrentDayBars) < Ref(LLV(O,z),-CurrentDayBars), Ref(LLV(C,z),-CurrentDayBars), Ref(LLV(O,z),-CurrentDayBars));
Lobar=Ref(LLVBars(Lo,z),-CurrentDayBars)+CurrentDayBars;
x00=BarCount-1-LastValue(Lobar)-5;
x01=BarCount-1;
//x01=Status("lastvisiblebar")+10;
y00=LastValue(Lo);
y01=y00;
Line11=LineArray(x00,y00,x01,y01,1);
Plot(Line11,"Low Line", PDLCLr,styleThick|styleNoTitle|styleNoLabel,0,0,5);
//Plot(Line11,"Low Line",ParamColor("PDL", PDLCLr),styleThick|styleNoTitle|styleNoLabel,0,0,5);
PlotText("PDL " + y01, LastValue(BarIndex())+4, y01, PDLClr);
//Calculation of Previous Day Close
pc=Ref(Close,-CurrentDayBars);
x10=BarCount-1-LastValue(CurrentDayBars)-5;
x11=BarCount-1;
y10=LastValue(pc);
y11=y10;
Line1=LineArray( x10, y10, x11, y11, 1 );
Plot( Line1, "Close line", ParamColor("Close line", colorWhite),styleThick|styleNoTitle|styleNoLabel ,0,0,5);
PlotText("PDC " + y11, LastValue(BarIndex())-26, y11, PDCClr);
}
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();