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
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
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);
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);
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?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.
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);
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);
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);
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); #
@SleepyZ Whats this minutes input? How do I calculate it correctly to put it for say Asia?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);
View attachment 2633
@SleepyZ Whats this minutes input? How do I calculate it correctly to put it for say Asia?
Code:#HL_Range_Market_Times_Using_Automatic_Calculation_Of_Minutes script times { input coverHLOnly = no; input a1 = 0400; input b1 = 1230; def minutes = If(a1 > b1, ((2300 - RoundDown(a1, -2)) / 100 * 60) + (RoundDown(b1, -2) / 100) * 60, ((RoundDown(b1, -2) / 100) - (RoundDown(a1, -2) / 100)) * 60) + If(a1 > b1, 60 - (a1 - Floor(a1 / 100) * 100) + (b1 - Floor(b1 / 100) * 100), (b1 - Floor(b1 / 100) * 100) - (a1 - Floor(a1 / 100) * 100)); def sec1 = SecondsFromTime(a1); def sec2 = SecondsFromTime(b1); 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 coverHLOnly = no; input a1 = 2100; input b1 = 259; def up1 = times(coverHLOnly, a1, b1 = b1); def down1 = times(coverHLOnly, a1, b1).down; AddCloud(up1, down1, Color.CYAN, Color.CYAN); input a1a = 0400; input b1a = 1230; def up1a = times(coverHLOnly, a1a, b1a); def down1a = times(coverHLOnly, a1a, b1a).down; AddCloud(up1a, down1a, Color.LIGHT_RED, Color.LIGHT_RED); #
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
S | Plot High Low 1st Day to form range | Questions | 9 | |
O | High and Low of a Range | Questions | 1 | |
T | Yesterday Range compared to today's High/Low | Questions | 2 | |
J | N day high low range | Questions | 4 | |
Intra Year High Low Range Indicator | Questions | 3 |
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.