_SECTION_BEGIN("Selected TF Bar High Low Markings");
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() );
tf = Param("Select Time frame (min)",30,1,1440,1);
tfrm=in1Minute*tf;
TimeFrameSet(tfrm);
H1 = Ref(H,-1);
L1 = Ref(L,-1);
TimeFrameRestore();
H1 = TimeFrameExpand(H1, tfrm,expandFirst);
L1 = TimeFrameExpand(L1, tfrm,expandFirst);
Plot(H1,"",colororange,styledots|stylenoline|stylenorescale);
Plot(L1,"",colorbrightgreen,styledots|stylenoline|stylenorescale);
_SECTION_END();
_SECTION_BEGIN("Selected TF Bar High Low Markings");
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() );
tf = Param("Select Time frame (min)",30,1,1440,1);
tfrm=in1Minute*tf;
TimeFrameSet(tfrm);
H1 = Ref(H,-1);
L1 = Ref(L,-1);
TimeFrameRestore();
H1 = TimeFrameExpand(H1, tfrm,expandFirst);
L1 = TimeFrameExpand(L1, tfrm,expandFirst);
Plot(H1,"",colororange,styledots|stylenoline|stylenorescale);
Plot(L1,"",colorbrightgreen,styledots|stylenoline|stylenorescale);
_SECTION_END();
zTickSize=0.05;
//zTickSize=IIf(StrLeft(Name(),StrLen(Name())-8)=="CRUDEOIL",1,zTickSize);
function zRoundUp(zValue) {return ceil(zValue/zTickSize)*zTickSize;}
function zRoundDown(zValue) {return floor(zValue/zTickSize)*zTickSize;}
zTickSize=0.05;
//zTickSize=IIf(StrLeft(Name(),StrLen(Name())-8)=="CRUDEOIL",1,zTickSize);
function zRoundUp(zValue) {return ceil(zValue/zTickSize)*zTickSize;}
function zRoundDown(zValue) {return floor(zValue/zTickSize)*zTickSize;}
zTickSize=0.05;
function zRoundUp(zValue) {return ceil(zValue/zTickSize)*zTickSize;}
function zRoundDown(zValue) {return floor(zValue/zTickSize)*zTickSize;}
pricex = 9744.351;
t2 = zRoundDown(pricex) ;
_N( Title = ( "" + t2 ) ) ;
paise = 0.05;
a1 = 9744.351;
tRoundUp = ceil((Floor(a1) + int( (a1 % 1) / paise ) * paise + paise) * 100 ) / 100;
tRoundDown = ceil((Floor(a1) + int( (a1 % 1) / paise ) * paise ) * 100 ) / 100;
zTickSize=0.05;
function zRoundUp(zValue) {return ceil(zValue/zTickSize)*zTickSize;}
function zRoundDown(zValue) {return floor(zValue/zTickSize)*zTickSize;}
pricex = 9744.351;
t2 = zRoundDown(pricex) ;
_N( Title = ( "" + t2 ) ) ;
paise = 0.05;
a1 = 9744.351;
tRoundUp = ceil((Floor(a1) + int( (a1 % 1) / paise ) * paise + paise) * 100 ) / 100;
tRoundDown = ceil((Floor(a1) + int( (a1 % 1) / paise ) * paise ) * 100 ) / 100;
paise = 0.05;
a1 = 9744.351;
tRoundUp = ceil((Floor(a1) + int( (a1 % 1) / paise ) * paise + paise) * 100 ) / 100;
tRoundDown = ceil((Floor(a1) + int( (a1 % 1) / paise ) * paise ) * 100 ) / 100;
paise = 0.05;
a1 = 9883.41; // or 9883.4
tRoundUp = ceil((Floor(a1) + int( (a1 % 1) / paise ) * paise + paise) * 100 ) / 100;
tRoundDown = ceil((Floor(a1) + int( (a1 % 1) / paise ) * paise ) * 100 ) / 100;
GfxTextOut( "" + tRoundUp, 1000,150);
GfxTextOut( "" + tRoundDown, 1000,170);
Price = 1.3499;
A1 = frac(Price) * 100;
A2 = (Round(A1 / 5) * 5) / 100 + int(Price);
Price = 9883.44;
Set_tick = 0.05 * 100;
Get_frac = (Round((frac(Price) * 100) / Set_tick) * Set_tick)/100;
round_Up = IIf(Get_frac >= frac(Price), Get_frac, Get_frac + (Set_tick/100)) + int(Price);
round_Down = IIf(Get_frac >= frac(Price), Get_frac - (Set_tick/100), Get_frac) + int(Price);
printf( "Price: %g ", Get_frac );
printf( "\n round_Up: %g ", round_Up );
printf( "\n round_Down: %g ", round_Down );