Anyway to get this overnight gap cloud to extend until crossed pass one day?

beerguyster

New member
I love this overnight gap code and how it removes the cloud as it travels into it. But it only displays for that day. Anyway to get the cloud to extend until crossed pass one day?

I also noticed a peculiar behavior where it won't display an overnight gap after an abbreviated hours futures session like this 4th of July unless you have the overnight session enabled under chart settings. But the day after a regular trading day it will display the overnight gap without having overnight session enabled. Any easy workaround?

# TS_GapFill
# [www.thinkscripter.com]
# [email protected]
# Last Update 28 Jan 2010

input marketOpenTime = 0915;
input marketCloseTime = 1615;

def yesterdaysClose = close(period = "DAY" )[1];

def secondsFromOpen = SecondsFromTime(marketOpenTime);
def secondsTillClose = SecondsTillTime(marketCloseTime);
def marketOpen = if secondsFromOpen >= 0 and secondsTillClose >= 0 then 1 else 0;

rec regularHoursOpen = if (secondsFromOpen >= 0 and secondsFromOpen[1] < 0) or
(GetDay() != GetDay()[1]) then open else regularHoursOpen[1];

def newDay = if GetDay() != GetDay()[1] then 1 else 0;

rec regHoursHigh = if newDay then high else if marketOpen then
if high > regHoursHigh[1] then high else regHoursHigh[1] else high;
rec regHoursLow = if newDay then low else if marketOpen then
if low < regHoursLow[1] then low else regHoursLow[1] else low;

def yc = if marketOpen then yesterdaysClose else Double.NaN;
def o = if marketOpen then regularHoursOpen else Double.NaN;
def hg = o + (yc - o) / 2;

def gapUp = if yc < o then 1 else 0;
def gapDown = if yc > o then 1 else 0;

def gapRemaining = if gapUp then
Max(regHoursLow - yc, 0) else
if gapDown then Max(yc - regHoursHigh, 0) else 0;

def percentRemaining = 100 * gapRemaining / AbsValue(yc - o);
def gapFilled = if percentRemaining == 0 then 1 else 0;
def halfGapFilled = if percentRemaining <= 50 then 1 else 0;

plot gH = if (gapUp and !gapFilled and marketOpen and !newDay[-1])
then regHoursLow else if (gapDown and !gapFilled and marketOpen and !newDay[-1])
then yc else Double.NaN;
plot gL = if (gapUp and !gapFilled and marketOpen and !newDay[-1])
then yc else if (gapDown and !gapFilled and marketOpen and !newDay[-1])
then regHoursHigh else Double.NaN;
plot hGF = if !gapFilled and !halfGapFilled and marketOpen and !newDay[-1]
then hg else Double.NaN;

gH.SetPaintingStrategy(PaintingStrategy.DASHES);
gH.AssignValueColor(if gapDown then Color.DARK_RED else Color.DARK_GREEN);
gL.SetPaintingStrategy(PaintingStrategy.DASHES);
gL.AssignValueColor(if gapDown then Color.DARK_RED else Color.DARK_GREEN);
hGF.SetStyle(Curve.LONG_DASH);
hGF.SetDefaultColor(Color.DARK_GRAY);
gH.HideBubble();
gL.HideBubble();
hGF.HideBubble();

AddCloud(gH, gL, Color.VIOLET, Color.VIOLET);
AddLabel(gapUp or gapDown, Concat(percentRemaining, " % Gap Remaining" ), Color.WHITE);
 
Last edited:
Solution
I love this overnight gap code and how it removes the cloud as it travels into it. But it only displays for that day. Anyway to get the cloud to extend until crossed pass one day?

I also noticed a peculiar behavior where it won't display an overnight gap after an abbreviated hours futures session like this 4th of July unless you have the overnight session enabled under chart settings. But the day after a regular trading day it will display the overnight gap without having overnight session enabled. Any easy workaround?

this one will show a gap cloud until fully crossed or when a 5th gap appears
https://usethinkscript.com/threads/...-price-crosses-into-it-for-thinkorswim.11186/
I love this overnight gap code and how it removes the cloud as it travels into it. But it only displays for that day. Anyway to get the cloud to extend until crossed pass one day?

I also noticed a peculiar behavior where it won't display an overnight gap after an abbreviated hours futures session like this 4th of July unless you have the overnight session enabled under chart settings. But the day after a regular trading day it will display the overnight gap without having overnight session enabled. Any easy workaround?

this one will show a gap cloud until fully crossed or when a 5th gap appears
https://usethinkscript.com/threads/...-price-crosses-into-it-for-thinkorswim.11186/
 
Solution

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

I love this overnight gap code and how it removes the cloud as it travels into it. But it only displays for that day. Anyway to get the cloud to extend until crossed pass one day?

I also noticed a peculiar behavior where it won't display an overnight gap after an abbreviated hours futures session like this 4th of July unless you have the overnight session enabled under chart settings. But the day after a regular trading day it will display the overnight gap without having overnight session enabled. Any easy workaround?
I am using this gap indicator, and is asking the same exact question, to find a way to extend the unfilled gaps to the right until it is filled, currently it only shows for the current day.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
241 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