Swiss Army EA (Automatic order management)

 

What it is:

Below, you'll find my Swiss Army EA. I've designed it so that it can manage orders in your MT4 terminal using a large variety of methods. Features includes breakevens, trailing stops, setting/removing for takeprofits and stoplosses, and many close-out conditions; you also have ability to tell the EA which orders it can manage. This EA is an attempt to do away with little scripts for deleting orders and whatnot and just put ALL that crap in one nice package. I figure this EA should be useful for manual traders, and may also to augment EAs that are skimpy on their features, although I cannot guarantee that it will be fully compatible with all EAs.

How to use it:

Apply it to a chart. The orders that it is allowed to manage can be changed by changing the "Specific" options. It will perform trailing stops, breakevens, or closing of orders (as specified by user) for whatever orders it is allowed to manage (also specified by user). For example, if Swiss Army EA is allowed to manage all orders and you enable the trailing stops to 30, it will apply a trailing stop of 30 to all orders in your terminal. The EA will print to the screen what it is allowed to do, so that should help you along in figuring out what it is doing. Each instance of Swiss Army can only hold a certain number of settings without causing conflict within itself. If you require many different management features to be enabled, you may have to run another instance of Swiss Army to do everything that you want. Remember: You need one CONDITION, one ACTION, and one ORDER TYPE, at least.

What I need from you, the user:

If you want to use the EA, but don't know how to get it to what you want, post and ask me about it. I'll be able to provide you with a list of settings to use if the EA currently supports it. Please leave feedback and tell me what kind of management options you'd like to see in future versions; feel free to post any scripts, code, or functions that you believe would be useful.

SWISS ARMY EA:

It does everything but place its own orders!

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

New Features for Version 1.51 (June 26, 2007):IMPROVED: The actions that appear under ths "Modify Orders" section can now modify pending orders

IMPROVED: TakeProfits and Stoplosses, when set, will be applied to any hedge orders that are opened by Swiss Army

CHANGED: TakeProfits and Stoplosses, when set, will be in relation to the order's open price, NOT the current price (as in v1.5)

NEW FEATURE: RequireAllConditions when selected, will require that all selected conditions be met before actions will occur. For example, if a drawdown of 1% and Time_Activation at 12:30 are selected, actions will occur if at 12:30, if there is a drawdown of 1% or more.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Questions and Answers for v1.51 (First time users should read this part):

How does it work? Is it going to start trading by itself?

Swiss Army DOES NOT trade. It does not place any order according to any strategy, nor does it use indicators for any reason. It's sole purpose is to "manage" trades that already exist on your account.

Your TrailingStop when triggered will move SL to current market price which will most of the time close the trade anyway because price will most likely move a few pips against you do to normal market fluctuation. If not, how often does TS keep moving SL? or does it move it anymore?

The trailing stop is always X pips BEHIND the current price, X being the number that you specify.

BreakevenAt=10 when triggered will move SL to trade open price, then when you hit another 10 (20 pip profit) will it move up another ten or is that what BreakevenSlide does? once BreakevenAT is triggered thats it for BEA and BreakevenSlide=2 takes over and will keep moving SL 2 pips every +2pip more in profit price moves, correct?

This is not how the Breakeven feature works. The Breakeven feature can only be activated once, and after that, it will no longer modify the stops.

What do the settings BreakEvenAt, BreakEvenSlide and TrailingStop mean? For example, what does this setting do?

BreakEvenAt = 10

BreakEvenSlide = 20

TrailingStop = 10

Breakevens and TrailingStops are two different methods for managing the orders' stoplosses.

Because "BreakEvenAt" is at 10, when an order is profitable by 10 pips, its stoploss will be set to the open price (which will make it "breakeven") The "BreakEvenSlide" at 20 will move the "breakeven" point 20 pips higher than the order's open price, which, in this case, is not possible; therefore the "BreakEvenSlide" input must always be less than the "BreakEvenAt" input.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

KNOWN BUGS for v1.51:

"Largest Recorded" statistics are not calculated.

Actions not fully executing for some conditions (due to time lag)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

WISH LIST (whenever I get around to them):

Day of Week selectable for Time_Activation

Specific Orders selectable as an "Order Type"

Margin Statistics on screen

Files:
 

Hi raynklefas

Thank you for the expert

How do the ex.4 and mq.4 files differ?

I mean, are this 2 different versions?

And what is the BreakEvenSlide feature exactly doing?

You write in the code, it moves the BE around order open price.

Or do you meant it moves a stop around the BE?

Because normally the BE is given mathematically and can't get moved,

once the order(s) are opened.

I don't came here to critisize you, but I don't understand this point.

thnx

 
hbud:
Hi raynklefas

Thank you for the expert

How do the ex.4 and mq.4 files differ?

I mean, are this 2 different versions?

And what is the BreakEvenSlide feature exactly doing?

You write in the code, it moves the BE around order open price.

Or do you meant it moves a stop around the BE?

Because normally the BE is given mathematically and can't get moved,

once the order(s) are opened.

I don't came here to critisize you, but I don't understand this point.

thnx

The open order price IS the breakeven point. So yes, BES moves the BE around the BE. Also, I removed the EX4 because nobody uses it; yes it was the same version.

 

Hi raynklefas,

I've had so many problems with EA's with different magic numbers getting in the way of each other on the same currency.Closing the others orders etc.

Any way to address this problem with your EA?

 
retro:
Hi raynklefas,

I've had so many problems with EA's with different magic numbers getting in the way of each other on the same currency.Closing the others orders etc.

Any way to address this problem with your EA?

Nope sorry. What you are describing results from the way the EAs were coded. The EAs in question would need to be modified so they "play nicely" with other EAs. My Swiss Army EA will only be able to work correctly with certain EAs, depending on the strategy they employ for exits.

 

Hi raynklefas, thank-you for the EA.

Would be nice if the ea can offer partial take profits. eg. take 50% profit at target 1, take 25% at target 2 and the last 25% at target 3.

Thanks

jackt

 

Do I attach your SA EA to any chart then it still monitors all currencies or do I need to attach it to each currency pair I want it to monitor? IE: open one chart for Trade EA and one chart for SA EA for the currency pair I want, then do the same for all currencies? Two charts for each pair.

or do I just attach it to any chart and it will monitor all currency pair trades as individuals like another EA I have?

Thanks

 
matrixebiz:
Do I attach your SA EA to any chart then it still monitors all currencies or do I need to attach it to each currency pair I want it to monitor? IE: open one chart for Trade EA and one chart for SA EA for the currency pair I want, then do the same for all currencies? Two charts for each pair.

or do I just attach it to any chart and it will monitor all currency pair trades as individuals like another EA I have?

Thanks

It all depends on the "ManageBy" options that you select. By default, it will manage ALL trades in the terminal. I also made it print onscreen what it is allowed to manage so you will know. Also don't forget that you can run multiple instances of it at the same time. each managing a different currency.

 

I would like it to manage all trades but each one as an individual. There are EAs that manage all trades as well but they look at them all as a whole. So if all trades (regardless of currency) add up to my StopLoss of 50 it will close all trades. I want it to manage each trade independently.

 
matrixebiz:
I would like it to manage all trades but each one as an individual. There are EAs that manage all trades as well but they look at them all as a whole. So if all trades (regardless of currency) add up to my StopLoss of 50 it will close all trades. I want it to manage each trade independently.

Set "ManageBy_Symbol" to true and apply it to the symbol you want it to manage, and I think it'll do what you're looking for. Also, could you post these other EAs you're talking about. I'm curious to know what they are like.

 
ryanklefas:
Set "ManageBy_Symbol" to true and apply it to the symbol you want it to manage, and I think it'll do what you're looking for. Also, could you post these other EAs you're talking about. I'm curious to know what they are like.

There are some here: https://www.mql5.com/en/forum/176622 but they don't look at individual trades and handle then independently.

I use the I attached and need to attach to different charts and setup different Magic numbers in it according to what I set magic numbers too in the Trade EA. not really what I wanted either but can manage with it by setting different Magic numbers and set the Trade EA to only make one trade at a time per currency. I was looking for an EA that I can attach to a chart and it will look at each trade, no matter what currency and treat it as an individual and monitor it with a TS, SL and TP. I'll have to read your attached pdf and try and understand if yours will do what I want.

EG: Trade EA opens trades, 2X Aud$, 3X Eur$ 5X $cad throughout the day. Now if I don't trust the trade EA to close each order at my specific SL or TP which I've had happen, I want to attach a backup EA to monitor the open trades also, so if one 1X Eur$ trade gets to the set SL or TP it will close it for me instead of waiting for the Trade EA to close it. Maybe I'm just confusing you Don't mean to.