FTS Toolkit - Trailing Stop EA - Minimize risk even further with trailing stop and BE

Peter O

Special Consultant to the FPA
Messages
4,744
Fellow Squad Members,


For those who use VPS or who are not at the PC all day this EA, in addition to our Break Even EA, can lower risk significantly as it manages trailing stop on a currency pair together with break even.

By default the EA drags stop level at 20 pips distance from market price. However, you can combine trailing stop with setting break even level. First, you can wait with trailing stop until break even triggers: if you set 'Trail_before_break_even' to false no modification will take place before stop gets to BE level.


Installation and starting:

Download source code from here:



This is an expert advisor code so you need to copy it to {MetaTrader4 folder}/experts folder and then start the trading platform (or close and restart if it was open). The tool will appear on Navigator panel (open from View menu) among Expert Advisors as FPA=TrailingStop so just drag over your chart.



Enable Expert Advisors:

To use it don't forget to enable Expert Advisors in terminal's Options (menu: Tools/Options - Expert Advisors tab first checkbox). This shows a smiley face on the upper right corner next to the EA's name (otherwise there is an x).










Settings and Parameters:

You can open Inputs tab right after starting EA when Properties come up or by pressing F7 if you switch from Common tab to Inputs.


Parameter: Break_Even_Trigger_in_Pips
Possible values: decimal numbers
Function: It tells the EA how far the market price should go in positive before break even gets set (default value is 30.0 pips). You can turn off break even if you set it to zero or negative.

Parameter: Break_Even_in_Pips
Possible values: decimal numbers
Function: This is break even level itself as you might want to calculate with spread and commission so break even would be in positive a bit (default value is 1.0 pip).

Parameter: Trailing_Stop_in_Pips
Possible values: decimal numbers
Function: The distance how far the stop level should follow market price in pips (default is 20.0 pips). If 'Trail_before_break_even' is set to false it waits until break even triggers.

Parameter: Trail_before_break_even
Possible values: true or false
Function: It hangs trailing until stop moves to break even. If BE is off (you've set 'Break_Even_Trigger_in_Pips' to zero or negative) you first need to set stop level to BE or to more profitable level. (Default is false.)

Parameter: Apply_to_all_symbols
Possible values: true or false
Function: Set it to true if you want to get all your trades managed by a single chart and EA. (Default is false.)



Operation:

Stop level follows market price by a certain distance ('Trailing_Stop_in_Pips') moving always in profitable direction. This is combined with setting break even levels that is triggered by 'Break_Even_Trigger_in_Pips' and set at 'Break_Even_in_Pips'.

If you prefer to set break even first you can get the EA wait until it triggers by setting 'Trail_before_break_even' to false (this is the default anyway).

Possibly you want to use the EA for trailing all your trades on all currency pairs, then you only need to set 'Apply_to_all_symbols' to true.


You can participate:

Tell me and your fellow Squad Members how you like it.
Tell me and your fellow Squad Members how could it be better.
Tell me and your fellow Squad Members if you have any problem while installing or using it.


Who wants to enter the Laboratory:

Right click on Navigator panel/Expert Advisors/FPA=TrailingStop and select Modify. MetaEditor opens up showing the full source code I've written for you.


On the first screen you find input parameters and you can change default values if you wish.


After modifying the code press F5 or Compile button on the top. If it writes "0 error(s),..." on the bottom, you have your own new version and you can start using it after going back to MT4 terminal.


Looking forward to hearing your feedback,

Peter
 
Last edited by a moderator:
How can i use this EA in STP brokers ?

As far as I know it should work correctly also with STP brokers. It calculates pips independently of digits and it doesn't deal with lot size. So if you see any specific problem please let me know.

Peter
 
It calculates pips independently of digits and it doesn't deal with lot size . So if you see any specific problem please let me know.
 
I just tried it from Chrome and worked well for me with both left click and right click/save link as... The same is from Firefox. Actually I don't have a working IE but anyway, I suspect it's a browser issue.

Let me try to attach it somehow else:

View attachment FPA=TrailingStop.mq4

or



Tell me if it works.
 
Last edited by a moderator:
How many pairs I can use at a time?
Regards,

Mizan Sharif

Hi,

You can set 'Apply_to_all_symbols' external variable to true and then it will manage all trades in the account. However, I prefer to use this EA on each currency pair I trade with 'Apply_to_all_symbols' set to false - that is on separate charts with many EA instances. I say it because evaluation takes place when a new tick comes in, that is if you trade AUDJPY and the EA runs on EURGBP then it will check AUDJPY prices (frequent ticks) quite rarely (when new EURGBP tick arrives in the European night). And the other thing is that if you have separate EAs on more charts you can set break even and trailing stop levels on each pair.

Peter
 
Hi,

one thing you could add that I like to use is to set the SL to the previous candles high or low (dependent on buy or sell). It's one of the easiest and safest trendwalking methods that basically implements the definition of trend (ie. higher lows, lower highs). The advantage is that your SL is dynamic based on price not on constant values like fixed trailing stop. It exits very early when trend is broken, so potential losses are low but also potential profits are much lower because retracements after low volatility movement exit the trades. I programmed an EA for that but I guess it's so simple you could add it yourself to this one.

Best regards,
Florian
 
Back
Top