Vertical clouds between two time periods

timetraveler

New member
VIP
I'm trying to use a vertical cloud to fill in between two time periods. Would also like to control the height of the cloud.

Can anyone help? Here is my code:

# Vertical Line will NOT display if input date is set to a NON-TRADING day.

declare lower;

input XLE_start1 = 20240112;
input XLE_end1 = 20240212;

def XLE_Range_1_start = (GetYYYYMMDD() == XLE_start1) ;
def XLE_Range_1_end = (GetYYYYMMDD() == XLE_end1) ;

AddVerticalLine(((XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine(((XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

AddCloud(XLE_Range_1_start and Double.POSITIVE_INFINITY, XLE_Range_1_end and Double.NEGATIVE_INFINITY );
 
Solution
I'm trying to use a vertical cloud to fill in between two time periods. Would also like to control the height of the cloud.

Can anyone help? Here is my code:

# Vertical Line will NOT display if input date is set to a NON-TRADING day.

declare lower;

input XLE_start1 = 20240112;
input XLE_end1 = 20240212;

def XLE_Range_1_start = (GetYYYYMMDD() == XLE_start1) ;
def XLE_Range_1_end = (GetYYYYMMDD() == XLE_end1) ;

AddVerticalLine(((XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine(((XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

AddCloud(XLE_Range_1_start and Double.POSITIVE_INFINITY, XLE_Range_1_end and Double.NEGATIVE_INFINITY );

EDIT change top bottom code
i added variables for...
I'm trying to use a vertical cloud to fill in between two time periods. Would also like to control the height of the cloud.

Can anyone help? Here is my code:

# Vertical Line will NOT display if input date is set to a NON-TRADING day.

declare lower;

input XLE_start1 = 20240112;
input XLE_end1 = 20240212;

def XLE_Range_1_start = (GetYYYYMMDD() == XLE_start1) ;
def XLE_Range_1_end = (GetYYYYMMDD() == XLE_end1) ;

AddVerticalLine(((XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine(((XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

AddCloud(XLE_Range_1_start and Double.POSITIVE_INFINITY, XLE_Range_1_end and Double.NEGATIVE_INFINITY );

EDIT change top bottom code
i added variables for the cloud top and bottom, to make it easier to change them

--------------------------------

enter 2 dates , YYYMMDD
if not a trade day, then goes to nearest trade date
draws 2 vertical lines, at start date and end date
draw a gray cloud between the lines

Code:
# vert_clouds

#https://usethinkscript.com/threads/vertical-clouds-between-two-time-periods.18065/
#Vertical clouds between two time periods

declare lower;

def bn = barnumber();
def na = double.nan;

input XLE_start1 = 20240112;
input XLE_end1 = 20240212;

#def XLE_Range_1_start = (GetYYYYMMDD() == XLE_start1) ;
#def XLE_Range_1_end = (GetYYYYMMDD() == XLE_end1) ;

def XLE_Range_1_start = (GetYYYYMMDD()[1] < XLE_start1 and GetYYYYMMDD() >= XLE_start1);
def XLE_Range_1_end = (GetYYYYMMDD() <= XLE_end1 and GetYYYYMMDD()[-1] > XLE_end1);

def rng = if bn == 1 then 0
 else if XLE_Range_1_start then 1
 else if  XLE_Range_1_end then 0
 else rng[1];

# EDIT  change top bottom code
def top = Double.POSITIVE_INFINITY;
def bot = Double.negative_INFINITY;

def cldtop = (if rng then top else na);

AddVerticalLine(((XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine(((XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

#AddCloud(XLE_Range_1_start and Double.POSITIVE_INFINITY, XLE_Range_1_end and Double.NEGATIVE_INFINITY );
AddCloud( cldtop, bot, color.light_gray );
#
 

Attachments

  • Capture.JPG
    Capture.JPG
    12.7 KB · Views: 145
Last edited:
Solution
enter 2 dates , YYYMMDD
if not a trade day, then goes to nearest trade date
draws 2 vertical lines, at start date and end date
draw a gray cloud between the lines

Code:
# vert_clouds

#https://usethinkscript.com/threads/vertical-clouds-between-two-time-periods.18065/
#Vertical clouds between two time periods

declare lower;

def bn = barnumber();
def na = double.nan;

input XLE_start1 = 20240112;
input XLE_end1 = 20240212;

#def XLE_Range_1_start = (GetYYYYMMDD() == XLE_start1) ;
#def XLE_Range_1_end = (GetYYYYMMDD() == XLE_end1) ;

def XLE_Range_1_start = (GetYYYYMMDD()[1] < XLE_start1 and GetYYYYMMDD() >= XLE_start1);
def XLE_Range_1_end = (GetYYYYMMDD() <= XLE_end1 and GetYYYYMMDD()[-1] > XLE_end1);

def rng = if bn == 1 then 0
 else if XLE_Range_1_start then 1
 else if  XLE_Range_1_end then 0
 else rng[1];

def cldtop = (if rng then Double.POSITIVE_INFINITY else na);

AddVerticalLine(((XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine(((XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

#AddCloud(XLE_Range_1_start and Double.POSITIVE_INFINITY, XLE_Range_1_end and Double.NEGATIVE_INFINITY );
AddCloud( cldtop, double.negative_INFINITY, color.light_gray );
#


halcyonguy, Thank you!! This is it. I can move forward now. Am looking at controlling the height of the cloud now. I will research. Thanks!!
 
Last edited by a moderator:
halcyonguy, Thank you!! This is it. I can move forward now. Am looking at controlling the height of the cloud now. I will research. Thanks!!

This is another method that uses @halcyonguy 's fold to find the highest high/lowest low in the range to limit the height of the cloud

The image uses a 4h 180d chart

Screenshot 2024-02-26 101159.png
Code:
# Vertial_Clouds_Limited_Height
# @halcyonguy vert_clouds

#https://usethinkscript.com/threads/vertical-clouds-between-two-time-periods.18065/
#Vertical clouds between two time periods

#declare lower;

input XLE_start1 = 20240112;
input XLE_end1   = 20240212;
input hideplots  = yes;
input verticals  = yes;

def XLE_Range_1_start = (GetYYYYMMDD()[1] < XLE_start1 and GetYYYYMMDD() >= XLE_start1);
def XLE_Range_1_end   = (GetYYYYMMDD() <= XLE_end1 and GetYYYYMMDD()[-1] > XLE_end1);

def bn = BarNumber();
def na = Double.NaN;

def rng = if bn == 1 then 0
 else if XLE_Range_1_start then 1
 else if  XLE_Range_1_end then 0
 else rng[1];


def lastbar = HighestAll(if !IsNaN(close) then bn else na);

def look_back_bars_max = lastbar - HighestAll(if XLE_Range_1_start then bn else na);
def look_back_bars_min = lastbar - HighestAll(if XLE_Range_1_end then bn else na);

# is the current bar within the lookback quantity of bars? true/false

# highest
def hi = fold i = 0 to look_back_bars_max
with p
do if !rng then 0 else if GetValue(high, (bn - (lastbar - i))) > p then GetValue(high, (bn - (lastbar - i))) else p;

plot hix = if !rng then na else HighestAll(hi);
hix.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hix.SetHiding(hideplots);

# lowest
def lolo = LowestAll(if rng then low else na);
plot lox = if !rng then na else lolo;
lox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lox.SetHiding(hideplots);

AddVerticalLine((verticals and (XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

DefineGlobalColor("Cloud", Color.LIGHT_GRAY);

AddCloud( hix, lox, color1 = GlobalColor("Cloud"));

#
 
i changed my code in post 2,
i added variables for the cloud top and bottom, to make it easier to change them
I'm still trying to figure out another way to control the height of cloud without having any price chart, OR to set a 0-1 price range on the right of the chart (see image) and set the height based on 1-0.
1.png
 
This is another method that uses @halcyonguy 's fold to find the highest high/lowest low in the range to limit the height of the cloud

The image uses a 4h 180d chart
SleepyZ: I think I got it. I modified your code slightly by adding a plot so I don't rely on the symbol's price. I can now change the height accordingly. Check it out:




declare lower;


def A = 1.0;
def B = 0.5;
plot C = 0.0;


input XLE_start1 = 20240112;
input XLE_end1 = 20240212;
input hideplots = yes;
input verticals = yes;

def XLE_Range_1_start = (GetYYYYMMDD()[1] < XLE_start1 and GetYYYYMMDD() >= XLE_start1);
def XLE_Range_1_end = (GetYYYYMMDD() <= XLE_end1 and GetYYYYMMDD()[-1] > XLE_end1);

def bn = BarNumber();
def na = Double.NaN;

def rng = if bn == 1 then 0
else if XLE_Range_1_start then 1
else if XLE_Range_1_end then 0
else rng[1];


def lastbar = HighestAll(if !IsNaN(A) then bn else na);

def look_back_bars_max = lastbar - HighestAll(if XLE_Range_1_start then bn else na);
def look_back_bars_min = lastbar - HighestAll(if XLE_Range_1_end then bn else na);

# is the current bar within the lookback quantity of bars? true/false

# highest
def hi = fold i = 0 to look_back_bars_max
with p
do if !rng then 0 else if GetValue(A, (bn - (lastbar - i))) > p then GetValue(A, (bn - (lastbar - i))) else p;

plot hix = if !rng then na else HighestAll(hi);
hix.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hix.SetHiding(hideplots);

# lowest
def lolo = LowestAll(if rng then B else na);
plot lox = if !rng then na else lolo;
lox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lox.SetHiding(hideplots);

AddVerticalLine((verticals and (XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

DefineGlobalColor("Cloud", Color.LIGHT_GRAY);

AddCloud( hix, lox, color1 = GlobalColor("Cloud"));

#
 
SleepyZ: I think I got it. I modified your code slightly by adding a plot so I don't rely on the symbol's price. I can now change the height accordingly. Check it out:




declare lower;


def A = 1.0;
def B = 0.5;
plot C = 0.0;


input XLE_start1 = 20240112;
input XLE_end1 = 20240212;
input hideplots = yes;
input verticals = yes;

def XLE_Range_1_start = (GetYYYYMMDD()[1] < XLE_start1 and GetYYYYMMDD() >= XLE_start1);
def XLE_Range_1_end = (GetYYYYMMDD() <= XLE_end1 and GetYYYYMMDD()[-1] > XLE_end1);

def bn = BarNumber();
def na = Double.NaN;

def rng = if bn == 1 then 0
else if XLE_Range_1_start then 1
else if XLE_Range_1_end then 0
else rng[1];


def lastbar = HighestAll(if !IsNaN(A) then bn else na);

def look_back_bars_max = lastbar - HighestAll(if XLE_Range_1_start then bn else na);
def look_back_bars_min = lastbar - HighestAll(if XLE_Range_1_end then bn else na);

# is the current bar within the lookback quantity of bars? true/false

# highest
def hi = fold i = 0 to look_back_bars_max
with p
do if !rng then 0 else if GetValue(A, (bn - (lastbar - i))) > p then GetValue(A, (bn - (lastbar - i))) else p;

plot hix = if !rng then na else HighestAll(hi);
hix.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
hix.SetHiding(hideplots);

# lowest
def lolo = LowestAll(if rng then B else na);
plot lox = if !rng then na else lolo;
lox.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
lox.SetHiding(hideplots);

AddVerticalLine((verticals and (XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

DefineGlobalColor("Cloud", Color.LIGHT_GRAY);

AddCloud( hix, lox, color1 = GlobalColor("Cloud"));

#

Yes, that works! Since you are using constants (A,B,C) you do not need the fold code and could simpy use something like the following

Code:
declare lower;


def A = 1.0;
def B = 0.5;
plot C = 0.0;


input XLE_start1 = 20240112;
input XLE_end1  = 20240212;
input hideplots = yes;
input verticals = yes;

def XLE_Range_1_start = (GetYYYYMMDD()[1] < XLE_start1 and GetYYYYMMDD() >= XLE_start1);
def XLE_Range_1_end = (GetYYYYMMDD() <= XLE_end1 and GetYYYYMMDD()[-1] > XLE_end1);

def bn = BarNumber();
def na = Double.NaN;

def rng = if bn == 1 then 0
else if XLE_Range_1_start then 1
else if XLE_Range_1_end then 0
else rng[1];

def hix = if !rng then na else A;
def lox = if !rng then na else B;

AddVerticalLine((verticals and (XLE_Range_1_start)), "XLE begin", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_1_end)), "XLE end", Color.YELLOW, Curve.FIRM);

DefineGlobalColor("Cloud", Color.LIGHT_GRAY);

AddCloud(hix, lox, color1 = GlobalColor("Cloud"));

#
 
Last edited:
Yes, that works! Since you are using constants (A,B,C) you do not need the fold code and could simpy use something like the following
I went ahead and modified again. It works. My end goal is to use it as customizable seasonality chart. I'm currently viewing on a Daily chart for 1 year, but would like to view the specific dates in prior years as well. Is this possible?


declare lower;

input XLE_start1 = 20240210;
input XLE_end1 = 20240530;

input XLE_start2 = 20240815;
input XLE_end2 = 20240915;

input XLE_start3 = 20241115;
input XLE_end3 = 20241222;

input TOP = 0.9;
input BTM = 0.85;

input hideplots = yes;
input verticals = yes;

plot HIGH = 1.0;
HIGH.SetDefaultColor(CreateColor(025, 025, 025));
plot LOW = 0.0;
LOW.SetDefaultColor(CreateColor (025, 025, 025));

#----------------------------------------------------------------------------------------------------------- >>>

def XLE_Range_1_start = (GetYYYYMMDD()[1] < XLE_start1 and GetYYYYMMDD() >= XLE_start1);
def XLE_Range_1_end = (GetYYYYMMDD() <= XLE_end1 and GetYYYYMMDD()[-1] > XLE_end1);

def XLE_Range_2_start = (GetYYYYMMDD()[1] < XLE_start2 and GetYYYYMMDD() >= XLE_start2);
def XLE_Range_2_end = (GetYYYYMMDD() <= XLE_end2 and GetYYYYMMDD()[-1] > XLE_end2);

def XLE_Range_3_start = (GetYYYYMMDD()[1] < XLE_start3 and GetYYYYMMDD() >= XLE_start3);
def XLE_Range_3_end = (GetYYYYMMDD() <= XLE_end3 and GetYYYYMMDD()[-1] > XLE_end3);

def bn = BarNumber();
def na = Double.NaN;

def rng = if bn == 1 then 0
else if XLE_Range_1_start or XLE_Range_2_start or XLE_Range_3_start then 1
else if XLE_Range_1_end or XLE_Range_2_end or XLE_Range_3_end then 0
else rng[1];

#----------------------------------------------------------------------------------------------------------- >>>

def lastbar = HighestAll(if !IsNaN(TOP) then bn else na);

def look_back_bars_max = lastbar - HighestAll(if XLE_Range_1_start or XLE_Range_2_start or XLE_Range_3_start then bn else na);
def look_back_bars_min = lastbar - HighestAll(if XLE_Range_1_end or XLE_Range_2_end or XLE_Range_3_end then bn else na);

def hix = if !rng then na else TOP;
def lox = if !rng then na else BTM;

#----------------------------------------------------------------------------------------------------------- >>>

AddVerticalLine((verticals and (XLE_Range_1_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_1_end)), " END", Color.YELLOW, Curve.FIRM);

AddVerticalLine((verticals and (XLE_Range_2_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_2_end)), " END", Color.YELLOW, Curve.FIRM);

AddVerticalLine((verticals and (XLE_Range_3_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_3_end)), " END", Color.YELLOW, Curve.FIRM);

DefineGlobalColor("Cloud", CreateColor( 255, 255, 000 ) );
AddCloud( hix, lox, color1 = GlobalColor("Cloud"));

AddChartBubble(XLE_Range_1_start, TOP, "XLE", GlobalColor("Cloud"), no);
AddChartBubble(XLE_Range_2_start, TOP, "XLE", GlobalColor("Cloud"), no);
AddChartBubble(XLE_Range_3_start, TOP, "XLE", GlobalColor("Cloud"), no);
2.png



2.png
 
Last edited:
I went ahead and modified again. It works. My end goal is to use it as customizable seasonality chart. I'm currently viewing on a Daily chart for 1 year, but would like to view the specific dates in prior years as well. Is this possible?

If you were looking for these 2024 dates to appear for those 1 year back, then the following addition should help

1. To find the year back from the input dates was done by subtracting 10000 from each input date.
2. A years_back input was added to allow easier addition of years, if desired.
3. To make additional years_back, Add the following snippet to your full code
3a. Change all of the 'a' added to each part of the snippet to 'b', etc for each additonal year. See bold examples in snippet code

[Examples
input years_backa = 1;
def XLE_Range_1a_start = (GetYYYYMMDD()[1] < (XLE_start1-10000-years_backa) and GetYYYYMMDD() >= (XLE_start1)-10000-years_backa) ;

3b. Change years_back to next years back .


Snippet code added to full script
Code:
############
input years_backa = 1;
def XLE_Range_1a_start = (GetYYYYMMDD()[1] < (XLE_start1-10000-years_backa)  and GetYYYYMMDD() >= (XLE_start1)-10000-years_backa) ;
def XLE_Range_1a_end = (GetYYYYMMDD() <= (XLE_end1-10000-years_backa)  and GetYYYYMMDD()[-1] > (XLE_end1)-10000-years_backa) ;

def XLE_Range_2a_start = (GetYYYYMMDD()[1] < (XLE_start2-10000-years_backa)  and GetYYYYMMDD() >= (XLE_start2-10000-years_backa) );
def XLE_Range_2a_end = (GetYYYYMMDD() <= (XLE_end2-10000-years_backa) and GetYYYYMMDD()[-1] > (XLE_end2-10000-years_backa) );

def XLE_Range_3a_start = (GetYYYYMMDD()[1] < (XLE_start3-10000-years_backa)  and GetYYYYMMDD() >= (XLE_start3-10000-years_backa) );
def XLE_Range_3a_end = (GetYYYYMMDD() <= (XLE_end3-10000-years_backa)  and GetYYYYMMDD()[-1] > (XLE_end3-10000-years_backa) );


def rng1a = if bn == 1 then 0
else if XLE_Range_1a_start or XLE_Range_2a_start or XLE_Range_3a_start then 1
else if XLE_Range_1a_end or XLE_Range_2a_end or XLE_Range_3a_end then 0
else rng1a[1];

#----------------------------------------------------------------------------------------------------------- >>>

def hixa = if !rng1a then na else TOP;
def loxa = if !rng1a then na else BTM;

#----------------------------------------------------------------------------------------------------------- >>>

AddVerticalLine((verticals and (XLE_Range_1a_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_1a_end)), " END", Color.YELLOW, Curve.FIRM);

AddVerticalLine((verticals and (XLE_Range_2a_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_2a_end)), " END", Color.YELLOW, Curve.FIRM);

AddVerticalLine((verticals and (XLE_Range_3a_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_3a_end)), " END", Color.YELLOW, Curve.FIRM);


DefineGlobalColor("Cloud", CreateColor( 255, 255, 000 ) );
AddCloud( hixa, loxa, color1 = GlobalColor("Cloud"));

AddChartBubble(XLE_Range_1a_start, TOP, "XLE", GlobalColor("Cloud"), no);
AddChartBubble(XLE_Range_2a_start, TOP, "XLE", GlobalColor("Cloud"), no);
AddChartBubble(XLE_Range_3a_start, TOP, "XLE", GlobalColor("Cloud"), no);

#

The full code is below

Screenshot 2024-02-26 152448.png
Code:
declare lower;


input XLE_start1 = 20240210;
input XLE_end1 = 20240530;

input XLE_start2 = 20240815;
input XLE_end2 = 20240915;

input XLE_start3 = 20241115;
input XLE_end3 = 20241222;

input TOP = 0.9;
input BTM = 0.85;

input hideplots = yes;
input verticals = yes;

plot HIGH = 1.0;
HIGH.SetDefaultColor(CreateColor(025, 025, 025));
plot LOW = 0.0;
LOW.SetDefaultColor(CreateColor (025, 025, 025));

#----------------------------------------------------------------------------------------------------------- >>>

def XLE_Range_1_start = (GetYYYYMMDD()[1] < XLE_start1  and GetYYYYMMDD() >= XLE_start1);
def XLE_Range_1_end = (GetYYYYMMDD() <= XLE_end1 and GetYYYYMMDD()[-1] > XLE_end1);

def XLE_Range_2_start = (GetYYYYMMDD()[1] < XLE_start2 and GetYYYYMMDD() >= XLE_start2);
def XLE_Range_2_end = (GetYYYYMMDD() <= XLE_end2 and GetYYYYMMDD()[-1] > XLE_end2);

def XLE_Range_3_start = (GetYYYYMMDD()[1] < XLE_start3 and GetYYYYMMDD() >= XLE_start3);
def XLE_Range_3_end = (GetYYYYMMDD() <= XLE_end3 and GetYYYYMMDD()[-1] > XLE_end3);

def bn = BarNumber();
def na = Double.NaN;

def rng = if bn == 1 then 0
else if XLE_Range_1_start or XLE_Range_2_start or XLE_Range_3_start then 1
else if XLE_Range_1_end or XLE_Range_2_end or XLE_Range_3_end then 0
else rng[1];

#----------------------------------------------------------------------------------------------------------- >>>

def hix = if !rng then na else TOP;
def lox = if !rng then na else BTM;

#----------------------------------------------------------------------------------------------------------- >>>

AddVerticalLine((verticals and (XLE_Range_1_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_1_end)), " END", Color.YELLOW, Curve.FIRM);

AddVerticalLine((verticals and (XLE_Range_2_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_2_end)), " END", Color.YELLOW, Curve.FIRM);

AddVerticalLine((verticals and (XLE_Range_3_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_3_end)), " END", Color.YELLOW, Curve.FIRM);

DefineGlobalColor("Cloud", CreateColor( 255, 255, 000 ) );
AddCloud( hix, lox, color1 = GlobalColor("Cloud"));

AddChartBubble(XLE_Range_1_start, TOP, "XLE", GlobalColor("Cloud"), no);
AddChartBubble(XLE_Range_2_start, TOP, "XLE", GlobalColor("Cloud"), no);
AddChartBubble(XLE_Range_3_start, TOP, "XLE", GlobalColor("Cloud"), no);

############
input years_backa = 1;
def XLE_Range_1a_start = (GetYYYYMMDD()[1] < (XLE_start1-10000-years_backa)  and GetYYYYMMDD() >= (XLE_start1)-10000-years_backa) ;
def XLE_Range_1a_end = (GetYYYYMMDD() <= (XLE_end1-10000-years_backa)  and GetYYYYMMDD()[-1] > (XLE_end1)-10000-years_backa) ;

def XLE_Range_2a_start = (GetYYYYMMDD()[1] < (XLE_start2-10000-years_backa)  and GetYYYYMMDD() >= (XLE_start2-10000-years_backa) );
def XLE_Range_2a_end = (GetYYYYMMDD() <= (XLE_end2-10000-years_backa) and GetYYYYMMDD()[-1] > (XLE_end2-10000-years_backa) );

def XLE_Range_3a_start = (GetYYYYMMDD()[1] < (XLE_start3-10000-years_backa)  and GetYYYYMMDD() >= (XLE_start3-10000-years_backa) );
def XLE_Range_3a_end = (GetYYYYMMDD() <= (XLE_end3-10000-years_backa)  and GetYYYYMMDD()[-1] > (XLE_end3-10000-years_backa) );


def rng1a = if bn == 1 then 0
else if XLE_Range_1a_start or XLE_Range_2a_start or XLE_Range_3a_start then 1
else if XLE_Range_1a_end or XLE_Range_2a_end or XLE_Range_3a_end then 0
else rng1a[1];

#----------------------------------------------------------------------------------------------------------- >>>

def hixa = if !rng1a then na else TOP;
def loxa = if !rng1a then na else BTM;

#----------------------------------------------------------------------------------------------------------- >>>

AddVerticalLine((verticals and (XLE_Range_1a_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_1a_end)), " END", Color.YELLOW, Curve.FIRM);

AddVerticalLine((verticals and (XLE_Range_2a_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_2a_end)), " END", Color.YELLOW, Curve.FIRM);

AddVerticalLine((verticals and (XLE_Range_3a_start)), " BEGIN", Color.YELLOW, Curve.FIRM);
AddVerticalLine((verticals and (XLE_Range_3a_end)), " END", Color.YELLOW, Curve.FIRM);


DefineGlobalColor("Cloud", CreateColor( 255, 255, 000 ) );
AddCloud( hixa, loxa, color1 = GlobalColor("Cloud"));

AddChartBubble(XLE_Range_1a_start, TOP, "XLE", GlobalColor("Cloud"), no);
AddChartBubble(XLE_Range_2a_start, TOP, "XLE", GlobalColor("Cloud"), no);
AddChartBubble(XLE_Range_3a_start, TOP, "XLE", GlobalColor("Cloud"), no);

#
 
Last edited:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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