_SECTION_BEGIN("HOURLY CHART");
RequestTimedRefresh( 1 );
GraphXSpace=5;
TFMinLong = Param("Long Timeframe (Minutes)", 60, 1, 1500, 1);
BYSL=Param("BYSL",2,0.1,10,0.1);
TFSec = in1Minute * TFMinLong;
TimeFrameSet(TFSec);
TFOpen = Open;
TFHigh = High;
TFLow = Low;
TFClose = Close;
TFBarIndex = BarIndex();
TFLastBarIndex = LastValue(BarIndex());
TimeFrameRestore();
TFOpen = TimeFrameExpand(TFOpen, TFSec, expandFirst);
TFHigh = TimeFrameExpand(TFHigh, TFSec, expandFirst);
TFLow = TimeFrameExpand(TFLow, TFSec, expandFirst);
TFClose = TimeFrameExpand(TFClose, TFSec, expandFirst);
TFBarIndex = TimeFrameExpand(TFBarIndex, TFSec, expandLast + 1);
TFLastBarIndex = TimeFrameExpand(TFLastBarIndex, TFSec, expandLast + 1);
J = TFClose;
OP1 = Ref(TFOpen+BYSL,-1);
OP2 = Ref(TFOpen-BYSL,-1);
Plot(Op1, "",colorGreen,styleStaircase|styleNoLabel );
Plot(Op2, "",colorRed,styleStaircase|styleNoLabel);
Buy_Valid = TFClose>OP1;
Sell_Valid = OP2>TFClose;
Candlecol=IIf(BarsSince(Buy_Valid)<BarsSince(Sell_Valid) AND BarsSince(Buy_Valid)!=0,5,
IIf(BarsSince(Buy_Valid)>BarsSince(Sell_Valid) AND BarsSince(Sell_Valid)!=0,4,1));
cc1=IIf(Buy_Valid,colorLime,IIf(Sell_Valid,colorRed,Candlecol));
SetBarFillColor(Cc1);
cc1=IIf(Buy_Valid,colorLime,IIf(Sell_Valid,colorRed,Candlecol));
PlotOHLC( TFOpen, TFHigh, TFLow, TFClose, Name(), Cc1, styleCandle );
//PlotOHLC( TFOpen, TFOpen, TFClose, TFClose, Name(), Cc1, styleCandle );
_SECTION_END();
_SECTION_BEGIN("PreDHL TdayHL");
x=LastVisibleValue(DateNum());
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
Cond=BarsSince(DateNum()<x);
y=Ref(DateNum(),-Cond);
Cond1=BarsSince(DateNum()<LastValue(y));
z=Cond1-Cond;
Hi0=HHV(H,Cond);
Hi0bar=HHVBars(H,Cond);
x20=BarCount-LastValue(Cond);
x21=BarCount-1;
y20=LastVisibleValue(Hi0);
y21=y20;
Line2 = LineArray( x20, y20, x21, y21, 1 );
Plot( Line2, "day high line", colorOrange,styleThick|styleNoTitle|styleNoLabel);
PlotText(" DH " , LastValue(BarIndex())-(numbars/Hts), Y20, colorOrange);
Li0=LLV(L,Cond);
Li0bar=LLVBars(L,Cond);
x30=BarCount-LastValue(Cond);
x31=BarCount-1;
y30=LastVisibleValue(Li0);
y31=y30;
Line3 = LineArray( x30, y30, x31, y31, 1 );
Plot( Line3, "day low line", colorTurquoise,styleThick|styleNoTitle|styleNoLabel );
PlotText(" DL " , LastValue(BarIndex())-(numbars/Hts), Y30, colorTurquoise);
Hi=Ref(HHV(H,z),-Cond);
Hibar=Ref(HHVBars(H,z),-Cond)+Cond;
x0=BarCount-1-LastValue(Hibar);
x1=BarCount-1;
y0=LastValue(Hi);
y1=y0;
Line = LineArray( x0, y0, x1, y1, 1 );
Plot( Line, "high line", colorGreen,styleThick|styleNoTitle|styleNoLabel );
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), Y0, colorGreen);
Lo=Ref(LLV(L,z),-Cond);
Lobar=Ref(LLVBars(L,z),-Cond)+Cond;
x00=BarCount-1-LastValue(Lobar);
x01=BarCount-1;
y00=LastValue(Lo);
y01=y00;
Line11=LineArray(x00,y00,x01,y01,1);
Plot(Line11,"Low Line",colorBlue,styleThick|styleNoTitle|styleNoLabel);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), Y00, colorBlue);
_SECTION_END();
_SECTION_BEGIN("OPCL line");
FB = DateNum() != Ref(DateNum(),-1);
FB1 = DateNum() != Ref(DateNum(),-1);
FB2 = DateNum() != Ref(DateNum(),-1);
FB3 = DateNum() != Ref(DateNum(),-1);
Bars = 1 + BarsSince(FB);
Op = ValueWhen(FB,O);
Hi = ValueWhen(FB2,H);
Lo = ValueWhen(FB3,L);
Cl = ValueWhen(FB1,C);
Plot(Op, "",colorRed,styleDashed|styleNoLabel);
//Plot(Hi, "",colorYellow,styleDashed|styleNoLabel);
//Plot(Lo, "",colorPink,styleDashed|styleNoLabel);
Plot(Cl, "",colorBrightGreen,styleDashed|styleNoLabel);
FB = DateNum() != Ref(DateNum(),1);
Opc = ValueWhen(FB,C);
Plot(Opc, "",colorWhite,styleLine|styleNoLabel);
_SECTION_END();