I am trying to write percentage trailing stop. The code is designed to perform highest high over the previous number of bars since entry.
longStopPrice = 0.0, shortStopPrice = 0.0, lengthinmp = 0, highesthigh = 0.0, stopValue = 0.0
longStopPrice := if (strategy.position_size > 0)
lengthinmp := barssince(strategy.position_size == 0)
highesthigh = highest(high, barssince(strategy.position_size == 0)) // had used lengthinmp in an earlier version on this line
stopValue = highesthigh * (1 - StopPerc)
// max(stopValue, longStopPrice[1])
else
0
The error I get is line 49: Cannot call 'highest' with arguments (series[float], series[integer]); available overloads: highest(series[float], integer) => series[float]; highest(integer) => series[float]
My understanding is that when working it would not included the current bar. Does anyone know how to include the current bar? Thanks