The Stoploss indicator calculates a moving ratchet price level at which a trade should be liquidated in cases of adverse market conditions. The indicator can be constructed to protect either long or short positions.
A typical method of calculating a stoploss on long trades is to deduct the average true range for a given lookback period multiplied by a suitable factor from the previous bar low. A ratchet mechanism must be integrated to make sure that as long as the stoploss level is not broken, it will move higher and continue to protect achieved gains in the underlying long position.
The calculation for a stoploss on short trades is made by adding the average true range for a given lookback period multiplied by a suitable factor from the previous bar high. Again, a ratchet mechanism must be integrated to make sure that as long as the stoploss level is not broken, it will move lower and continue to protect achieved gains on the underlying short position.
