# TS_TRADEZONES
# http://www.thinkscripter.com
# [email protected]
# Last Update 30 JUN 2009
input zoneStart = 1500;
input zoneEnd = 1615;
input type = {default NOTRADE, REVERSAL};
plot highBar;
plot lowBar;
switch (type){
case NOTRADE:
highBar = if secondsTillTime(zoneStart) <= 0 and secondsTillTime(zoneEnd) >= 0 then highestAll(high) else double.nan;
lowBar = if secondsTillTime(zoneStart) <= 0 and secondsTillTime(zoneEnd) >= 0 then lowestAll(low) else double.nan;
case REVERSAL:
lowBar = if secondsTillTime(zoneStart) <= 0 and secondsTillTime(zoneEnd) >= 0 then highestAll(high) else double.nan;
highBar = if secondsTillTime(zoneStart) <= 0 and secondsTillTime(zoneEnd) >= 0 then lowestAll(low) else double.nan;
}
highBar.assignValueColor(if highBar>lowBar then color.dark_red else color.green);
lowBar.assignValueColor(if highBar>lowBar then color.dark_red else color.green);
addCloud(lowBar, highBar);
#---------------- End Of Code --------------------
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
# Add Cloud Time Based
# tomsk
# 12.16.2019
declare hide_on_daily;
input Time1 = 1100;
input Time2 = 1330;
def active = SecondsTillTime(Time1) <= 0 and SecondsTillTime(Time2) >= 0;
AddCloud(if active then Double.NEGATIVE_INFINITY else Double.NaN, Double.POSITIVE_INFINITY, Color.Gray, Color.Gray);
# End Add Cloud Time Based
what time frames are you trying to highlight?Anybody know of a script to show/highlight certain times of the trading day? Like morning, mod-day, and closing, etc?
This worked great for me... i'm highlighting time frames for futures. One thing I ran into was an issue highlighting timeframes that carried over from 2300 - 0200 the next day... doesn't seem like TOS likes the idea of assigning a time value that are different days? Not sure if there is a way to code around that.@BenTen This is probably the best way to highlight via an AddCloud the times of day one would be interested in. Run this on a 5 min chart for example
Code:# Add Cloud Time Based # tomsk # 12.16.2019 declare hide_on_daily; input Time1 = 1100; input Time2 = 1330; def active = SecondsTillTime(Time1) <= 0 and SecondsTillTime(Time2) >= 0; AddCloud(if active then Double.NEGATIVE_INFINITY else Double.NaN, Double.POSITIVE_INFINITY, Color.Gray, Color.Gray); # End Add Cloud Time Based
This worked great for me... i'm highlighting time frames for futures. One thing I ran into was an issue highlighting timeframes that carried over from 2300 - 0200 the next day... doesn't seem like TOS likes the idea of assigning a time value that are different days? Not sure if there is a way to code around that.
Ruby:# Add Cloud Time Based # tomsk # 12.16.2019 declare hide_on_daily; input Time1 = 1100; input Time2 = 1330; def sec1 = SecondsFromTime(Time1); def sec2 = SecondsFromTime(Time2); def isTime1 = (sec1 >= 0 and sec1[1] < 0) or (sec1 < sec1[1] and sec1 >= 0); def isTime2 = (sec2 >= 0 and sec2[1] < 0) or (sec2 < sec2[1] and sec2 >= 0); def inRange = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else inRange[1], 0); def active = inRange; DefineGlobalColor("Cloud", Color.GRAY); AddCloud(if active then Double.NEGATIVE_INFINITY else Double.NaN, Double.POSITIVE_INFINITY, GlobalColor("Cloud"), GlobalColor("Cloud")); # End Add Cloud Time Based
@SleepyZ or others, this is a great tool. Is there a way to have the cloud stop a the high and low of the candles in the time frame?
Code:# Add Cloud Time Based # tomsk # 12.16.2019 declare hide_on_daily; input Time1 = 1100; input Time2 = 1330; def sec1 = SecondsFromTime(Time1); def sec2 = SecondsFromTime(Time2); def isTime1 = (sec1 >= 0 and sec1[1] < 0) or (sec1 < sec1[1] and sec1 >= 0); def isTime2 = (sec2 >= 0 and sec2[1] < 0) or (sec2 < sec2[1] and sec2 >= 0); def inRange = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else inRange[1], 0); def active = inRange; def bars = 200000; input pricePerRowHeightMode = { AUTOMATIC, default TICKSIZE, CUSTOM}; input customRowHeight = 1.0; input timePerProfile = {default BAR}; input onExpansion = no; input profiles = 1000; def period; switch (timePerProfile) { case BAR: period = BarNumber() - 1; } def count = CompoundValue(1, if inRange and period != period[1] then (count[1] + period - period[1]) % bars else count[1], 0); def cond = count < count[1] + period - period[1]; def height; switch (pricePerRowHeightMode) { case AUTOMATIC: height = PricePerRow.AUTOMATIC; case TICKSIZE: height = PricePerRow.TICKSIZE; case CUSTOM: height = customRowHeight; } profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 1000, "pricePerRow" = height, "value area percent" = 0); def con = CompoundValue(1, onExpansion, no); def hProfile = if inRange and IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest(); def lProfile = if inRange and IsNaN(vol.GetLowest()) and con then lProfile[1] else vol.GetLowest(); def plotsDomain = IsNaN(close) == onExpansion; def ProfileHigh = if inRange and plotsDomain then hProfile else Double.NaN; def ProfileLow = if inRange and plotsDomain then lProfile else Double.NaN; def dataCount = CompoundValue(1, if cond != cond[1] then dataCount[1] + 1 else dataCount[1] , 0); plot hrange = if inRange then ProfileHigh else Double.NaN; plot lrange = if inRange then ProfileLow else Double.NaN; DefineGlobalColor("Cloud", Color.GRAY); AddCloud(if active then hrange else Double.NaN, lrange, GlobalColor("Cloud"), GlobalColor("Cloud")); # End Add Cloud Time Based
Thanks @SleepyZ , for some reason this is not populating on my chart. I am using ticks and range bars
@SleepyZ do you know if there is an option on this to go back to the far left as much as possible?
Code:# Add Cloud Time Based # tomsk # 12.16.2019 declare hide_on_daily; script ac { input days = 0; input extend_left = no; input Time1 = 1100; input Time2 = 1330; def sec1 = SecondsFromTime(Time1); def sec2 = SecondsFromTime(Time2); def isTime1 = (sec1 >= 0 and sec1[1] < 0) or (sec1 < sec1[1] and sec1 >= 0); def isTime2 = (sec2 >= 0 and sec2[1] < 0) or (sec2 < sec2[1] and sec2 >= 0); def inRange = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else inRange[1], 0); def active = inRange; def bars = 200000; input pricePerRowHeightMode = { AUTOMATIC, default TICKSIZE, CUSTOM}; input customRowHeight = 1.0; input timePerProfile = {default BAR}; input onExpansion = no; input profiles = 1000; def period; switch (timePerProfile) { case BAR: period = BarNumber() - 1; } def count = CompoundValue(1, if inRange and period != period[1] then (count[1] + period - period[1]) % bars else count[1], 0); def cond = count < count[1] + period - period[1]; def height; switch (pricePerRowHeightMode) { case AUTOMATIC: height = PricePerRow.AUTOMATIC; case TICKSIZE: height = PricePerRow.TICKSIZE; case CUSTOM: height = customRowHeight; } profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, "numberOfProfiles" = 1000, "pricePerRow" = height, "value area percent" = 0); def con = CompoundValue(1, onExpansion, no); def hProfile = if inRange and IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest(); def lProfile = if inRange and IsNaN(vol.GetLowest()) and con then lProfile[1] else vol.GetLowest(); def plotsDomain = IsNaN(close) == onExpansion; def ProfileHigh = if inRange and plotsDomain then hProfile else Double.NaN; def ProfileLow = if inRange and plotsDomain then lProfile else Double.NaN; def dataCount = CompoundValue(1, if cond != cond[1] then dataCount[1] + 1 else dataCount[1] , 0); def ymd = GetYYYYMMDD(); def candles = !IsNaN(close); def capture = candles and ymd != ymd[1]; def dayCount = CompoundValue(1, if capture then dayCount[1] + 1 else dayCount[1], 0); def thisDay = (HighestAll(dayCount) - dayCount) ; def bn = BarNumber(); def hr = if thisDay == days and inRange then ProfileHigh else hr[1]; def hlbn = if thisDay == days and sec1 == 0 then bn else hlbn[1]; def lr = if thisDay == days and inRange then ProfileLow else lr[1]; plot hrange = if extend_left and bn <= HighestAll(hlbn) then HighestAll(hr) else if thisDay == days and inRange then ProfileHigh else Double.NaN; plot lrange = if extend_left and bn <= HighestAll(hlbn) then HighestAll(lr) else if thisDay == days and inRange then ProfileLow else Double.NaN; } input extend_left = yes; DefineGlobalColor("Cloud", Color.GRAY); DefineGlobalColor("H", Color.GREEN); DefineGlobalColor("L", Color.RED); plot hr0 = ac(0, extend_left).hrange; plot lr0 = ac(0, extend_left).lrange; AddCloud(hr0, lr0, GlobalColor("Cloud"), GlobalColor("Cloud")); plot hr1 = ac(1, extend_left).hrange; plot lr1 = ac(1, extend_left).lrange; AddCloud(hr1, lr1, GlobalColor("Cloud"), GlobalColor("Cloud")); plot hr2 = ac(2, extend_left).hrange; plot lr2 = ac(2, extend_left).lrange; AddCloud(hr2, lr2, GlobalColor("Cloud"), GlobalColor("Cloud")); plot hr3 = ac(3, extend_left).hrange; plot lr3 = ac(3, extend_left).lrange; AddCloud(hr3, lr3, GlobalColor("Cloud"), GlobalColor("Cloud")); plot hr4 = ac(4, extend_left).hrange; plot lr4 = ac(4, extend_left).lrange; AddCloud(hr4, lr4, GlobalColor("Cloud"), GlobalColor("Cloud")); hr0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); lr0.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); hr1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); lr1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); hr2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); lr2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); hr3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); lr3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); hr4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); lr4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL); hr0.SetDefaultColor(GlobalColor("H")); lr0.SetDefaultColor(GlobalColor("L")); hr1.SetDefaultColor(GlobalColor("H")); lr1.SetDefaultColor(GlobalColor("L")); hr2.SetDefaultColor(GlobalColor("H")); lr2.SetDefaultColor(GlobalColor("L")); hr3.SetDefaultColor(GlobalColor("H")); lr3.SetDefaultColor(GlobalColor("L")); hr4.SetDefaultColor(GlobalColor("H")); lr4.SetDefaultColor(GlobalColor("L")); # End Add Cloud Time Based
can you add chart bubble for hrange and lrange?Yes,
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
P | Highlight three candles consecutively making higher lows | Questions | 5 | |
Is there a way to enable constant highlight? | Questions | 1 | ||
M | Watchlist highlight blocking colors | Questions | 4 | |
T | Support resistance crosshairs highlight candles when crosshairs touch them. | Questions | 5 | |
Extended hour Highlight Cloud | Questions | 1 |
Start a new thread and receive assistance from our community.
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.
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.