Orb difference

Drmoh1800

Member
VIP
I found lot of orb indicators,
I am just looking to measure differences between orb high and low for 30 m and add a label above this candle for each day .
Is this possible? Can any one help ? My coding skill is very limited thanks

# ORB for TOS Mobile App

# Mobius

# V01.08.2018



def o = open;

def h = high;

def l = low;

def c = close;

def OpeningBell = getTime()[1] < RegularTradingStart(getYYYYMMDD()) and

getTime() > RegularTradingStart(getYYYYMMDD());

def RTH = getTime() >= RegularTradingStart(getYYYYMMDD()) and

getTime() <= RegularTradingEnd(getYYYYMMDD());

def ORActive = getTime() >= OpeningBell and

getTime() <= RegularTradingStart(getYYYYMMDD()) + 1800000;

def ORH = if OpeningBell

then h

else if ORActive and

h > ORH[1]

then h

else ORH[1];

def ORL = if OpeningBell

then l

else if ORActive and

l < ORL[1]

then l

else ORL[1];

plot ORhigh = if !ORActive and RTH

then ORH

else Double.NaN;

ORhigh.SetStyle(Curve.LONG_DASH);

ORhigh.SetLineWeight(3);

ORhigh.SetDefaultColor(Color.GREEN);

plot ORlow = if !ORActive and RTH

then ORL

else Double.NaN;

ORlow.SetStyle(Curve.LONG_DASH);

ORlow.SetLineWeight(3);

ORlow.SetDefaultColor(Color.RED);

def ORmeanActive = getTime() >= OpeningBell and

getTime() <= RegularTradingStart(getYYYYMMDD()) + 300000;

def ORmeanH = if OpeningBell

then h

else if ORmeanActive and h > ORmeanH[1]

then h

else ORmeanH[1];

def ORmeanL = if OpeningBell

then l

else if ORmeanActive and l < ORmeanL[1]

then l

else ORmeanL[1];

plot ORmean = if !ORmeanActive and RTH

then Round(((ORmeanH + ORmeanL) / 2) / TickSize(), 0) * TickSize()

else Double.NaN;

ORmean.SetStyle(Curve.LONG_DASH);

ORmean.SetLineWeight(3);

ORmean.SetDefaultColor(Color.YELLOW);
def diff = ORmeanH - ORmeanL ;

AddLabel(yes,
text = "orb diff: " + diff,
color = Color.WHITE
);


# End Code ORB for Mobile App
 
Last edited:
I found lot of orb indicators,
I am just looking to measure differences between orb high and low for 30 m and add a label above this candle for each day .
Is this possible? Can any one help ? My coding skill is very limited thanks

# ORB for TOS Mobile App

# Mobius

# V01.08.2018



def o = open;

def h = high;

def l = low;

def c = close;

def OpeningBell = getTime()[1] < RegularTradingStart(getYYYYMMDD()) and

getTime() > RegularTradingStart(getYYYYMMDD());

def RTH = getTime() >= RegularTradingStart(getYYYYMMDD()) and

getTime() <= RegularTradingEnd(getYYYYMMDD());

def ORActive = getTime() >= OpeningBell and

getTime() <= RegularTradingStart(getYYYYMMDD()) + 1800000;

def ORH = if OpeningBell

then h

else if ORActive and

h > ORH[1]

then h

else ORH[1];

def ORL = if OpeningBell

then l

else if ORActive and

l < ORL[1]

then l

else ORL[1];

plot ORhigh = if !ORActive and RTH

then ORH

else Double.NaN;

ORhigh.SetStyle(Curve.LONG_DASH);

ORhigh.SetLineWeight(3);

ORhigh.SetDefaultColor(Color.GREEN);

plot ORlow = if !ORActive and RTH

then ORL

else Double.NaN;

ORlow.SetStyle(Curve.LONG_DASH);

ORlow.SetLineWeight(3);

ORlow.SetDefaultColor(Color.RED);

def ORmeanActive = getTime() >= OpeningBell and

getTime() <= RegularTradingStart(getYYYYMMDD()) + 300000;

def ORmeanH = if OpeningBell

then h

else if ORmeanActive and h > ORmeanH[1]

then h

else ORmeanH[1];

def ORmeanL = if OpeningBell

then l

else if ORmeanActive and l < ORmeanL[1]

then l

else ORmeanL[1];

plot ORmean = if !ORmeanActive and RTH

then Round(((ORmeanH + ORmeanL) / 2) / TickSize(), 0) * TickSize()

else Double.NaN;

ORmean.SetStyle(Curve.LONG_DASH);

ORmean.SetLineWeight(3);

ORmean.SetDefaultColor(Color.YELLOW);
def diff = ORmeanH - ORmeanL ;

AddLabel(yes,
text = "orb diff: " + diff,
color = Color.WHITE
);


# End Code ORB for Mobile App

this draws a bubble above the ORB high line, that shows the difference between the high line and low line.

it was hard coded to 30 min ORB.
i changed it to allow, inputing minutes for,
..ORB time(30)
..ORB mean time(5) (yellow line)

if the minutes are not a multiple of the chart minutes, then a cyan label appears.

Code:
# orb_label

#https://usethinkscript.com/threads/orb-difference.16512/
#Orb difference

# ORB for TOS Mobile App
# Mobius
# V01.08.2018

input orb_minutes = 30;
def orb_ms = (orb_minutes * 60 * 1000);

def chart_agg = GetAggregationPeriod();
def chart_min = chart_agg/60000;

def o = open;
def h = high;
def l = low;
def c = close;
def OpeningBell = getTime()[1] < RegularTradingStart(getYYYYMMDD()) and getTime() > RegularTradingStart(getYYYYMMDD());
def RTH = getTime() >= RegularTradingStart(getYYYYMMDD()) and getTime() <= RegularTradingEnd(getYYYYMMDD());
# orig , 30 min
#def ORActive = getTime() >= OpeningBell and getTime() <= RegularTradingStart(getYYYYMMDD()) + 1800000;
# add a var
def ORActive = getTime() >= OpeningBell and getTime() <= RegularTradingStart(getYYYYMMDD()) + orb_ms;

def ORH = if OpeningBell then h
 else if ORActive and h > ORH[1] then h
 else ORH[1];

def ORL = if OpeningBell then l
 else if ORActive and l < ORL[1] then l
 else ORL[1];

plot ORhigh = if !ORActive and RTH then ORH else Double.NaN;
ORhigh.SetStyle(Curve.LONG_DASH);
ORhigh.SetLineWeight(3);
ORhigh.SetDefaultColor(Color.GREEN);

plot ORlow = if !ORActive and RTH then ORL else Double.NaN;
ORlow.SetStyle(Curve.LONG_DASH);
ORlow.SetLineWeight(3);
ORlow.SetDefaultColor(Color.RED);


input orb_mean_minutes = 5;
def mean_ms =  orb_mean_minutes * 60* 1000;
#def ORmeanActive = getTime() >= OpeningBell and getTime() <= RegularTradingStart(getYYYYMMDD()) + 300000;
def ORmeanActive = getTime() >= OpeningBell and getTime() <= RegularTradingStart(getYYYYMMDD()) + mean_ms;

def ORmeanH = if OpeningBell then h
 else if ORmeanActive and h > ORmeanH[1] then h
 else ORmeanH[1];

def ORmeanL = if OpeningBell then l
 else if ORmeanActive and l < ORmeanL[1] then l
 else ORmeanL[1];

plot ORmean = if !ORmeanActive and RTH then Round(((ORmeanH + ORmeanL) / 2) / TickSize(), 0) * TickSize() else Double.NaN;
ORmean.SetStyle(Curve.LONG_DASH);
ORmean.SetLineWeight(3);
ORmean.SetDefaultColor(Color.YELLOW);

def diff = ORmeanH - ORmeanL;

input show_last_ORB_diff = yes;
AddLabel(show_last_ORB_diff,
text = "orb diff: " + diff,
color = Color.WHITE
);


input show_diff_bubble = yes;
addchartbubble(show_diff_bubble and (if ORActive[1] and !ORActive then ORH else Double.NaN), orh,
diff
, color.yellow, yes);

def is_orbt = if floor(orb_minutes / chart_min) == (orb_minutes / chart_min) then 1 else 0;
def is_meant = if floor(orb_mean_minutes / chart_min) == (orb_mean_minutes / chart_min) then 1 else 0;

addlabel(!is_orbt, "ORB time " + orb_minutes + " is not a multiple of chart time " + chart_min, color.cyan);
addlabel(!is_meant, "MEAN time " + orb_mean_minutes + " is not a multiple of chart time " + chart_min, color.cyan);


input test1 = no;
addchartbubble(test1, low,
diff + "\n" +
(diff/2 + orl) + "\n" +
ormean
, color.yellow, no);
# End Code ORB for Mobile App
#

used odd minute numbers, so cyan labels appear
ncL44gc.jpg
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Thank you very much,
The main reason i am doing this i noticed that especially for es and nq in 15 and 30 m 50% and 100% of difference could be target to close the position or start one
 
Last edited:
Thread starter Similar threads Forum Replies Date
X Add High Lows to ORB Questions 0
S ORB Alert / Scan Questions 0
I ORB End Time Questions 2
S Help Creating An ORB Study Questions 3
H Need Half Range line for ORB strategy Questions 2

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
335 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top