Repainting when using 'close' for crossover/under

142 Views Asked by At

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.

1

There are 1 best solutions below

2
AmphibianTrading On

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