The Expert Advisor opens two opposite positions at the moment of formation of a bar.
One of the positions should be closed with Stop Loss, and the other one should close with profit with the help of the Trailing Stop function.
When testing the Expert Advisor, check its parameters in two tick generation modes ("Every tick based on real ticks" and "Every tick"), because positions are only opened on a new bar, while the Trailing function works on every tick (the possibility of trailing is checked on every tick). An example of such a situation when testing on EURUSD, M1:
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/20166
A module of trading signals based on the Moving Average indicator signal module.VSI
VSI - Volatility Switch Indicator.