This is a bit of a different study. It takes a specific timeframe (eg. 9:30 to 10:30) and compares the current range of movement to the average range in that timeframe. It is not comparing the average daily range, just the range in that timeframe (for the duration of the chart). It prints this information in a label on the top left:
When the given 'range' has ended, the label will simply show the usual expected range on that timeframe. There is also an option to show 'targets' that would be the usual range +/- the open price. Not sure how useful those are just yet so they are hidden by default. This is intended for daytrading types and probably has little value on stocks and timeframes larger than a 4hr.
The open/close of the range are available via options. So if you normally trade from 2:30am to 4:00am, you can use those values. Default is 9:30am to 10:30am. You could even change to a larger range like 9am to noon.
I haven't seen a study that does something like this before so I'm all ears for ideas the community might have for this one.
When the given 'range' has ended, the label will simply show the usual expected range on that timeframe. There is also an option to show 'targets' that would be the usual range +/- the open price. Not sure how useful those are just yet so they are hidden by default. This is intended for daytrading types and probably has little value on stocks and timeframes larger than a 4hr.
The open/close of the range are available via options. So if you normally trade from 2:30am to 4:00am, you can use those values. Default is 9:30am to 10:30am. You could even change to a larger range like 9am to noon.
I haven't seen a study that does something like this before so I'm all ears for ideas the community might have for this one.
Ruby:
# Created by @tony_futures
# Custom range script comparing average first hour for the length of the chart to current day
declare upper;
declare hide_on_daily;
input RoundLevel = 0;
input openStart = 0930;
input openEnd = 1030;
input alwaysShowCompare = no;
def openActive = SecondsTillTime(openEnd) > 0 and SecondsFromTime(openStart) >= 0;
Def ORActive = secondstilltime(openEnd)>0 AND secondsfromtime(openStart)>=0;
def RTHOpen = if ORActive and !ORActive[1] then open else RTHopen[1];
def ORHigh = if ORActive and !ORActive[1] then high else if ORActive and high > ORhigh[1] then high else ORhigh[1];
def ORlow = if ORActive and !ORActive[1] then low else if ORActive and low < ORlow[1] then low else ORlow[1];
def TodayRange = ORHigh - ORLow;
def endOfopen = !openActive and openActive[1];
def openRange = if endOfopen then TodayRange else Double.NaN;
def openCount = if endOfopen then openCount[1] + 1 else openCount[1];
def openCum = if endOfopen then openCum[1] + openRange else openCum[1];
def openAvg = openCum/openCount;
def OpenPercentage = Round((TodayRange / openAvg) * 100, RoundLevel);
def Today = GetLastDay() == GetDay();
AddLabel ((Today and ORActive) OR AlwaysShowCompare, "OR: " + Round (TodayRange , RoundLevel) + " vs Avg: " + round (openAvg,RoundLevel)+ " | " + round (OpenPercentage,RoundLevel) + "%", (if OpenPercentage <= 40 then Color.LIGHT_GREEN else if OpenPercentage >= 85 then Color.LIGHT_RED else Color.WHITE));
AddLabel(Today and !ORActive, "Expected Range: " + RoundDown(openAvg,RoundLevel), Color.WHITE);
def expHigh = (RTHOpen + openAvg);
def expLow = (RTHOpen - openAvg);
input showPossibleRange = no;
AddLabel(showPossibleRange and Today and !ORActive, "Possible High Range: " + RoundDown(expHigh, RoundLevel), Color.WHITE);
AddLabel(showPossibleRange and Today and !ORActive, "Possible Low Range: " + RoundUp(expLow, RoundLevel), Color.WHITE);
Last edited: