How to draw a square in the high and low range of a market

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

SleepyZ

Well-known 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

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

EdMadrid1

New member
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-Pantalla-2021-10-05-a-la-s-19-44-51.png
 

Similar threads

Top