- Help Needed for Order Execution
- Alert system in MT4
- Timeseries array indexing using loops in EA without using indicators and oncalculate function - is it possible ?
Just use a "virtual" offset.
Lets say that your original Stop is 1.3 pips (13 points). Just define your "virtual" offset to for example, 5 pips (50 points) and add it to your expected stop.
That would make your real broker side stop at 13 + 50 = 63 points (which the broker will accept because it is more than the stops level). In your code you then simply read your stop (from your broker data), subtract 50 points, getting 13 points, and if the price has moved more than that, then you close your position.
This allows you to easily implement trailing stops and not have to store extra variables in your EA. It also allows you to recover if the EA, Terminal or PC crash, and give you a safety net so that the broker will still close the trade even if you lose the connection. It will have more loss than usual but if you use a reasonable virtual stop size, it will still be within an acceptable "critical" loss level.
Just use a "virtual" offset.
Lets say that your original Stop is 1.3 pips (13 points). Just define your "virtual" offset to for example, 5 pips (50 points) and add it to your expected stop.
That would make your real broker side stop at 13 + 50 = 63 points (which the broker will accept because it is more than the stops level). In your code you then simply read your stop (from your broker data), subtract 50 points, getting 13 points, and if the price has moved more than that, then you close your position.
This allows you to easily implement trailing stops and not have to store extra variables in your EA. It also allows you to recover if the EA, Terminal or PC crash, and give you a safety net so that the broker will still close the trade even if you lose the connection. It will have more loss than usual but if you use a reasonable virtual stop size, it will still be within an acceptable "critical" loss level.
You can use static variables inside functions. That way you won't need to update them on every tick. Only when needed. They will work in a similar way as globally scoped variables, but their scope will be local, only within that function.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use