Customize length of Veritical and horizontal lines

MLlalala

Member
First i wanna draw a set of lines at with a customizable height, and at fixed time. For example, at 9:30 and 10:30 i wanna draw two vertical lines, but i wanna choose to start at a certain price, let's say i wanna draw these vertical lines at 100 price level, then the height of the lines is maybe $10. This means after $10, the line will stop plotting. I need to draw several of this vertical lines

Then i also wanna plot horizontal lines. similarly, i wanna choose what price to start to draw this line. then the length of price lines needs to be amount of certain bars. Let's say i start to draw horizontal line at $100, and the length is 50 bars. The line will stop plotting after 50 bars. I need to draw several of this horizontal lines

Is there anyway to do this? Greatly appreaciate any help!

UPDATE:
I think i have solved the price line for daily chart, but i am not sure how to do it on intraday, say i wanna set start time to 9:30 and end time to 16:00

input StartDate = 20220104;
input endDate = 20220404;
input space = 100;
input startprice = 1500;


def condition1 = GetYYYYMMDD() > StartDate;
def condition2 = GetYYYYMMDD() < endDate;
def hh = if GetYYYYMMDD() == StartDate then startprice else if condition1 and condition2 then hh[1] else if GetYYYYMMDD() > endDate then Double.NaN else hh[1];
plot line0 = if GetYYYYMMDD() < StartDate then Double.NaN else hh;
line0.SetPaintingStrategy(12);

plot line1 = line0 + space;
plot line2 = line1 + space;
 
Last edited by a moderator:

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

I have not been able to customize a height for vertical line yet, though

Here is an example of customizable vertical lines and an optional cloud in between.

The image below is GME with the lines starting at 0930 and 1030, both @$120 + a height of $10.

Ruby:
input Begin  = 0930;
input End    = 1030;
def Active   = if SecondsTillTime(End) >= 0 and SecondsFromTime(Begin) >= 0 then 1 else 0;

def x        = CompoundValue(1, if SecondsTillTime(Begin)[1] > 0 and
                                   SecondsTillTime(Begin) <= 0 or
                                  (SecondsTillTime(Begin)[1] < SecondsTillTime(Begin) and
                                   SecondsTillTime(Begin)[1] > 0)
                                then BarNumber()
                                else Double.NaN, 1);
def y        = CompoundValue(1, if SecondsTillTime(End)[1] > 0 and
                                   SecondsTillTime(End) <= 0 or
                                  (SecondsTillTime(End)[1] < SecondsTillTime(End) and
                                   SecondsTillTime(End)[1] > 0)
                            then BarNumber()
                            else double.nan, 1);
input height   = 10;
input price    = 120;
def xhh         = if BarNumber() == HighestAll(x) then price + height else Double.NaN;
def xll         = if BarNumber() == HighestAll(x) then price else Double.NaN;

AddChart(xhh, xll, 0, 0, ChartType.BAR, color.yellow);

def yhh         = if BarNumber() == HighestAll(y) then price + height else Double.NaN;
def yll         = if BarNumber() == HighestAll(y) then price else Double.NaN;

AddChart(yhh, yll, 0, 0, ChartType.BAR, Color.YELLOW);

input showcloud = yes;
AddCloud(if showcloud and between(barnumber(), highestall(x), highestall(y)) then price+height else double.nan, price, color.yellow, color.yellow);
Capture.jpg
 
This looks great, i amended my price code to start between two time but it doesn't plot, may i know if you could have a look where is wrong?

input Start = 0930;#define the start of tradingsession, suggest no change
input end = 1600;#define the end of tradingsession, suggest no change
input space = 6.25;
input startprice = 300;

def condition1 = gettime() > Start;
def condition2 = Gettime() < end;
def hh = if Gettime() == Start then startprice else if condition1 and condition2 then hh[1] else if Gettime() > end then Double.NaN else hh[1];
# the logic is plotting price lines only between 0930 and 1600
plot line0 = if Gettime() < Start then Double.NaN else hh;
line0.SetPaintingStrategy(12);

plot line1 = line0 + space;
plot line2 = line1 + space;
plot line3 = line2 + space;
 
This looks great, i amended my price code to start between two time but it doesn't plot, may i know if you could have a look where is wrong?

input Start = 0930;#define the start of tradingsession, suggest no change
input end = 1600;#define the end of tradingsession, suggest no change
input space = 6.25;
input startprice = 300;

def condition1 = gettime() > Start;
def condition2 = Gettime() < end;
def hh = if Gettime() == Start then startprice else if condition1 and condition2 then hh[1] else if Gettime() > end then Double.NaN else hh[1];
# the logic is plotting price lines only between 0930 and 1600
plot line0 = if Gettime() < Start then Double.NaN else hh;
line0.SetPaintingStrategy(12);

plot line1 = line0 + space;
plot line2 = line1 + space;
plot line3 = line2 + space;

The gettime() function does not recognize your start and end times as input. So the following defines start and end to use with your code.

Ruby:
#input Start = 0930;#define the start of tradingsession, suggest no change
#input end = 1600;#define the end of tradingsession, suggest no change


input space = 6.25;
input startprice = 300;
def start = regularTradingStart(getyyyYMMDD());
def end   = regularTradingEnd(getyyYYMMDD());
def condition1 = gettime() > Start;
def condition2 = Gettime() < end;
def hh = if Gettime() crosses above Start then startprice
 else if condition1 and condition2 then hh[1] else if Gettime() > end then Double.NaN
else hh[1];

# the logic is plotting price lines only between 0930 and 1600
plot line0 = if Gettime() < Start then Double.NaN else hh;
line0.SetPaintingStrategy(12);

plot line1 = line0 + space;
plot line2 = line1 + space;
plot line3 = line2 + space;

If you wanted to use your inputs for starrt and end as is, then you would use the secondsfromtime() and/or secondstilltime() functions in conjunction with them.

Ruby:
input Start = 0930;#define the start of tradingsession, suggest no change
input end = 1600;#define the end of tradingsession, suggest no change
input space = 6.25;
input startprice = 190;

def condition1 = secondsFromTime(Start) > 0;
def condition2 = secondsFromTime(end)<0;
def hh = if secondsFromTime(Start)==0 then startprice else if condition1 and condition2 then hh[1] else if secondsfromTime(end)>0 then Double.NaN
else hh[1];
# the logic is plotting price lines only between 0930 and 1600
plot line0 = if secondsfromTime(start)<0 then Double.NaN else hh;
line0.SetPaintingStrategy(12);

plot line1 = line0 + space;
plot line2 = line1 + space;
plot line3 = line2 + space;
 
Here is an example of customizable vertical lines and an optional cloud in between.

The image below is GME with the lines starting at 0930 and 1030, both @$120 + a height of $10.
Thank you:) i have tried this and it plots a defined height vertical line at start and end time, but what if i need more lines in between? For example, every 20 minutes or bars i need to plot a line, is there a way to do it?
 
Thank you:) i have tried this and it plots a defined height vertical line at start and end time, but what if i need more lines in between? For example, every 20 minutes or bars i need to plot a line, is there a way to do it?

Since you want a custom vertical line, the TOS built-in addverticalline() function, which could be coded to automatically plot verticallines as you suggest, but these will plot from the top of the chart to the bottom.

To do the custom verticals at intervals, I have made a template to do these. It has 2 additional custome verticals included. Just set the input interval to your desired number of bars to repeat the vertical lines. You will need to add code to the template to create more custom verticals.

Here is an example of what you would add to the bottom of the template for next additional vertical

Ruby:
def xhh3         = if BarNumber() == HighestAll(x+interval * 3) then price + height else Double.NaN;
def xll3         = if BarNumber() == HighestAll(x+interval * 3) then price else Double.NaN;

AddChart(xhh3, xll3, 0, 0, ChartType.BAR, color.yellow);

Here is the template
Ruby:
input Begin  = 0930;

#def Active   = if SecondsTillTime(End) >= 0 and SecondsFromTime(Begin) >= 0 then 1 else 0;

def x        = CompoundValue(1, if SecondsTillTime(Begin)[1] > 0 and
                                   SecondsTillTime(Begin) <= 0 or
                                  (SecondsTillTime(Begin)[1] < SecondsTillTime(Begin) and
                                   SecondsTillTime(Begin)[1] > 0)
                                then BarNumber()
                                else Double.NaN, 1);
input height   = 10;
input price    = 120;
def xhh         = if BarNumber() == HighestAll(x) then price + height else Double.NaN;
def xll         = if BarNumber() == HighestAll(x) then price else Double.NaN;

AddChart(xhh, xll, 0, 0, ChartType.BAR, color.yellow);

input interval = 20;
def xhh1         = if BarNumber() == HighestAll(x+interval * 1) then price + height else Double.NaN;
def xll1         = if BarNumber() == HighestAll(x+interval * 1) then price else Double.NaN;

AddChart(xhh1, xll1, 0, 0, ChartType.BAR, color.yellow);

def xhh2         = if BarNumber() == HighestAll(x+interval * 2) then price + height else Double.NaN;
def xll2         = if BarNumber() == HighestAll(x+interval * 2) then price else Double.NaN;

AddChart(xhh2, xll2, 0, 0, ChartType.BAR, color.yellow);
 
Thank you:) i have tried this and it plots a defined height vertical line at start and end time, but what if i need more lines in between? For example, every 20 minutes or bars i need to plot a line, is there a way to do it?


thank you for posting that vertical line code, @SleepyZ . i didn't realize it was possible. for some reason i thought there would be a horizontal line component, like it would be a doji style of candle.

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

( response to post#6 )
here is my version that draws all of the repeating vertical lines, between 2 times.
. draw many partial vertical lines, between 2 times during a day.
. choose how many minutes between lines
. draw lines on all days or just the current day


Ruby:
# vertline_cust_post07

# draw many partial vertical lines, between 2 times during a day.
# choose how many minutes between lines
# draw lines on all days or just the current day

def na = double.nan;
input line_spacing_x_minutes = 20;

# is last day the current day
def istoday = if GetLastDay() == GetDay() then 1 else 0;
input show_only_today = yes;
# draw only on current day  yes/no
def days_enable = if show_only_today then istoday else 1;

input start = 0930;
input end = 1600;
# is current bar during normal trading hours?
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;

def chartagg = getAggregationPeriod();
def chartmin = (chartagg/1000)/60;
def daybarqty = roundup(390 / chartmin, 0);
#addlabel(1, "chartmin " + chartmin, color.magenta);
#AddLabel(1, "bars per day " + daybarqty, Color.MAGENTA);

# time from start
def tsec = secondsfromTime(start);
def tmin = tsec/60;

def div2 = line_spacing_x_minutes/chartmin;
def div = if (floor(div2) == div2) then 1 else 0;

def i = tmin % line_spacing_x_minutes;
def v = if isnan(close) then 0 else 1;
def x = (div and i == 0 and days_enable and daytime and v and (secondsfromTime(start) != 0 and secondsfromTime(end) != 0));

input height   = 10;
input price    = 120;
# draw partial vertical lines, at x minute spacing
def h1 = if x then (price + height) else na;
def l1 = if x then price else na;
AddChart(h1, l1 , 0, 0, ChartType.BAR, color.yellow);


# draw 2 vertical lines, at start and end of period
def ss = if (days_enable and v and (secondsfromTime(start) == 0 or secondsfromTime(end) == 0) ) then 1 else 0;
# draw partial vertical line
def h2 = if ss then (price + height) else na;
def l2 = if ss then price else na;
AddChart(h2, l2 , 0, 0, ChartType.BAR, color.cyan);


addlabel(!div, "line spacing minutes is not a multiple of chart minutes " + line_spacing_x_minutes + "/" + chartmin, color.cyan);

# ------------------------------
# test stuff

input label_stats = yes;
addlabel(label_stats, "line_spacing_minutes: " + line_spacing_x_minutes, color.yellow);
addlabel(label_stats, "line_spacing_bars: " + div2, color.yellow);

input test1_vert_line = no;
addverticalline(test1_vert_line , "   " + tmin, color.cyan);

input test2_chart_stats = no;
addchartbubble(test2_chart_stats, low*0.995,
tmin + " tmin\n" +
chartmin + " min\n" +
i + " i\n" +
x + " x\n" +
div2 + " div2\n" +
div + " div"
#daybarqty + " bars\n" +
, color.yellow, no);
#


start and stop times set to 10am and 2pm
line spacing is 20 minutes , on a 5 minute chart (img2)
set to show on all days
N48NoXn.jpg
 
thank you for posting that vertical line code, @SleepyZ . i didn't realize it was possible. for some reason i thought there would be a horizontal line component, like it would be a doji style of candle.

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

( response to post#6 )
here is my version that draws all of the repeating vertical lines, between 2 times.
. draw many partial vertical lines, between 2 times during a day.
. choose how many minutes between lines
. draw lines on all days or just the current day


Ruby:
# vertline_cust_post07

# draw many partial vertical lines, between 2 times during a day.
# choose how many minutes between lines
# draw lines on all days or just the current day

def na = double.nan;
input line_spacing_x_minutes = 20;

# is last day the current day
def istoday = if GetLastDay() == GetDay() then 1 else 0;
input show_only_today = yes;
# draw only on current day  yes/no
def days_enable = if show_only_today then istoday else 1;

input start = 0930;
input end = 1600;
# is current bar during normal trading hours?
def daytime = if secondsfromTime(start) >= 0 and secondstillTime(end) > 0 then 1 else 0;

def chartagg = getAggregationPeriod();
def chartmin = (chartagg/1000)/60;
def daybarqty = roundup(390 / chartmin, 0);
#addlabel(1, "chartmin " + chartmin, color.magenta);
#AddLabel(1, "bars per day " + daybarqty, Color.MAGENTA);

# time from start
def tsec = secondsfromTime(start);
def tmin = tsec/60;

def div2 = line_spacing_x_minutes/chartmin;
def div = if (floor(div2) == div2) then 1 else 0;

def i = tmin % line_spacing_x_minutes;
def v = if isnan(close) then 0 else 1;
def x = (div and i == 0 and days_enable and daytime and v and (secondsfromTime(start) != 0 and secondsfromTime(end) != 0));

input height   = 10;
input price    = 120;
# draw partial vertical lines, at x minute spacing
def h1 = if x then (price + height) else na;
def l1 = if x then price else na;
AddChart(h1, l1 , 0, 0, ChartType.BAR, color.yellow);


# draw 2 vertical lines, at start and end of period
def ss = if (days_enable and v and (secondsfromTime(start) == 0 or secondsfromTime(end) == 0) ) then 1 else 0;
# draw partial vertical line
def h2 = if ss then (price + height) else na;
def l2 = if ss then price else na;
AddChart(h2, l2 , 0, 0, ChartType.BAR, color.cyan);


addlabel(!div, "line spacing minutes is not a multiple of chart minutes " + line_spacing_x_minutes + "/" + chartmin, color.cyan);

# ------------------------------
# test stuff

input label_stats = yes;
addlabel(label_stats, "line_spacing_minutes: " + line_spacing_x_minutes, color.yellow);
addlabel(label_stats, "line_spacing_bars: " + div2, color.yellow);

input test1_vert_line = no;
addverticalline(test1_vert_line , "   " + tmin, color.cyan);

input test2_chart_stats = no;
addchartbubble(test2_chart_stats, low*0.995,
tmin + " tmin\n" +
chartmin + " min\n" +
i + " i\n" +
x + " x\n" +
div2 + " div2\n" +
div + " div"
#daybarqty + " bars\n" +
, color.yellow, no);
#


start and stop times set to 10am and 2pm
line spacing is 20 minutes , on a 5 minute chart (img2)
set to show on all days
N48NoXn.jpg
You guys are amazing!!! i combined the price and time plot together and show what i really want to plot:

First is price line code:

input Start = 0930;#customizable
input end = 1107;#customizable
input space = 0.78125;
input startprice = 300;

def condition1 = secondsFromTime(Start) > 0;
def condition2 = secondsFromTime(end)<0;
def hh = if secondsFromTime(Start)==0 then startprice else if condition1 and condition2 then hh[1] else if secondsfromTime(end)>0 then Double.NaN
else hh[1];
# the logic is plotting price lines only between 0930 and 1600
plot line0 = if secondsfromTime(start)<0 then Double.NaN else hh;
line0.SetPaintingStrategy(12);

plot line1 = line0 + space;
plot line2 = line1 + space;
plot line3 = line2 + space;
plot line4 = line3 + space;
plot line5 = line4 + space;
plot line6 = line5 + space;
plot line7 = line6 + space;
plot line8 = line7 + space;

Then timeline code is just the same as halcyonguy in post # 8

The output should look like this
ccrZpID.png


There is a final step, i wanna plot circles as attached picture. There are 5 groups of circles, each group consists of 3 concentric circles. This seems a really difficult to do, appreiciate if some help can be provided

ezbSlfY.png
 
There is a final step, i wanna plot circles as attached picture. There are 5 groups of circles, each group consists of 3 concentric circles. This seems a really difficult to do, appreiciate if some help can be provided

i've seen a post somewhere about this. i don't understand how drawing a bunch of circles will tell you anything different, from just looking at a bare chart.
drawing a circle , on a stock chart, that has different units on the horizontal and vertical axis, is very difficult.

sometimes i create studies that i don't have a use for, just to see if i can. i started on one that draws ovals.
i will look it up and post what i have. i think i wanted to add some kind of auto scaling to get the shape closer to a circle.
https://usethinkscript.com/threads/drawing-a-circle-on-the-chart.10485/#post-93293

to everyone, i'm sorry for making posts about code, then forgetting to finish them and post the code.
 
i've seen a post somewhere about this. i don't understand how drawing a bunch of circles will tell you anything different, from just looking at a bare chart.
drawing a circle , on a stock chart, that has different units on the horizontal and vertical axis, is very difficult.

sometimes i create studies that i don't have a use for, just to see if i can. i started on one that draws ovals.
i will look it up and post what i have. i think i wanted to add some kind of auto scaling to get the shape closer to a circle.
https://usethinkscript.com/threads/drawing-a-circle-on-the-chart.10485/#post-93293

to everyone, i'm sorry for making posts about code, then forgetting to finish them and post the code.
Great thanks! i will study your script and see if i can work it out.
 
i've seen a post somewhere about this. i don't understand how drawing a bunch of circles will tell you anything different, from just looking at a bare chart.
drawing a circle , on a stock chart, that has different units on the horizontal and vertical axis, is very difficult.

sometimes i create studies that i don't have a use for, just to see if i can. i started on one that draws ovals.
i will look it up and post what i have. i think i wanted to add some kind of auto scaling to get the shape closer to a circle.
https://usethinkscript.com/threads/drawing-a-circle-on-the-chart.10485/#post-93293

to everyone, i'm sorry for making posts about code, then forgetting to finish them and post the code.
This is called Murray math, and i mannually draw this which is quite time consuming, so i am seeking a way to automate the process
 
Last edited:
Since you want a custom vertical line, the TOS built-in addverticalline() function, which could be coded to automatically plot verticallines as you suggest, but these will plot from the top of the chart to the bottom.

To do the custom verticals at intervals, I have made a template to do these. It has 2 additional custome verticals included. Just set the input interval to your desired number of bars to repeat the vertical lines. You will need to add code to the template to create more custom verticals.

Here is an example of what you would add to the bottom of the template for next additional vertical



Here is the template
Hey Sleepy Z, I was trying to achieve something similar with this time study, here is the code that I've sliced together so far.

def DrawLine = getDay() == getLastDay() and
!secondsFromTime(0930) or
!secondsFromTime(1000) or
!secondsFromTime(1030) or
!secondsFromTime(1100) or
!secondsFromTime(1130) or
!secondsFromTime(1200) or
!secondsFromTime(1230) or
!secondsFromTime(1300) or
!secondsFromTime(1330) or
!secondsFromTime(1400) or
!secondsFromTime(1430) or
!secondsFromTime(1500) or
!secondsFromTime(1530) ;
AddVerticalLine (DrawLine, "", Color.light_gray);
##setpaintstrat## having trouble...

This is simply displaying white dashed vertical lines , I was hoping to be able to do the following:
  • have the vertical lines only displayed for the current trading day
  • the ability to customize each line's color and style

Just having trouble coding the proper painting strategy so I can edit as needed. Any help is greatly appreciated! Cheers.
-N
 
Hey Sleepy Z, I was trying to achieve something similar with this time study, here is the code that I've sliced together so far.

def DrawLine = getDay() == getLastDay() and
!secondsFromTime(0930) or
!secondsFromTime(1000) or
!secondsFromTime(1030) or
!secondsFromTime(1100) or
!secondsFromTime(1130) or
!secondsFromTime(1200) or
!secondsFromTime(1230) or,
!secondsFromTime(1300) or
!secondsFromTime(1330) or
!secondsFromTime(1400) or
!secondsFromTime(1430) or
!secondsFromTime(1500) or
!secondsFromTime(1530) ;
AddVerticalLine (DrawLine, "", Color.light_gray);
##setpaintstrat## having trouble...

This is simply displaying white dashed vertical lines , I was hoping to be able to do the following:
  • have the vertical lines only displayed for the current trading day
  • the ability to customize each line's color and style

Just having trouble coding the proper painting strategy so I can edit as needed. Any help is greatly appreciated! Cheers.
-N

This will help with limiting the lines to just the last day. You can change the colors and strokes/styles for each line within thiis code.

Ruby:
def DrawLine = if getDay() == getLastDay() then
!secondsFromTime(0930) or
!secondsFromTime(1000) or
!secondsFromTime(1030) or
!secondsFromTime(1100) or
!secondsFromTime(1130) or
!secondsFromTime(1200) or
!secondsFromTime(1230) or
!secondsFromTime(1300) or
!secondsFromTime(1330) or
!secondsFromTime(1400) or
!secondsFromTime(1430) or
!secondsFromTime(1500) or
!secondsFromTime(1530)
else double.nan;
addverticalLine(Drawline, "",
if !secondsFromTime(0930) then color.red else
if !secondsFromTime(1000) then color.white else
if !secondsFromTime(1030) then color.red else
if !secondsFromTime(1100) then color.red else
if !secondsFromTime(1130) then color.red else
if !secondsFromTime(1200) then color.red else
if !secondsFromTime(1230) then color.red else
if !secondsFromTime(1300) then color.red else
if !secondsFromTime(1330) then color.red else
if !secondsFromTime(1400) then color.red else
if !secondsFromTime(1430) then color.red else
if !secondsFromTime(1500) then color.red else
color.yellow,
if !secondsFromTime(0930) then curve.FIRM else
if !secondsFromTime(1000) then curve.LONG_DASH else
if !secondsFromTime(1030) then curve.MEDIUM_DASH else
if !secondsFromTime(1100) then curve.POINTS else
if !secondsFromTime(1130) then curve.SHORT_DASH else
if !secondsFromTime(1200) then curve.FIRM else
if !secondsFromTime(1230) then curve.LONG_DASH else
if !secondsFromTime(1300) then curve.MEDIUM_DASH else
if !secondsFromTime(1330) then curve.POINTS else
if !secondsFromTime(1400) then curve.SHORT_DASH else
if !secondsFromTime(1430) then curve.FIRM else
if !secondsFromTime(1500) then curve.LONG_DASH else
curve.MEDIUM_DASH);
 
This will help with limiting the lines to just the last day. You can change the colors and strokes/styles for each line within thiis code.
This is perfect, thank you sir.

Another quick question... I'm trying to get the below definition display a boolean point signal when present
but having trouble with the code..

##
def volumestdev = RelativeVolumeStDev(length = Deviation_Length);
def decrease = volume < volume[1];
Def devdecrease = volumestdev >= 1 and decrease;

##Plot (devdecrease) if devdecrease then SetPaintingStrategy(PaintingStrategy.booLEAN_POINTS) else double.NaN;##

Let me know if this even makes sense !
Thx boss
 
This will help with limiting the lines to just the last day. You can change the colors and strokes/styles for each line within thiis code.
I forgot to ask... I re wrote the code last night, not the most efficient way of doing it I'm sure, but it does work.

How can I incorporate only showing for the current day with the below code?

def DL930 = !SecondsFromTime(0930);
AddVerticalLine (DL930 , "", Color.light_green, curve.POINTS);
def DL1030 = !SecondsFromTime(1030);
AddVerticalLine (DL1030, "", Color.dark_gRAY);
def DL1130 = !SecondsFromTime(1130);
AddVerticalLine (DL1130 , "", Color.dark_GRAY);
def DL1230 = !SecondsFromTime(1230);
AddVerticalLine (DL1230, "", Color.dark_GRAY);
def DL1330 = !SecondsFromTime(1330);
AddVerticalLine (DL1330, "", Color.dark_gray);
def DL1430 = !SecondsFromTime(1430);
AddVerticalLine (DL1430, "", Color.dark_GRAY);
def DL1530 = !SecondsFromTime(1530);
AddVerticalLine (DL1530, "", Color.dark_GRAY);

def DL1000 = !SecondsFromTime(1000);
AddVerticalLine (DL1000, "", Color.DARK_GRAY, Curve.FIRM);
def DL1100 = !SecondsFromTime(1100);
AddVerticalLine (DL1100, "", Color.DARK_GRAY, Curve.FIRM);
def DL1200 = !SecondsFromTime(1200);
AddVerticalLine (DL1200, "", Color.DARK_GRAY, Curve.FIRM);
def DL1300 = !SecondsFromTime(1300);
AddVerticalLine (DL1300, "", Color.DARK_GRAY, Curve.FIRM);
def DL1400 = !SecondsFromTime(1400);
AddVerticalLine (DL1400, "", Color.dark_GRAY, Curve.FIRM);
def DL1500 = !SecondsFromTime(1500);
AddVerticalLine (DL1500, "", Color.dark_GRAY, Curve.FIRM);
def DL1600 = !SecondsFromTime(1600);
AddVerticalLine (DL1600, "", Color.red,curve.POINTS);

thanks for all your help
 
I forgot to ask... I re wrote the code last night, not the most efficient way of doing it I'm sure, but it does work.

How can I incorporate only showing for the current day with the below code?

def DL930 = !SecondsFromTime(0930);
AddVerticalLine (DL930 , "", Color.light_green, curve.POINTS);
def DL1030 = !SecondsFromTime(1030);
AddVerticalLine (DL1030, "", Color.dark_gRAY);
def DL1130 = !SecondsFromTime(1130);
AddVerticalLine (DL1130 , "", Color.dark_GRAY);
def DL1230 = !SecondsFromTime(1230);
AddVerticalLine (DL1230, "", Color.dark_GRAY);
def DL1330 = !SecondsFromTime(1330);
AddVerticalLine (DL1330, "", Color.dark_gray);
def DL1430 = !SecondsFromTime(1430);
AddVerticalLine (DL1430, "", Color.dark_GRAY);
def DL1530 = !SecondsFromTime(1530);
AddVerticalLine (DL1530, "", Color.dark_GRAY);

def DL1000 = !SecondsFromTime(1000);
AddVerticalLine (DL1000, "", Color.DARK_GRAY, Curve.FIRM);
def DL1100 = !SecondsFromTime(1100);
AddVerticalLine (DL1100, "", Color.DARK_GRAY, Curve.FIRM);
def DL1200 = !SecondsFromTime(1200);
AddVerticalLine (DL1200, "", Color.DARK_GRAY, Curve.FIRM);
def DL1300 = !SecondsFromTime(1300);
AddVerticalLine (DL1300, "", Color.DARK_GRAY, Curve.FIRM);
def DL1400 = !SecondsFromTime(1400);
AddVerticalLine (DL1400, "", Color.dark_GRAY, Curve.FIRM);
def DL1500 = !SecondsFromTime(1500);
AddVerticalLine (DL1500, "", Color.dark_GRAY, Curve.FIRM);
def DL1600 = !SecondsFromTime(1600);
AddVerticalLine (DL1600, "", Color.red,curve.POINTS);

thanks for all your help

Put this code

Ruby:
if getday()!=getlastday() then double.nan else

as shown in the following 2 examples from your code in all of the others

Ruby:
def DL930 = !SecondsFromTime(0930);
AddVerticalLine (if getday()!=getlastday() then double.nan else DL930 , "", Color.light_green, curve.POINTS);
def DL1030 = !SecondsFromTime(1030);
AddVerticalLine (if getday()!=getlastday() then double.nan else DL1030, "", Color.dark_gRAY);
 
This is perfect, thank you sir.

Another quick question... I'm trying to get the below definition display a boolean point signal when present
but having trouble with the code..

##
def volumestdev = RelativeVolumeStDev(length = Deviation_Length);
def decrease = volume < volume[1];
Def devdecrease = volumestdev >= 1 and decrease;

##Plot (devdecrease) if devdecrease then SetPaintingStrategy(PaintingStrategy.booLEAN_POINTS) else double.NaN;##

Let me know if this even makes sense !
Thx boss

I wasn't sure where you wanted the point to appear, so I chose to put in the upper price panel. As the points were difficult to see, I added an optional bubble for your use or viewing.

Ruby:
declare upper;
input deviation_length = 60;
def volumestdev = RelativeVolumeStDev(length = deviation_length);
def decrease = volume < volume[1];
plot devdecrease = volumestdev >= 1 and decrease;
devdecrease.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
devdecrease.SetLineWeight(5);

input showbubbles = yes;
AddChartBubble(showbubbles and devdecrease, low, "", Color.CYAN, no);
 
I wasn't sure where you wanted the point to appear, so I chose to put in the upper price panel. As the points were difficult to see, I added an optional bubble for your use or viewing.

Ruby:
declare upper;
input deviation_length = 60;
def volumestdev = RelativeVolumeStDev(length = deviation_length);
def decrease = volume < volume[1];
plot devdecrease = volumestdev >= 1 and decrease;
devdecrease.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
devdecrease.SetLineWeight(5);

input showbubbles = yes;
AddChartBubble(showbubbles and devdecrease, low, "", Color.CYAN, no);
Everything i needed and then some, appreciate your help as always
-N
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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