0

I want to store one specific candle of the day, say O=H or O=L in variable and it will be valid until next such candle form,

Once I get candle, need to get OHLC data of this candle,

How can I store this candle?

rjcode
  • 1,193
  • 1
  • 25
  • 56

1 Answers1

0

The var keyword retains the value of a variable. You can use it like this:

var float o_open = na
var float o_high = na
var float o_low = na
var float o_close = na

if your_condition
    o_open := open
    o_high := high
    o_low := low
    o_close := close
mr_statler
  • 1,913
  • 2
  • 3
  • 14
  • Thank you, i tried to add diff like below, but it throw compilation error, ```var float diff = o_high - o_low hline(diff, "+50", color.lime)``` – rjcode Nov 10 '22 at 06:48
  • You can’t use a series with `hline()` function. You can use `line.new()` function instead – mr_statler Nov 10 '22 at 08:51