Average True Range (ATR) Trailing Stops Technical Indicator for cAlgo API (which is based on C#).
Trailing stops are normally calculated relative to closing price:
Calculate Average True Range ("ATR")
Multiply ATR by your selected multiple e.g. 3 x ATR
In an up-trend, subtract 3 x ATR from Closing Price and plot the result as the stop for the following day
If price closes below the ATR stop, add 3 x ATR to Closing Price — to track a Short trade
Otherwise, continue subtracting 3 x ATR for each subsequent day until price reverses below the ATR stop
[[url removed, login to view]]
More documentation can be found by google search.
I specialize in developing trading solutions for cAlgo, MT4, TradeStation etc. I can design the ATR based Trailing Stop indicator for cAlgo. Please check your inbox for my message.