the high and low range of a Asian, European markets for ThinkOrSwim

EdMadrid1

New member
How to draw a square in the high and low range of a market.
Example the high and low of the Asian market and the high and low of the European market with different colors
and that they stay painted all the time.
thank you
 
Solution
How to draw a square in the high and low range of a market.
Example the high and low of the Asian market and the high and low of the European market with different colors
and that they stay painted all the time.
thank you

Here is a modification of a recent study I did on here that plots both the sessions you requested. I do not trade these so you may need to adjust the timeframes and the minutes in the respective timeframes.

Ruby:
script times {
input coverHLOnly = yes;
input minutes     = 360;
input begin = 2100;
input end   = 0259;
def sec1    = SecondsFromTime(begin);
def sec2    = SecondsFromTime(end);
def isTime1 = (sec1 >= 0 and sec1[1] <= 0) or (sec1 < sec1[1] and sec1 >= 0);
def isTime2 = (sec2 > 0 and sec2[1] <= 0)...

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

How to draw a square in the high and low range of a market.
Example the high and low of the Asian market and the high and low of the European market with different colors
and that they stay painted all the time.
thank you

Here is a modification of a recent study I did on here that plots both the sessions you requested. I do not trade these so you may need to adjust the timeframes and the minutes in the respective timeframes.

Ruby:
script times {
input coverHLOnly = yes;
input minutes     = 360;
input begin = 2100;
input end   = 0259;
def sec1    = SecondsFromTime(begin);
def sec2    = SecondsFromTime(end);
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 topaint = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else topaint[1], 0);

def dayh    = if toPaint[1] == 0 and toPaint == 1
              then high
              else if toPaint == 1
              then Max(high, dayh[1])
              else 0;
def dayhi   = if toPaint[1] == 1 and toPaint == 0
              then dayh[1]
              else dayhi[1];
def dayl    = if toPaint[1] == 0 and toPaint == 1
              then low
              else if toPaint == 1
              then Min(low, dayl[1]) else 0 ;
def daylo   = if toPaint[1] == 1 and toPaint == 0
              then dayl[1]
              else daylo[1];

plot up      = if GetDay() <= GetLastDay() and toPaint
              then if coverHLOnly == no
                   then Double.POSITIVE_INFINITY
                   else dayhi[-minutes / (GetAggregationPeriod() / 60000)]       
              else Double.NaN;
plot down    = if GetDay() <= GetLastDay() and toPaint
              then if coverHLOnly == no
                   then Double.NEGATIVE_INFINITY
                   else daylo[-minutes / (GetAggregationPeriod() / 60000)]         
              else Double.NaN;
}
input begin1   = 2100;
input end1     = 0259;
input minutes1 = 360;
def up1   = times(minutes = minutes1, begin = begin1, end = end1);
def down1 = times(minutes = minutes1, begin = begin1, end = end1).down;
AddCloud(up1, down1, Color.cyan,color.cyan);

input begin2   = 0400;
input end2     = 1230;
input minutes2 = 510;
def up2      = times(minutes = minutes2, begin = begin2, end = end2);
def down2    = times(minutes = minutes2, begin = begin2, end = end2).down;
AddCloud(up2, down2, Color.light_red,color.light_red);

input showlabels = yes;
addlabel(showlabels, "Tokyo", color.cyan);
addlabel(showlabels, "Europe", color.light_red);
Capture.jpg
 
Solution
Finally i got it!
Thank you @SleepyZ
here the code

Code:
script times {
input coverHLOnly = yes;
input minutes     = 360;
input begin = 1800;
input end   = 0259;
def sec1    = SecondsFromTime(begin);
def sec2    = SecondsFromTime(end);

#1er cuadro amarillo el de Asia
def isTime1 = (sec1 > 0 and sec1[1] <= 0) or (sec1 < sec1[1] and sec1 >= 0);
#2do Cuadro Azul el de Europa
def isTime2 = (sec2 > 0 and sec2[1] <= 0) or (sec2 < sec2[1] and sec2 > 0);
def topaint = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else topaint[1], 0);

def dayh    = if toPaint[1] == 0 and toPaint == 1
              then high
              else if toPaint == 1
              then Max(high, dayh[1])
              else 0;
def dayhi   = if toPaint[1] == 1 and toPaint == 0
              then dayh[1]
              else dayhi[1];
def dayl    = if toPaint[1] == 0 and toPaint == 1
              then low
              else if toPaint == 1
              then Min(low, dayl[1]) else 0 ;
def daylo   = if toPaint[1] == 1 and toPaint == 0
              then dayl[1]
              else daylo[1];

plot up      = if GetDay() <= GetLastDay() and toPaint
              then if coverHLOnly == no
                   then Double.POSITIVE_INFINITY
                   else dayhi[-minutes / (GetAggregationPeriod() / 60000)]       
              else Double.NaN;
plot down    = if GetDay() <= GetLastDay() and toPaint
              then if coverHLOnly == no
                   then Double.NEGATIVE_INFINITY
                   else daylo[-minutes / (GetAggregationPeriod() / 60000)]         
              else Double.NaN;
}

input begin1   = 1745;
input end1     = 0300;
input minutes1 = 560;
def up1   = times(minutes = minutes1, begin = begin1, end = end1);
def down1 = times(minutes = minutes1, begin = begin1, end = end1).down;
AddCloud(up1, down1, createColor(255,185,50), createColor(255,185,50));

input begin2   = 0259;
input end2     = 0930;
input minutes2 = 510;
def up2      = times(minutes = minutes2, begin = begin2, end = end2);
def down2    = times(minutes = minutes2, begin = begin2, end = end2).down;
AddCloud(up2, down2, createColor(116,189,232), createColor(116,189,232));

input showlabels = yes;
addlabel(showlabels, "Tokyo", color.yellow);
addlabel(showlabels, "Europe", color.blue);

Captura-de-****alla-2021-10-05-a-la-s-19-44-51.png
 
Here is a modification of a recent study I did on here that plots both the sessions you requested. I do not trade these so you may need to adjust the timeframes and the minutes in the respective timeframes.
I have a similar indicator I found but it only prints lines not a box for session high\low. I was wondering how I can get it to print for prior dates? I got the "input showOnlyLastPeriod = yes". What do I need next?

input sessionStartTime = 2000;
input sessionEndTime = 2230;
input showOnlyLastPeriod = yes;

def day = GetDay();
def lastDay = GetLastDay();
def isToday = day == lastDay;
def isTargetPeriod = SecondsTillTime(sessionStartTime) <= 0 and SecondsTillTime(sessionEndTime) > 0 and isToday;

def targetPeriodHigh = if isTargetPeriod and high > targetPeriodHigh[1] then high
else targetPeriodHigh[1];
def pmHigh = HighestAll(targetPeriodHigh);

plot pmHighPlot = if isTargetPeriod then pmHigh else Double.NaN;
pmHighPlot.SetDefaultColor(Color.YELLOW);


def targetPeriodLow = if !isTargetPeriod then Double.POSITIVE_INFINITY
else if isTargetPeriod and low < targetPeriodLow[1] then low
else targetPeriodLow[1];

def pmLow = LowestAll(targetPeriodLow);

plot pmLowPlot = if pmLow > 0 and isTargetPeriod then pmLow else Double.NaN;
pmLowPlot.SetDefaultColor(Color.YELLOW);
 
Dear sir, I hope this message finds all ya'll well.
I am writing to kindly request some clarification & help in correcting a script assigned to the Asia pacific High Low Range. I couldn't get it to plot only the current trading day and would greatly appreciate your guidance to ensure that I complete the task accurately and as per your expectations.
Your patience and understanding has made all the difference in my learning and trading journey to be consistent since I was 23. I'm 30 now and still growing and following all you're work. Thank you for teaching me the importance of perseverance and resilience. Sincerely, Isaac.

Ruby:
script times {
input coverHLOnly = yes;
input ShowTodayOnly    = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
#Plot yesterday's high / low
#plot Yhigh = if ShowTodayOnly and !Today then Double.NaN else high(period = "day" )[1];
#plot Ylow = if ShowTodayOnly and !Today then Double.NaN else low(period = "day" )[1];
input minutes     = 360;
input begin = 1900;
input end   = 0000;
def sec1    = SecondsFromTime(begin);
def sec2    = SecondsFromTime(end);
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 topaint = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else topaint[1], 0);

def dayh    = if toPaint[1] == 0 and toPaint == 1
              then high
              else if toPaint == 1
              then Max(high, dayh[1])
              else 0;
def dayhi   = if toPaint[1] == 1 and toPaint == 0
              then dayh[1]
              else dayhi[1];
def dayl    = if toPaint[1] == 0 and toPaint == 1
              then low
              else if toPaint == 1
              then Min(low, dayl[1]) else 0 ;
def daylo   = if toPaint[1] == 1 and toPaint == 0
              then dayl[1]
              else daylo[1];

plot up      = if GetDay() <= GetLastDay() and toPaint
              then if coverHLOnly == no
                   then Double.POSITIVE_INFINITY
                   else dayhi[-minutes / (GetAggregationPeriod() / 60000)]       
              else Double.NaN;
plot down    = if GetDay() <= GetLastDay() and toPaint
              then if coverHLOnly == no
                   then Double.NEGATIVE_INFINITY
                   else daylo[-minutes / (GetAggregationPeriod() / 60000)]         
              else Double.NaN;
}
input begin1   = 1900;
input end1     = 0000;
input minutes1 = 360;
def up1   = times(minutes = minutes1, begin = begin1, end = end1);
def down1 = times(minutes = minutes1, begin = begin1, end = end1).down;
AddCloud(up1, down1, Color.YELLOW,color.YELLOW);

input begin2   = 0400;
input end2     = 1230;
input minutes2 = 510;
def up2      = times(minutes = minutes2, begin = begin2, end = end2);
def down2    = times(minutes = minutes2, begin = begin2, end = end2).down;
#AddCloud(up2, down2, Color.light_red,color.light_red);

input showlabels = yes;
addlabel(showlabels, "Tokyo", color.YELLOW);
#addlabel(showlabels, "Europe", color.light_red);
 
Last edited by a moderator:
Dear sir, I hope this message finds all ya'll well.
I am writing to kindly request some clarification & help in correcting a script assigned to the Asia pacific High Low Range. I couldn't get it to plot only the current trading day and would greatly appreciate your guidance to ensure that I complete the task accurately and as per your expectations.
Your patience and understanding has made all the difference in my learning and trading journey to be consistent since I was 23. I'm 30 now and still growing and following all you're work. Thank you for teaching me the importance of perseverance and resilience. Sincerely, Isaac.

Ruby:
script times {
input coverHLOnly = yes;
input ShowTodayOnly    = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
#Plot yesterday's high / low
#plot Yhigh = if ShowTodayOnly and !Today then Double.NaN else high(period = "day" )[1];
#plot Ylow = if ShowTodayOnly and !Today then Double.NaN else low(period = "day" )[1];
input minutes     = 360;
input begin = 1900;
input end   = 0000;
def sec1    = SecondsFromTime(begin);
def sec2    = SecondsFromTime(end);
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 topaint = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else topaint[1], 0);

def dayh    = if toPaint[1] == 0 and toPaint == 1
              then high
              else if toPaint == 1
              then Max(high, dayh[1])
              else 0;
def dayhi   = if toPaint[1] == 1 and toPaint == 0
              then dayh[1]
              else dayhi[1];
def dayl    = if toPaint[1] == 0 and toPaint == 1
              then low
              else if toPaint == 1
              then Min(low, dayl[1]) else 0 ;
def daylo   = if toPaint[1] == 1 and toPaint == 0
              then dayl[1]
              else daylo[1];

plot up      = if GetDay() <= GetLastDay() and toPaint
              then if coverHLOnly == no
                   then Double.POSITIVE_INFINITY
                   else dayhi[-minutes / (GetAggregationPeriod() / 60000)]      
              else Double.NaN;
plot down    = if GetDay() <= GetLastDay() and toPaint
              then if coverHLOnly == no
                   then Double.NEGATIVE_INFINITY
                   else daylo[-minutes / (GetAggregationPeriod() / 60000)]        
              else Double.NaN;
}
input begin1   = 1900;
input end1     = 0000;
input minutes1 = 360;
def up1   = times(minutes = minutes1, begin = begin1, end = end1);
def down1 = times(minutes = minutes1, begin = begin1, end = end1).down;
AddCloud(up1, down1, Color.YELLOW,color.YELLOW);

input begin2   = 0400;
input end2     = 1230;
input minutes2 = 510;
def up2      = times(minutes = minutes2, begin = begin2, end = end2);
def down2    = times(minutes = minutes2, begin = begin2, end = end2).down;
#AddCloud(up2, down2, Color.light_red,color.light_red);

input showlabels = yes;
addlabel(showlabels, "Tokyo", color.YELLOW);
#addlabel(showlabels, "Europe", color.light_red);

1. This uses counting to limit the plots/clouds for Tokyo as follows
2. The test bubbles are used to confirm how the count1/cond1 works
3. There are 9 Tokyo clouds per the count1. The highestall(count1) ==9 and from it is subtracted the count1 at each grouping . So the 9 count1 grouping = 9 - 9 + 1 = 1. The 8 count1 grouping = 9 - 8 + 1 = 2 ... etc, etc.
4. If you wanted to do this for Europe, then replace all count1 to count2; up1 to up2; and cond1 to cond2,

Code:
input begin1   = 1900;
input end1     = 0000;
input minutes1 = 360;
def up1    = times(minutes = minutes1, begin = begin1, end = end1);
def down1  = times(minutes = minutes1, begin = begin1, end = end1).down;
def count1 = if !IsNaN(close) and !IsNaN(up1) != !IsNaN(up1[1]) then count1[1] + 1 else count1[1];
def cond1  = HighestAll(count1) - count1 + 1;
AddCloud(if cond1 == 1 then up1 else Double.NaN, down1, Color.YELLOW, Color.YELLOW);
input test = yes;
AddChartBubble(test, low, count1 + "\n" + cond1, Color.YELLOW, no);

Here is the full code with test set to NO.
Screenshot 2024-05-05 160236.png
Code:
script times {
    input coverHLOnly = yes;
    input ShowTodayOnly    = yes;
    def Today = if GetDay() == GetLastDay() then 1 else 0;
#Plot yesterday's high / low
#plot Yhigh = if ShowTodayOnly and !Today then Double.NaN else high(period = "day" )[1];
#plot Ylow = if ShowTodayOnly and !Today then Double.NaN else low(period = "day" )[1];
    input minutes     = 360;
    input begin = 1900;
    input end   = 0000;
    def sec1    = SecondsFromTime(begin);
    def sec2    = SecondsFromTime(end);
    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 topaint = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else topaint[1], 0);

    def dayh    = if topaint[1] == 0 and topaint == 1
              then high
              else if topaint == 1
              then Max(high, dayh[1])
              else 0;
    def dayhi   = if topaint[1] == 1 and topaint == 0
              then dayh[1]
              else dayhi[1];
    def dayl    = if topaint[1] == 0 and topaint == 1
              then low
              else if topaint == 1
              then Min(low, dayl[1]) else 0 ;
    def daylo   = if topaint[1] == 1 and topaint == 0
              then dayl[1]
              else daylo[1];

    plot up      = if GetDay() <= GetLastDay() and topaint
              then if coverHLOnly == no
                   then Double.POSITIVE_INFINITY
                   else dayhi[-minutes / (GetAggregationPeriod() / 60000)]       
              else Double.NaN;
    plot down    = if GetDay() <= GetLastDay() and topaint
              then if coverHLOnly == no
                   then Double.NEGATIVE_INFINITY
                   else daylo[-minutes / (GetAggregationPeriod() / 60000)]         
              else Double.NaN;
}
input begin1   = 1900;
input end1     = 0000;
input minutes1 = 360;
def up1    = times(minutes = minutes1, begin = begin1, end = end1);
def down1  = times(minutes = minutes1, begin = begin1, end = end1).down;
def count1 = if !IsNaN(close) and !IsNaN(up1) != !IsNaN(up1[1]) then count1[1] + 1 else count1[1];
def cond1  = HighestAll(count1) - count1 + 1;
AddCloud(if cond1 == 1 then up1 else Double.NaN, down1, Color.YELLOW, Color.YELLOW);
input test = no;
AddChartBubble(test, low, count1 + "\n" + cond1, Color.YELLOW, no);

input begin2   = 0400;
input end2     = 1230;
input minutes2 = 510;
def up2      = times(minutes = minutes2, begin = begin2, end = end2);
def down2    = times(minutes = minutes2, begin = begin2, end = end2).down;
#AddCloud(up2, down2, Color.light_red,color.light_red);

input showlabels = yes;
AddLabel(showlabels, "Tokyo", Color.YELLOW);
#addlabel(showlabels, "Europe", color.light_red);
#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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