stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

CloseAllOfPairOrEntireBasketTM
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3538
Page 1 of 2
Author:  milanese [ Thu Mar 27, 2014 7:07 pm ]
Post subject:  CloseAllOfPairOrEntireBasketTM

mobthehop has asked me to code a trademanger that can close all positions of open pairs, or of the entire basket if a certain % target of the account-balance is reached. Here his original request:
mobthehop » Thu Mar 27, 2014 10:26 am wrote:Love it! Thanks to original requester and T for coding it....

T, could you do me a personal favour and code a version that:

- multi pairs - ie only need to be run off one chart
1. closes all orders of any ONE currency pair if the profit percentage has reached x% of balance
2. close all open / pending orders of ALL pairs when profit has reached y% of balance (similar to a basket trader) or
3. close all open / pending orders of ALL pairs when profit has reached # of open pairs multiplied by z% of balance or

eg:

1. EUR/USD, balance of account is 5000, profit target 1% (same for each pair!) - close all open orders (including any pending orders) of EUR/USD when total profit of all open orders for EUD/USD has reached 50....

2. Close all orders across the board if overall profit has reached 3% (y%)of balance
or
3. I have orders open for AU and EJ, profit per pair 0.5% (z%) close everything if 1% of balance is reached

Would very much appreciate your help as I am looking for a "helper" like this for ages....

My apologies to the thread owner for posting this here... / Thks in advance MOP
Attached you find the EA that should do this, please test the functions first on a demo account out!!
It is a multipair EA, you must only attach it at one chart and it manages all open positions, it does not matter on which chart.
The settings should be self explaining...
please use the deactivate EA button of your Empty4 before attaching the alltrademanager, and activate after attaching the EA, as the EA could freeze for some seconds yor Empty4 , do the same if you want remove the EA (the EA uses an endless loop)
Bugfix 28/03/2014
TradeManagerForMopTheHopB_6xx.mq4

Cheers :)

Tommaso
Author:  milanese [ Thu Mar 27, 2014 9:22 pm ]
Post subject:  CloseAllOfPairOrEntireBasketTM

I updated the EA in the first post for a more informative display..
Please redownload..

Cheers :)

Tommaso
Author:  mobthehop [ Fri Mar 28, 2014 12:52 am ]
Post subject:  CloseAllOfPairOrEntireBasketTM

T,

you are a coding machine... thanks a lot for doing this and so fast.... will test it out immediately

Cheers / Mop
Author:  milanese [ Fri Mar 28, 2014 8:37 am ]
Post subject:  [bugfix!!]CloseAllOfPairOrEntireBasketTM

mobthehop » Fri Mar 28, 2014 12:52 am wrote:T,

you are a coding machine... thanks a lot for doing this and so fast.... will test it out immediately

Cheers / Mop
there was a bug, that caused that trades with x % are not correct closed if x% was > y%, was my fault because I tested first only in that way.. this is fixed now it works (or should) as intended....
Please redownload all the fixed version in the first post..

Cheers :)

Tommaso
Author:  mobthehop [ Fri Mar 28, 2014 9:04 am ]
Post subject:  CloseAllOfPairOrEntireBasketTM

T, thanks a lot, you find errors faster than I can do my testing...

As always, very much appreciated / Mop
Author:  milanese [ Fri Mar 28, 2014 9:09 am ]
Post subject:  CloseAllOfPairOrEntireBasketTM

mobthehop » Fri Mar 28, 2014 9:04 am wrote:T, thanks a lot, you find errors faster than I can do my testing...

As always, very much appreciated / Mop
I had it here running OOTB running, so I saw that closes correct the Y positions, and the entire basket, but missed before closing the entire basket to close a GBPUSD buy( a X position).., was caused from a wrong else if condition that only could work if x would be < y, was caused by testing first in that way..
Edit yes now it works perfect claused here an EURAUD buy (x trade) ..

Cheers and a great weekend!

Tommaso
Author:  cad0811 [ Sat Apr 18, 2015 6:22 am ]
Post subject:  CloseAllOfPairOrEntireBasketTM

milanese » Fri Mar 28, 2014 3:07 am wrote:mobthehop has asked me to code a trademanger that can close all positions of open pairs, or of the entire basket if a certain % target of the account-balance is reached. Here his original request:
mobthehop » Thu Mar 27, 2014 10:26 am wrote:Love it! Thanks to original requester and T for coding it....

T, could you do me a personal favour and code a version that:

- multi pairs - ie only need to be run off one chart
1. closes all orders of any ONE currency pair if the profit percentage has reached x% of balance
2. close all open / pending orders of ALL pairs when profit has reached y% of balance (similar to a basket trader) or
3. close all open / pending orders of ALL pairs when profit has reached # of open pairs multiplied by z% of balance or

eg:

1. EUR/USD, balance of account is 5000, profit target 1% (same for each pair!) - close all open orders (including any pending orders) of EUR/USD when total profit of all open orders for EUD/USD has reached 50....

2. Close all orders across the board if overall profit has reached 3% (y%)of balance
or
3. I have orders open for AU and EJ, profit per pair 0.5% (z%) close everything if 1% of balance is reached

Would very much appreciate your help as I am looking for a "helper" like this for ages....

My apologies to the thread owner for posting this here... / Thks in advance MOP
Attached you find the EA that should do this, please test the functions first on a demo account out!!
It is a multipair EA, you must only attach it at one chart and it manages all open positions, it does not matter on which chart.
The settings should be self explaining...
please use the deactivate EA button of your Empty4 before attaching the alltrademanager, and activate after attaching the EA, as the EA could freeze for some seconds yor Empty4 , do the same if you want remove the EA (the EA uses an endless loop)
Bugfix 28/03/2014




Cheers :)

Tommaso
Thank you for your great tools that can have a small request?
Can you add a cash check, may be outside the percentage more than an option.
Thank you very much!
Cheers!
Author:  milanese [ Sat Apr 18, 2015 8:17 am ]
Post subject:  CloseAllOfPairOrEntireBasketTM

cad0811 » Sat Apr 18, 2015 6:22 am wrote: Thank you for your great tools that can have a small request?
Can you add a cash check, may be outside the percentage more than an option.
Thank you very much!
Cheers!
Sorry but I don't understand, what you intend with a "cash-check"?

Cheers :)

Tommaso
Author:  cad0811 [ Sat Apr 18, 2015 9:23 am ]
Post subject:  CloseAllOfPairOrEntireBasketTM

milanese » Sat Apr 18, 2015 4:17 pm wrote:
cad0811 » Sat Apr 18, 2015 6:22 am wrote: Thank you for your great tools that can have a small request?
Can you add a cash check, may be outside the percentage more than an option.
Thank you very much!
Cheers!
Sorry but I don't understand, what you intend with a "cash-check"?

Cheers :)

Tommaso
I'm sorry, forgive my poor English.
I mean: adding a "CashTakeProfit".
Such as:
ProfitPercentForPairXToClose = 1;
CashTakeProfitForPairXToClose = 30;
ProfitPercentForPairYToClose = 0.5;
CashTakeProfitForPairYToClose = 15;
AllOverBasketProfitPercentToClose = 3;
AllOverBasketCashTakeProfitToClose = 90
Thanks!
Cheers!
Author:  milanese [ Sat Apr 18, 2015 10:18 am ]
Post subject:  CloseAllOfPairOrEntireBasketTM

cad0811 » Sat Apr 18, 2015 9:23 am wrote: I'm sorry, forgive my poor English.
I mean: adding a "CashTakeProfit".
Such as:
ProfitPercentForPairXToClose = 1;
CashTakeProfitForPairXToClose = 30;
ProfitPercentForPairYToClose = 0.5;
CashTakeProfitForPairYToClose = 15;
AllOverBasketProfitPercentToClose = 3;
AllOverBasketCashTakeProfitToClose = 90
Thanks!
Cheers!
Attached is the MOD that should do what you asked...
TradeManagerForMopTheHopD.mq4
TradeManagerForMopTheHopD.ex4
Cheers :)

Tommaso
All times are UTC Page 1 of 2