Hi Everyone,
Below is my code. I want my EA to stop once it will hit the target.I am not talking about any particular duration just it will stop the EA.
For new execution/initialisation of the trade, Have to remove the EA from the chart and again drag and drop it from the Expert list.
So once the (Target_Profit_of_this_Session) hit the given value. My EA should stop.
What about ExpertRemove()?

- www.mql5.com
Here EA will remove based on tick or no execution of trades. But i want my EA to get close after achieving that Target PROFIT.
So is there any such easy way. Please help me out.
Here EA will remove based on tick or no execution of trades. But i want my EA to get close after achieving that Target PROFIT.
So is there any such easy way. Please help me out.
And what shall the EA do after reaching Target Profit?
If you program:
bool ProfitReached = false; ... void OnTick() { if (ProfitReached) return; } if (AccountProfit()>= Target_Profit_of_this_Session) { ... ProfitReached = true; }
You have to stop and restart your EA anyway.
And what shall the EA do after reaching Target Profit?
If you program:
You have to stop and restart your EA anyway.
My main intension is to stop EA once it reached the Target Profit.
Suppose my todays target got it. And i am not infront of my system for a day or 2 days. So in that case EA should not start any trade in those time.
When i will be available and infront of my system then i will restart manually my EA by just drag and drop.
Code snippet examples:
double StartEquity; int ProfitTarget = 50; bool TradingEnabled = true; bool CheckedStartEquity = false; //do this check once, at start of EA session if (!CheckedStartEquity) { StartEquity = AccountEquity(); CheckedStartEquity = true; } //check equity after every tick if (AccountEquity() >= StartEquity + ProfitTarget) { //Close all orders OrderClose(ticket,Lots,Bid,0,Red); //.... //.... //disable further trading TradingEnabled = false; } //trading logic loop if (TradingEnabled) { //TRADING LOGIC }
as Ujjawal said, you will need to reset the EA after every session, unless you add code to execute at a certain time to reset all these values.
Code snippet examples:
as Ujjawal said, you will need to reset the EA after every session, unless you add code to execute at a certain time to reset all these values.
The shared code is not working.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Everyone,
Below is my code. I want my EA to stop once it will hit the target.
I am not talking about any particular duration just it will stop the EA.
For new execution/initialisation of the trade, Have to remove the EA from the chart and again drag and drop it from the Expert list.
So once the (Target_Profit_of_this_Session) hit the given value. My EA should stop.