shakib3585
Active member
Hello All,
I have been researching to find the "initial balance" for an entire trading session and determine if the type is "small", "medium," or "wide". I finally gathered a code, which I attached in the code section. The only drawback is that it won't be able to determine the type beyond a regular trading session. If you find a solution to determine the type of "initial balance" beyond the regular trading session, then please feel free to post it here.
Thanks
I have been researching to find the "initial balance" for an entire trading session and determine if the type is "small", "medium," or "wide". I finally gathered a code, which I attached in the code section. The only drawback is that it won't be able to determine the type beyond a regular trading session. If you find a solution to determine the type of "initial balance" beyond the regular trading session, then please feel free to post it here.
Thanks
Code:
def firstBarNumber = if GetDay() <> GetDay()[1] then BarNumber() else firstBarNumber[1];
#First Bar Info
def high1 = if BarNumber() == firstBarNumber then high(period = aggregationPeriod.thirtY_MIN) else high1[1];
def low1 = if BarNumber() == firstBarNumber then low(period = aggregationPeriod.thirTY_MIN) else low1[1];
#Second Bar Info
def high2 = if BarNumber() == firstBarNumber+1 then high(period = aggregationPeriod.thirtY_MIN) else high2[1];
def low2 = if BarNumber() == firstBarNumber+1 then low(period = aggregationPeriod.thirTY_MIN) else low2[1];
def hi = if high1>=high2 then high1 else high2;
def lo = if low1<=low2 then low1 else low2;
def rangebar = hi - lo;
input length = 10;
input averageType = AverageType.Simple;
def ATR1 = MovingAverage(averageType, TrueRange(high(period=aggregationPeriod.DAY)[1], close(period=aggregationPeriod.DAY)[1], low(period=aggregationPeriod.DAY)[1]), length);
def a = 1.2*ATR1;
def b = ATR1/3;
AddLabel(yes, if rangeBar<b then "IB.Range.type : SMALL" else if rangeBar>a then "IB.Range.type: WIDE "else if isNaN(ATR1)==1 then "IB.Range.type : N/A" else "IB.Range.type: MEDIUM " , color.CYAN);
Last edited: