0

I've seen many indicators that mark the range of forex trading sessions.

In a similar manner I'd like to draw a rectangle around all the candles between 15:00 - 18:00 GMT+2.

I'd like the top of the rectangle to be on top of the high in that range and the bottom at the low of the range.

I've tried looking at the code that they used in some of the forex trading session indicators but I'm new to all this and it went over my head. I'm also still becoming accustomed to using documentation and being able to practically create implementations from documentation.

I've tried the following:

//@version=5
indicator('My Indicator', overlay = true)

// Define the start and end times for the rectangle
startTime = timestamp(year, month, day, 10, 0, 0) - time('50D')
endTime = timestamp(year, month, day, 11, 0, 0) - time('50D')

// Use a for loop to iterate over the days in the data
for i = 0 to 49
  // Get the high and low values for the rectangle
  highValue = highest(high[range(startTime, endTime)])
  lowValue = lowest(low[range(startTime, endTime)])

  // Draw the top and bottom lines of the rectangle
  hline(highValue, startTime, endTime, color=color.orange)
  hline(lowValue, startTime, endTime, color=color.orange)

  // Draw the left and right lines of the rectangle
  vline(startTime, highValue, lowValue, color=color.orange)
  vline(endTime, highValue, lowValue, color=color.orange)

  // Increment the start and end times to the next day
  startTime := startTime + time('1D')

But I received the error:

10:11:36 PM — Compilation error. Line 12: Mismatched input 'highValue' expecting 'end of line without line continuation'

How can I get this to work?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • Forgot to mention that I would like it to display the ranges on the previous days too, i think tradingview limit is 50 – isit_reallyme Dec 28 '22 at 20:16
  • Does this answer your question? [I got TradingView's 'end of line without continuation' error with Pine Script](https://stackoverflow.com/questions/51724359/i-got-tradingviews-end-of-line-without-continuation-error-with-pine-script) – mkrieger1 Jan 03 '23 at 14:08
  • not exactly -- headed in the right direction though :) – isit_reallyme Mar 17 '23 at 19:06

0 Answers0