Search code examples
pine-scriptpine-script-v4

Tradingview Pinescript quick q


I would like to plot a base horizontal line at an inputted (changeable) value, then have two lines plot around that line without showing the base line.

So baseline value entered is 1900. I want a line to automatically plot at 1901 and 1899 around that baseline but not showing the baseline (guess you could turn the baseline transparency to zero also). Thanks.


Solution

  • You don't have to plot the baseline in this case. The script will subtract and add 1 point to your input.

    //@version=4
    study("Baseline +-1", overlay = true)
    
    var float i_baseline = input(1900, "Baseline level")
    
    plot(i_baseline + 1, "Baseline + 1")
    plot(i_baseline - 1, "Baseline - 1")