1

I am beginning on pinescript and in coding, and I would like some help...

I would want to know the impact on the market of the last 15 minutes of each trading day. So I would want to plot the price difference between the closing at 16:00 and the closing at 15:45. And I would like to read the indicator on 1D timeframe charts.

Thank you very much!

//@version=5
indicator("Time_Strategy", "Time_Strategy", overlay=false)

close_end = if hour(time) == 16 and minute(time) == 00
     close
else
     na

close_start = if hour(time) == 15 and minute(time) == 45
     close
else
     na

close_diff= close_end - close_start

plot (close_diff, "difference", color=color.blue, style=plot.style_columns)
Nicolas
  • 13
  • 4

1 Answers1

0

The script will be execetud on each bar close, so if you set your chart to the 1D timeframe, you won't have your information.
You should use the 15 min timeframe on your chart (or 5min or 3 min or 1min), then :

//@version=5
indicator("Time_Strategy", "Time_Strategy", overlay=false)
var close_end = 0.0
var close_start = 0.0

if hour(time) == 16 and minute(time) == 00
    close_end := close
    close_diff = close_end - close_start
    label.new(bar_index, close, str.totring(close_diff))

if hour(time) == 15 and minute(time) == 45
    close_start =  close
G.Lebret
  • 2,826
  • 2
  • 16
  • 27