ORB custom column show calculations only for today


Category:
0
0

Hi Pete,

This custom column script gives the ORB pct but it doesn’t calculate it just for today. It will go back to the previous day’s last 30 minutes of options volume if today’s initial 30 minutes doesn’t have any. Is it possible to tweak it so that it only shows for today?

 

Thank you!

 

def orStartTime = 0930;
def orEndTime = 1000;
def openingTime = 0930;
def closingTime = 1600;
def targetPctOrMultiple = 5.0;

def na = double.nan;

def isOr = secondstilltime(orEndTime) > 0
and secondsfromtime(orStartTime) >= 0;
def isRegHrs = secondsFromTime(openingTime) >= 0
and secondsTillTime(closingTime) > 0;

# opening range levels logic
rec orhi =
if orhi[1] == 0
or isOr[1] == no
and isOr == yes
then high
else if isOr
and high > orhi[1]
then high
else orhi[1];

rec orlo =
if orlo[1] == 0
or isOr[1] == no
and isOr == yes
then low
else if isOr
and low < orlo[1]
then low
else orlo[1];

# plots
def orh = if isOr then na else orhi;
def orl = if isOr then na else orlo;

def ood = open(period = AggregationPeriod.DAY);

def targetMove = orl * (targetPctOrMultiple / 100);

def orlt = orl – targetMove;
def loss = (((close – orl) / orl)) * 100;

plot scan = if isOr then 0 else loss;
scan.assignValueColor(if close <= orlt then color.green else color.gray);

Marked as spam
Posted by (Questions: 20, Answers: 27)
Asked on January 27, 2020 1:35 pm
139 views
0
Private answer

I find nothing in this code that will substitute the previous day's last thirty minutes when current day's first thirty minutes is not available. The code will not display any of today's values until the current day's Opening Range period has completed. If you find the code reporting data from the previous day because there is no data available for today, you cannot force it to display data that simply does not exist.

Marked as spam
Posted by (Questions: 37, Answers: 4117)
Answered on January 27, 2020 3:29 pm