Welcome to the BEST forum for traders

Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".

Draw a horizontal ray from one specific day

Dec 7, 2021 - 9:38 PM

Viewed 1555 times

https://best-trading-indicator.com/community/bti/forums/4180/topics/55213 COPY
  • Hi, I'm writing my first script, what I want to do is to draw a horizontal ray from a certain day (day of the last ATH) to the right. I draw a few lines based on percentage. I´m getting the lines at the levels that I want but it turns the chart messy with some many lines that go all through the chat. Also I´m getting a line that gets drawed at each candel top dont know why. I would like to add text on top right of the line too, with a fixed number on top of each line and the price at that line (which I already have in a variable. How do I code that?
    Here´s the script:

    levelsFormat = input.string(Values, ", options = [Values,Percent], inline =Levels)
    labelsPosition = input.string(
    Left,Labels Position, options = [Left,Right"])

    //Get ATH
    get_all_time_high() =>
    h = 0.0
    t = 0
    h := bar_index == 0 ? high : high > h[1] ? high : h[1]
    t := bar_index == 0 ? time : high > h[1] ? time : t[1]
    [h, t]

    [ath, ath_dt] = request.security(syminfo.tickerid, 'D', get_all_time_high())

    lATH=line.new(bar_index - 1, ath, bar_index, ath, extend = extend.both, color = color.green)

    line.delete(lATH[1])

    lARM=line.new(bar_index - 1, (ath*(1-0.05)), bar_index, (ath*(1-0.05)), extend = extend.both, color = color.olive, width = 1)

    line.delete(lARM[1])

    lARM2=line.new(bar_index - 1, (ath*(1-0.1)), bar_index, (ath*(1-0.1)), extend = extend.both, color = color.red, width = 1)
    line.delete(lARM2[1])

    lARM3=line.new(bar_index - 1, (ath*(1-0.15)), bar_index, (ath*(1-0.15)), extend = extend.both, color = color.red, width = 1)
    line.delete(lARM3[1])

    lARM4=line.new(bar_index - 1, (ath*(1-0.2)), bar_index, (ath*(1-0.2)), extend = extend.both, color = color.gray, width = 1)
    line.delete(lARM4[1])

    lARM5=line.new(bar_index - 1, (ath*(1-0.3)), bar_index, (ath*(1-0.3)), extend = extend.both, color = color.green, width = 1)
    line.delete(lARM5[1])

    lARM6=line.new(bar_index - 1, (ath*(1-0.4)), bar_index, (ath*(1-0.4)), extend = extend.both, color = color.olive, width = 1)
    line.delete(lARM6[1])

    lARM7=line.new(bar_index - 1, (ath*(1-0.5)), bar_index, (ath*(1-0.5)), extend = extend.both, color = color.blue, width = 1)
    line.delete(lARM7[1])

    0
  • Also I´m getting a line that gets drawed at each candel top dont know why Solved

    0
CONTENTS