0

Hi I have a script that uses the following code:

if (longCondition or ta.crossover(secondlongentryprice, sstoploss)) and inDateRange and is_entry_session

For the secondlongentryprice I was using close as the candle value but it was repainting sometimes.
My programmer told me that using high or low as the value instead should fix the problem because, while live, the close is constantly moving but if you use low or high it doesnt matter how much more higher or lower the area that the respective candles get, as long as it gets below the are and then above in the 2 candles it satisfies the condition with no repainting.
Currently watching and recording the live chart using high and low instead of close to see if it repaints.

Gu5tavo71
  • 706
  • 1
  • 4
  • 11

1 Answers1

1

You can use barstate.isconfirmed and it won't paint until the bar actually closes

if (longCondition or ta.crossover(secondlongentryprice, sstoploss)) and inDateRange and is_entry_session and barstate.isconfirmed

or

if barstate.isconfirmed
    secondlongentryprice := close
smashapalooza
  • 932
  • 2
  • 2
  • 12
  • Okay thanks. And then you can use any OHLC? but without using that will using high/ low instead of close also not repaint? – Spenser Courville-Taylor Mar 02 '23 at 16:21
  • Using your example above you could do something like ta.crossover(secondlongentryprice, sstoploss)) and inDateRange and is_entry_session and barstate.is confirmed – smashapalooza Mar 02 '23 at 16:51