Working MQL4 Expert Advisor... won't trade at all

 

Hello! This is one of my first posts, so please be easy on me.

Here is the issue -- I have written multiple EAs and not one of them will make live trades.

I cannot find out why my Expert Advisors will not trade. I have done my best to follow the official MQL4 documentation. I have read the MQL4 forum posts about Expert Advisors not taking trades. I have visited websites that claim to help in troubleshooting. Having doubts about even my hardware, I ran the Expert Advisors on three different computers to no avail.

The troubleshoots I have tried, but had no success with;

  • Check if Autotrading is enabled. It is!

  • Select Allow live trading in the EA's properties. It is ON!

  • See if Long and Short positions are enabled -- they are.

  • DLL imports are enabled even though no use has been made of them.

  • In Tools > Options > Expert Advisors, under the parent "Allow automated trading" radio button, all three radio buttons regarding "Disable automated trading..." are  unchecked*.*

  • The Experts tab as well as the Journal tab do not print any errors.

  • The terminal is confirmed to be connected to the brokerage.

  • The internet connection is solid.

  • The client has been restarted multiple times (obviously...)

  • In the code, since hearing that perhaps the slippage could be too tight, I adjusted it to be much looser.

I'm not sure if it's relevant, but I have run MT4 on computers with different amounts of CPU cores. I saw that this may or may not present an issue.

The EAs compile with 0 errors and 0 warnings, should that help in diagnostics. These EAs can be dropped onto a chart and they appear to be running -- they just never make a trade when they should. I can watch the chart and see a point that the EA should be making a trade, and the EA does nothing.

I came to the MQL4 forums as a last resort. I tried my best to troubleshoot the issue on my own, but at this point I feel like I am out of options. I read through the relevant posts and did not find any solutions -- I really don't want to waste anyone's time, but I can really use advice at this point.

Thank you for understanding my frustration and thanks in advance!


Update: I also attached an EA which I wrote to illustrate the issue. This EA simply buys at Ask price, sets a stop loss 5 pips below the buy price, and sets a take profit 10 pips above the buy price. Logically, I think that this would open a long position as soon as the EA started up. Yet, it does nothing. I hope this can help lead to a solution.

Files:
 
Nicholas Quentin Martin:

Hello! This is one of my first posts, so please be easy on me.

Here is the issue -- I have written multiple EAs and not one of them will make live trades.

I cannot find out why my Expert Advisors will not trade. I have done my best to follow the official MQL4 documentation. I have read the MQL4 forum posts about Expert Advisors not taking trades. I have visited websites that claim to help in troubleshooting. Having doubts about even my hardware, I ran the Expert Advisors on three different computers to no avail.

The troubleshoots I have tried, but had no success with;

  • Check if Autotrading is enabled. It is!

  • Select Allow live trading in the EA's properties. It is ON!

  • See if Long and Short positions are enabled -- they are.

  • DLL imports are enabled even though no use has been made of them.

  • In Tools > Options > Expert Advisors, under the parent "Allow automated trading" radio button, all three radio buttons regarding "Disable automated trading..." are  unchecked*.*

  • The Experts tab as well as the Journal tab do not print any errors.

  • The terminal is confirmed to be connected to the brokerage.

  • The internet connection is solid.

  • The client has been restarted multiple times (obviously...)

  • In the code, since hearing that perhaps the slippage could be too tight, I adjusted it to be much looser.

I'm not sure if it's relevant, but I have run MT4 on computers with different amounts of CPU cores. I saw that this may or may not present an issue.

The EAs compile with 0 errors and 0 warnings, should that help in diagnostics. These EAs can be dropped onto a chart and they appear to be running -- they just never make a trade when they should. I can watch the chart and see a point that the EA should be making a trade, and the EA does nothing.

I came to the MQL4 forums as a last resort. I tried my best to troubleshoot the issue on my own, but at this point I feel like I am out of options. I read through the relevant posts and did not find any solutions -- I really don't want to waste anyone's time, but I can really use advice at this point.

Thank you for understanding my frustration and thanks in advance!


Update: I also attached an EA which I wrote to illustrate the issue. This EA simply buys at Ask price, sets a stop loss 5 pips below the buy price, and sets a take profit 10 pips above the buy price. Logically, I think that this would open a long position as soon as the EA started up. Yet, it does nothing. I hope this can help lead to a solution.

First change this

// wrong code
if (MarketInfo(_Symbol, MODE_SPREAD) <= 2.5)

//correct code
if (MarketInfo(_Symbol, MODE_SPREAD) <= 25)


Also what does this mean? //ayrıca bu ne demek ?

double AssignStop()

{

   return entry - 0.0005;

   

}

5 pips or 50 pips? // 5 pips mi 50 pips mi?

in this state it only works with 5 digits symbols.

You can use the code below instead.

//bu hali ile sadece 5 digits sembollerde çalışır.

//Bunun yerine aşağıdaki kod u kullanabilirsiniz.


double AssignStop()

{

   return entry - 50*Point;

   

}

Attached is the screenshot of the EA working with a simple fix.

Files:
aa.PNG  12 kb
 
Mehmet Bastem:

First change this


Also what does this mean? //ayrıca bu ne demek ?

5 pips or 50 pips? // 5 pips mi 50 pips mi?

in this state it only works with 5 digits symbols.

You can use the code below instead.

//bu hali ile sadece 5 digits sembollerde çalışır.

//Bunun yerine aşağıdaki kod u kullanabilirsiniz.


Attached is the screenshot of the EA working with a simple fix.


Sorry for the delayed response! I had expected comments to my post to appear in the message section of my profile. 

Thank you for taking your time to review my code and correct its issues.

In the AssignStop() function, I intended to set a stop loss price at a distance of 5 pips below the entry price. Please, I would like to better understand -- what is the purpose/advantage of using 50*Point instead of 0.0005?

I will modify my EAs as you suggested. Thank you!

 
Nicholas Quentin Martin:

Sorry for the delayed response! I had expected comments to my post to appear in the message section of my profile. 

Thank you for taking your time to review my code and correct its issues.

In the AssignStop() function, I intended to set a stop loss price at a distance of 5 pips below the entry price. Please, I would like to better understand -- what is the purpose/advantage of using 50*Point instead of 0.0005?

I will modify my EAs as you suggested. Thank you!

i modify ur expert and define some new variables

u need no new function for such expert

only consider that you should use ecn account at least cause of using such near stoploss!

i designed that for 40 instead of 5 points

and default is openin buy positions but u can change that for sell or both at a same time

u can change that in input part when u want to run the expert

i attach code so u can use for ur next ea

Files:
just_buy.mq4  4 kb
just_buy.ex4  9 kb
 
Nicholas Quentin Martin: Check if Autotrading is enabled. It is!

Enabled in the options (or the button) and in the EA settings.

 
Nicholas Quentin Martin:

Sorry for the delayed response! I had expected comments to my post to appear in the message section of my profile. 

Thank you for taking your time to review my code and correct its issues.

In the AssignStop() function, I intended to set a stop loss price at a distance of 5 pips below the entry price. Please, I would like to better understand -- what is the purpose/advantage of using 50*Point instead of 0.0005?

I will modify my EAs as you suggested. Thank you!

If you use the value of 0.0005, it will give correct results only in parities with a pip value of 0.0001. such as for example EURUSD USDCHF. However, if you use GBPJPY parity, an error occurs. But if you use 50*Point, you will add or decrease 5 pips in all parities.

 
Mehmet Bastem:

If you use the value of 0.0005, it will give correct results only in parities with a pip value of 0.0001. such as for example EURUSD USDCHF. However, if you use GBPJPY parity, an error occurs. But if you use 50*Point, you will add or decrease 5 pips in all parities.

I understand the purpose of using 50*Point now. Thank you!
 
Mohsen Bjp:

i modify ur expert and define some new variables

u need no new function for such expert

only consider that you should use ecn account at least cause of using such near stoploss!

i designed that for 40 instead of 5 points

and default is openin buy positions but u can change that for sell or both at a same time

u can change that in input part when u want to run the expert

i attach code so u can use for ur next ea

Sorry for the delayed response. I have been trying to configure this website to send me notifications, but have had no such luck. What benefit do you feel an ECN account would bring in regards to the stop loss?

Thank you for making these changes!

 
Nicholas Quentin Martin:

Sorry for the delayed response. I have been trying to configure this website to send me notifications, but have had no such luck. What benefit do you feel an ECN account would bring in regards to the stop loss?

Thank you for making these changes!

stoplevel is so tight at ecn type 

and some brokers have much more stoplevel than normal

and when you set your stoplevel near current price it causes error

Reason: