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);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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