I try to add this line to my EA which doesn't work.
If AccountProfits () = 1.0
Then CloseAllTrades ()
--------------------------------------------
Do I need to add something else that I didn't know about?
Hey guys,
Is this correct?
I add
int gi_555555 = 1.0;
At the beginning.
Then this
if (OrderProfit() > gi_555555) {
CloseAllTrades();
}
The compiler shows no error. But can someone tell me if this will work?
Thanks
Hey guys,
Is this correct?
I add
int gi_555555 = 1.0;
At the beginning.
Then this
if (OrderProfit() > gi_555555) {
CloseAllTrades();
}
The compiler shows no error. But can someone tell me if this will work?
Thanks
There are some flaws in your logic, if you are having a losing session the robot will keep trading, if you do close all trades the robot will start to trade, OrderProfit ()returns current account profit so you need to compare it to the profit at the beginning of the session. Also you might not want to close winning positions arbitrarily.
If all you want to do is stop trading for a certain period of time you can do this:
if( Hour()>12 && Hour()<21){return(0)} //returns to start during the time interval
If you have SL and TP set they will execute while you sleep but no new trades will be entered. Of course you will have to adjust the hours to your local time.
HTH
Keith
Well, I don't want to stop it trading for a certain time.
And about "no new trades will be entered", my robot does not trade one position for one pair. It needs to open new trades to cancel out losing trades sometimes, so it can't be use.
I have an idea but not sure if it will work. But I need to confirm something:
void manageclose () Does it means anything include under this code will only be executed during closing of order?
Also I need to know what OrdersHistoryTotal () does.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I'm a newbie in mql coding, though I can recognize some codes. Here's what I was unable to code and I need help.
Example:
An EA can't be used during volatile time. [Price that skyrocket or drop more than 50 points in 5 minutes.]
When enabling an EA, you need to analyze the chart and make sure it's safe to trade before attaching.
My problems here is that, when the EA close a session of 5 positions on a currency [scalping] it will open a new trading session again. If I'm present, that's ok.
But if I'm sleeping, it will work by itself even during dangerous trending.
My idea is that, when the bot open a new trading session. And when that session ends, stop trading.
Can someone tell me the code which make the EA stop trading after the account balance increase by 1 USD? [That will make it stop if it earn $12 or $45]
And when the balance does increase more than 1 USD, it will stop trading until I re-attach it. Then it will calculate based on new balance.
What I mean by account balance is the balance that take realized profits into account without counting the current open trades.
Thanks