_SECTION_BEGIN("Open Range Breakout");
xf = ParamList("TF","5M|10M|15M|30M|H",2);
ShowORB = ParamToggle("Show Opening Range", "Show|Hide", 1);
if(ShowORB == 1)
{
SetBarsRequired(-2,-2); //Turn Quick AFL Off
spacer = IIf(xf == "5M",500,IIf(xf == "10M",1000,IIf(xf == "15M",1500,IIf(xf == "30M",3000,IIf(xf == "H",6000,1)))));
tf = IIf(xf == "5M",300,IIf(xf == "10M",600,IIf(xf == "15M",900,IIf(xf == "30M",1800,IIf(xf == "H",6000,1)))));
newday = Day() != Ref(Day(),-1); //check if new day or
starttime = ValueWhen(newday,TimeNum());
IBendtime = starttime+spacer;
minh = ValueWhen(newday,TimeFrameGetPrice("H",tf));
minl = ValueWhen(newday,TimeFrameGetPrice("L",tf));
printf("%g",IBendtime);
ORBH = IIf(TimeNum() < IBendtime, Null ,minh);
ORBL = IIf(TimeNum() < IBendtime, Null, minl);
Rangehi = LastValue(ORBH);
Rangelo = LastValue(ORBL);
Plot(ORBH,"ORBH",ParamColor("ORH",colorYellow),styleNoTitle);
Plot(ORBL,"ORBL",ParamColor("ORL",colorYellow),styleNoTitle);
PlotOHLC(ORBL,ORBH,ORBL,ORBH,"ORB",ParamColor("OR",colorGrey40),styleCloud|styleNoLabel|styleNoTitle,0,0,0,-1);
Filter = Param("Filter",5,0,100,0.01,0);
UT = Ref(C,-1)> Rangehi+Filter;
DT = Rangelo-Filter > Ref(C,-1);
Hor=Param("Horizontal Position",500,1,1200,1);
Ver=Param("Vertical Position",1,1,830,1);
FS=Param("Font Size Trend",34,11,100,1);
//T= ParamList("Trend", "Select Trend|Sideways|Short Only|Long Only");
GfxSetBkMode( 1 );
GfxSelectFont( "Arial", FS, 700, italic = False, underline = False, True );
GfxSetTextColor(ParamColor("ColorTrend",colorWhite) );
GfxSetOverlayMode( mode = 1 );
IIf(UT,GfxTextOut("minor Up Trend "+UT , Hor,Ver ),IIf(DT,GfxTextOut( "minor Down Trend " + DT , Hor,Ver+20 ),GfxTextOut( "Sideways", Hor,Ver+40 )) );
}
_SECTION_END();