Download MetaTrader 5

help me please?

To add comments, please log in or register
sebastian1121
47
sebastian1121  

Hello there thanks for taking the time to click my post, I needed some help with editing an EA that I have.

the main problem I'm having is that its opening new trades at random places. What i mean is, say I set up my expert adviser and then shutdown mt4. Then say I come back 24 hours later and re-open it, the expert adviser will open new trades as if i miraculously arrived at the right moment all the parameters lined up.

I'm experimenting with "only short" "only long" options in the common section. I'm using price action and some other indicators to determine weather I want the ea to only take long or short positions. THE PROBLEM is the ea will take a new trade as soon as go from only long to only short or vise versa. as if its registering the last buy/sell command from many many pips ago

Files:
Keith Watford
Moderator
10533
Keith Watford  

I've not looked at the code, but it is possible that the history is updating and so you are getting undesired results.

Click on expert advisors to disable them as soon as the platform opens and before it connects to the internet

Disable EAs before shutting down the platform

Write code in init to deal with platform re-starts

Syed Naufal Gaddafi
1468
Syed Naufal Gaddafi  
GumRai:

I've not looked at the code, but it is possible that the history is updating and so you are getting undesired results.

Click on expert advisors to disable them as soon as the platform opens and before it connects to the internet

Disable EAs before shutting down the platform

Write code in init to deal with platform re-starts


Nah. Just put a timer. Simple as that.


Or, put a checks before opening any trades.

qjol
3245
qjol  
or you can put the EA a Sleep while GetLastError == 4066
Tjipke de Vries
6433
Tjipke de Vries  
int start()
  {
  if(AccountBalance()==0)return(0);
Syed Naufal Gaddafi
1468
Syed Naufal Gaddafi  
if(AccountBalance()==0)return(0);

Been asked many times here at this forum. Just the way of questioning is a bit different though. LOL XD
qjol
3245
qjol  

deVries:

int start()
  {
  if(AccountBalance()==0)return(0);

not true at all, because the account balance is taking let's say 2 sec to get the right value

and then you need a few more seconds for history update (i mean the charts history not orders history)

Syed Naufal Gaddafi
1468
Syed Naufal Gaddafi  
qjol:

not true at all, because the account balance is taking let's say 2 sec to get the right value

and then you need a few more seconds for history update (i mean the charts history not orders history)


As I notice it when I account balance not updating correctly when initializing, I simply put a timer to check for incoming tick. When the tick comes, everything shows the expected numbers. :)
qjol
3245
qjol  
the account balance is updated before the charts history
MikeBor
12
MikeBor  
Hello guys, wanted to share this free <link removed> with you. I do not know which topic to choose, sorry if it is incorrect. It shows good results and small profit.
Alain Verleyen
Moderator
35134
Alain Verleyen  
MikeBor:
Hello guys, wanted to share this free <link removed> with you. I do not know which topic to choose, sorry if it is incorrect. It shows good results and small profit.
You can't do that on this forum. Advertising is not allowed, even if it's free product. Thank you.
12
To add comments, please log in or register