Swiss Army EA (Automatic order management) - page 2

 
matrixebiz:
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.

Yeah, you did confuse me, but thanks for the EA. I will look at it.

 

New version available. Added lots of nice close out options.

 

Hi Ryan:

Do I attach this EA to a duplicate chart of the pairs I am trading or attach it to the working chart I am running with the other EA? (no conflict?)

The other EA is the Bless FifthElement EA

Also, after it closes the trades, will it stop trading until I reset it? (This is what I want)

Will it do this?

Thanx ryan

 

Thanks

Ryan,

Some really great work here. Nice job.

P.S.

What do you think about having an option to 'hedge'. In other words, if 'hedge' is set to true, the EA will place a trade to hedge the open positions instead of closing them.

EX:

Separate open SELL orders: 1 GBP/USD mini, 2 GBP/USD minis, .5 GBP/USD minis.

'Hedge' is set to TRUE, and AMOUNT is set to $300 (or could be based on equity loss percentage).

When the account equity falls to the specified AMOUNT value, the EA places a BUY order of 3.5 mini lots to hedge the cumulative opened SELL orders mentioned above. So to add to the following features: CloseByTime; CloseByTotalProfit; CloseByTotalLoss; CloseByDrawdown; - HedgeByDrawdown

Just a thought, I figured it would help this already great EA become more encompassing... like the Swiss Army knife. (Nice name by the way... very fitting).

All the best,

MM

 

Here is one suggested my ND that is niffty!!!

The following was written by Stockwet ---

Manage Take Profit

The expert works by taking profit out of a trade at various take profit levels. You have the ability to customize the following parameters:

First_Target: This is the first take profit target, in pips, that you specify.

Target_Increment: Once the first profit target is reached, the next target will increment by the amount specified by the target increment variable.

Close_Lots: This is how many lots you want to take out at each target. For example, if you have 10 lots, you can take 1 lot out at each of 10 profit targets, or 5 lots out at each of two targets. It's up to you.

Move_Stops: Set to true if you want the expert to move stops based on the First_Stop and Stop_Differential parameters. Otherwise, set to false if you don't want stops moved automatically.

First_Stop: This will move your stoploss when a target, in pips, is reached.

Stop_Differential: This is the number of pips away from the original order entry price to set the new stop. By default, it's set to 0 but can be positive or negative.

Use_Max_Loss: Set to true if you want to input your own stoploss and hide your stop value from your broker. This is the maximum loss you'll risk on the trade. It's irrelevant if Move_Stops is set to true AND Move_Stops was triggered.

Max_Loss: example parameters that can be set for the expert. I'll explain each one with a scenario. Assume you place a 1 lot sell order for EURUSD at 1.2100 (1.2103/1.2100 - ask/bid). (Assume a 3 pip spread.)

The expert will take .1 lots ("Close_Lots"), or 1/10th of this scenario's order, out at +10 pips ("First_Target"), or 1.2090/1.2087.

After that, the next profit target will increment 8 pips ("Target_Increment") to 1.2082/1.2079. and another .1 lots will be taken out at that level. The expert continues to increment the preceding profit target by 8 pips until the original order is closed. In this example, the maximum pips gained would be 10 + (8*9), or 82 pips. (First target pips + increment pips * number of times to increment, which would vary depending on the original order size and the "Close_Lots" parameter.)

When the trade reaches +15 pips ("First_Stop"), the original stop loss will be moved to -5 pips ("Stop_Differential") from the order entry price. In this case, the order entry price was 1.2100, so the new price would be 1.2105. This means that you would lose 5 pips if the trade turned. Set the "Stop_Differential" parameter to "0" in order to move stops to breakeven (1.2100). If this parameter were, for example, set to 5, then the stop loss would be moved to 1.2095, and you would have a 5 pip increase if the move turned against you and stopped you out.

If you don't want the expert to move the order's stop loss, then set the "Move_Stops" parameter to "false". I think this works, but haven't fully tested it.

I must warn everyone that I am not a sophisticated MQ4 programmer. Use this at your own risk. If one of you crack programmers can improve it, please feel free to do so.

Also, in case you're wondering, the reason I wrote this is so that I didn't have to place 5 different stop loss orders in order to manage different take profit levels. Since I don't want to sit in front of the computer all the time, waiting for these levels to hit and I take out a portion of the order, I figured an expert would do just the thing.

Regards,

stockwet

(COTtrader)

Files:
 
Mr.Marketz:
Ryan,

Some really great work here. Nice job.

P.S.

What do you think about having an option to 'hedge'. In other words, if 'hedge' is set to true, the EA will place a trade to hedge the open positions instead of closing them.

EX:

Separate open SELL orders: 1 GBP/USD mini, 2 GBP/USD minis, .5 GBP/USD minis.

'Hedge' is set to TRUE, and AMOUNT is set to $300 (or could be based on equity loss percentage).

When the account equity falls to the specified AMOUNT value, the EA places a BUY order of 3.5 mini lots to hedge the cumulative opened SELL orders mentioned above. So to add to the following features: CloseByTime; CloseByTotalProfit; CloseByTotalLoss; CloseByDrawdown; - HedgeByDrawdown

Just a thought, I figured it would help this already great EA become more encompassing... like the Swiss Army knife. (Nice name by the way... very fitting).

All the best,

MM

Thanks, Mr. Marketz. I'm really glad that you like it. And I like the hedging idea you have; I'll try to get it into the next version.

 

Awesome!

Ryan:

One more question:

Can your EA monitor just my floating profit/loss and start a trailing stop once it reaches a specified profit target?

Thanx

 
fxgrm:
Ryan:

One more question:

Can your EA monitor just my floating profit/loss and start a trailing stop once it reaches a specified profit target?

Thanx

No, it currently applies trailing stops at whenever it is enabled. You can however make it only begin trailing when an order is profitable by setting "OnlyTrailAfterProfit" to true and selecting the amount you want it to trail.

 

Thanks Ryan

I actually need an EA that can trail the profit in my floating P/L because I have several orders open at once. This way when they are collectively in profit it will close all trades even if there are a few negative trades open still and not one at a time.

Does this make sense?

ryanklefas:
No, it currently applies trailing stops at whenever it is enabled. You can however make it only begin trailing when an order is profitable by setting "OnlyTrailAfterProfit" to true and selecting the amount you want it to trail.
 
fxgrm:
I actually need an EA that can trail the profit in my floating P/L because I have several orders open at once. This way when they are collectively in profit it will close all trades even if there are a few negative trades open still and not one at a time. Does this make sense?

You want a trailing stop applied to the orders AS A WHOLE? It doesn't do that at the moment. The closest thing 1.3 has to that is the CloseByTotalProfit.

Reason: