Some code needed

[Deleted]  
I want to add a take profit and stop loss based on account profit or equity. So let say the account increases 50 buck it would close all open trades and start a new round of trades. How could I impliment such a function. If someone could give me some code to achieve this it would be greatly appreciated thank you
[Deleted]  
Virtualknight wrote >>
I want to add a take profit and stop loss based on account profit or equity. So let say the account increases 50 buck it would close all open trades and start a new round of trades. How could I impliment such a function. If someone could give me some code to achieve this it would be greatly appreciated thank you

if (accountequity > accountbalance) Close AllOrders;

See here https://docs.mql4.com/account

 
You can either calculate the TP needed in advance or alternatively you can check if profit/equity reached a target value each tick - when it has you can loop to close all orders.
[Deleted]  
EADeveloper wrote >>

if (accountequity > accountbalance) Close AllOrders;

See here https://docs.mql4.com/account

Sorry, of course

if (accountequity >= accountbalance+50) Close AllOrders;

[Deleted]  
Virtualknight wrote >>
I want to add a take profit and stop loss based on account profit or equity. So let say the account increases 50 buck it would close all open trades and start a new round of trades. How could I impliment such a function. If someone could give me some code to achieve this it would be greatly appreciated thank you

Here it is

Files: