This Export Advisor implements the trailing stop algorithm "Trailing Stop with Inside Bars" that was suggested by the famous German trader and author Michael Voigt ("Das grosse Buch der Markttechnik") to capture robust gains when trading strong price moves.
It is used for semiautomatic trading. You open a position manually and apply the expert to the chart. It modifies your order by setting a stop loss according to the trailing stop algorithm.
- Your trade direction (Long/Short) is detected automatically.
- The expert removes itself after being stopped out.
- You can specify the initial stop bar by setting the "numberOfStopBars" input parameter.
- You can set the threshold value added to lows/highs of bars for using input parameter "delta".
- The current value for the stop value is indicated as a blue line and logged to the terminal.
- Add-On: Separate indicator that shows the progress of the stop value as a red line available for free in the market.
This is an exact implementation of the algorithm described in "Das grosse Buch der Markttechnik".
The Stop-loss value is adjusted as soon as a candle has closed, beginning with the bar after the Start Bar (second bar close):
- as soon as a new Outside Bar occurs the stop is moved to it's High/Low (+ or - delta).
- as soon as an Inside Bar occurs the stop is relaxed to the High/Low (+ or - delta) of the predecessor of the Outside Bar (or kept at the Outside Bar, if it has a lower Low/higher High than the predecessor).
- when a candle closes below the Low of the current Outside Bar (LONG) the stop is set to that close value (-delta), vice versa for SHORT.
Bar for the initial stop (Input parameter "numberOfStopBars")
InsideBarStop allows to set the candle that defines the initial stop using the input parameter "numberOfStopBars". This offers full flexibility and is the only real extension of the algorithm suggested by Voigt.
Value 0 (start bar of the algorithm), 1 (bar preceding the start bar), and so on.
Threshold buffer (Input parameter"delta")
As M. Voigt suggests the trailing stop algorithm uses a fix „delta“ value (Input Parameter) that is added to or subtracted from the High and Low values of the bars to determine stop levels and Outside/Inside Bars.
Example: You are using the InsideBarStop in Long direction on the US SPX 500 index and set the Input Parameter „delta“ to the value „2.0“. The trailing stop values will be set 2 points below the Lows of the bars. A new Outside Bar will be detected only if a bar closes more that 2 points above the High of the current Outside Bar.
This mechanism is used to reduce the impact of market noise and prevents from being stopped out by slightly new highs or lows.
Detailed information concerning the algorithm is available in the product description of the indicator InsideBarStop Indicator.
The first screenshot below shows the indicator in action. The second one shows the expert displaying the current Stop-Loss as a blue line above the corresponding candle.