How to plot horizontal lines at price levels where the price ends with a certain number

ikymerai

New member
Hi All,

New to the forum and trying to learn thinkscript...I'd like to create an indicator that plots horizontal lines at price levels where the price ends with a certain number (user input number), i.e. userPriceEndsWith = "1.50" so we want to plot horizontal lines at every price level on the chart where the price ends with "1.50"

What I'd like to do is plot horizontal lines at 1.50, 11.50, 21.50, 31.50 etc

How can one do this in thinkscript? Are there loops in the language? Any example(s) would be greatly appreciated

Thanks in advance for all your help!

Adam
 
Solution
Hi All,

New to the forum and trying to learn thinkscript...I'd like to create an indicator that plots horizontal lines at price levels where the price ends with a certain number (user input number), i.e. userPriceEndsWith = "1.50" so we want to plot horizontal lines at every price level on the chart where the price ends with "1.50"

What I'd like to do is plot horizontal lines at 1.50, 11.50, 21.50, 31.50 etc

How can one do this in thinkscript? Are there loops in the language? Any example(s) would be greatly appreciated

Thanks in advance for all your help!

Adam

you will need a plot function for each line you want. fold loops can repeat a formula x times, but it returns 1 number value. they can't include a plot. you can't...

halcyonguy

Well-known member
VIP
Hi All,

New to the forum and trying to learn thinkscript...I'd like to create an indicator that plots horizontal lines at price levels where the price ends with a certain number (user input number), i.e. userPriceEndsWith = "1.50" so we want to plot horizontal lines at every price level on the chart where the price ends with "1.50"

What I'd like to do is plot horizontal lines at 1.50, 11.50, 21.50, 31.50 etc

How can one do this in thinkscript? Are there loops in the language? Any example(s) would be greatly appreciated

Thanks in advance for all your help!

Adam

you will need a plot function for each line you want. fold loops can repeat a formula x times, but it returns 1 number value. they can't include a plot. you can't have a loop repeat a plot many times.

below are ideas and formulas, may not be exact thinkscript codes.
the below formulas create instantaneous values.
you will have to search and find a study code that plots price line levels.

so you may want to do something like draw 3 lines above the current price, and 3 lines below it.
you could create a formula to find a multiple of 10, that is closest to the current price. call it baseline.

def basefactor = round( close /10, 0);
def baseline = basefactor * 10;

then add 3 numbers to it for lines above and subtract 3 numbers, for lines below.

def line1up = baseline + (10 + your number) ;
def line2up = baseline + (20 + your number) ;
def line3up = baseline + (30 + your number) ;

def line1dwn = baseline - (10 + your number) ;
def line2dwn = baseline - (20 + your number) ;
def line3dwn = baseline - (30 + your number);

then apply horizontal line formulas ( highestall(.... or whatever ) to each of the 7 values above.

here is an example code that draws a horizontal line.
https://usethinkscript.com/threads/how-to-plot-horizontal-line-in-thinkscript.836/#post-6832
 
Solution

Similar threads

Top