EA dosnt work at real time

 

hi

i run my EA at real account  at MQL4 and the EA dosnt make a trade when he wes should ( this is my first time that i run any EA at real time )

i run the EA at back test and he made the trade 


the "Auto trading " and "Allow live trading "  is on 

also , there is happy smiling at the top right corner


also , i worte a quote that give me outpot if there is any error with the ordersend and i didnt get any error or alert


there is any option that i need to change at metatrader platform  ? again at back test its work


the send order quote 


ordershort=OrderSend(NULL,OP_SELL,optimallotsize(percentloss,Bid,stoplossshort),Bid,20,stoplossshort,takeprofitshort,NULL,magicNMshort);
      
if(ordershort<0)
      {
         Alert("order faild error = " + GetLastError());
      }
      else
      {
         Alert("order was sent");
      }
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
, then each symbol positions will be closed in the same order, in which they are opened, starting with the oldest one. In case of an attempt to close positions in a different order, the trader will receive an appropriate error. There are several types of accounts that can be opened on a trade server. The type of account on which an MQL5 program...
 
  1. nati2009: i run my EA at real account  at MQL4 and the EA dosnt make a trade when he wes should (

    That is because it is broken.

  2. ordershort=OrderSend(NULL,OP_SELL,optimall…

    Be careful with NULL.

    1. On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
    2. Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
    3. Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
    4. MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
    5. Cloud Protector Bug? - MQL4 programming forum 2020.07.25
 

Thank you for your answer

soo every place that i worth "NULL" i need to change to "_Symbol" and every place i worth "0" i need to change to "_Period" ?

why at the back test its was work good despite i worth "NULL" and " 0 " 

 
nati2009:

also , i wrote a quote that give me outpot if there is any error with the ordersend and i didnt get any error or alert

ordershort=OrderSend(NULL,OP_SELL,optimallotsize(percentloss,Bid,stoplossshort),Bid,20,stoplossshort,takeprofitshort,NULL,magicNMshort);
      
if(ordershort<0)
      {
         Alert("order faild error = " + GetLastError());
      }
      else
      {
         Alert("order was sent");
      }


IF you are not getting any alert then obviously the OrderSend() is not being executed.

You should check the conditions that should execute the above block of code

 
Keith Watford:

IF you are not getting any alert then obviously the OrderSend() is not being executed.

You should check the conditions that should execute the above block of code

All the conditions above the block  was ok

as i said, i check this trade with back test and the trade was  executed

 
nati2009:

All the conditions above the block  was ok

as i said, i check this trade with back test and the trade was  executed

No they are not.

 
Keith Watford:

No they are not.

so i ask again

why at the back test the trade was  executed and at the real time is not ?


to only reason i see its like the previos commant was that i use "NULL" insted " _Symbol" 

 
someone please
nati2009:

so i ask again

why at the back test the trade was  executed and at the real time is not ?


to only reason i see its like the previos commant was that i use "NULL" insted " _Symbol" 

 

someone have answer please ?

 
nati2009: someone have answer please ?

"Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
     How To Ask Questions The Smart Way. 2004
          When asking about code

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.

Always post all relevant code.
     How To Ask Questions The Smart Way. 2004
          Be precise and informative about your problem

We can't see your broken code.

Fix your broken code.

With the information you've provided — we can only guess. And you haven't provided any useful information for that.

 
William Roeder:

"Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
     How To Ask Questions The Smart Way. 2004
          When asking about code

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.

Always post all relevant code.
     How To Ask Questions The Smart Way. 2004
          Be precise and informative about your problem

We can't see your broken code.

Fix your broken code.

With the information you've provided — we can only guess. And you haven't provided any useful information for that.


What i ask is there any familiar reason why at back test the EA make trade and at real time it dosent make any trade ? maybe something at the options ? 

as i said before i 

the "Auto trading " and "Allow live trading "  is on 

also , there is happy smiling at the top right corner ( As i know that mean that the EA allowed to work)

 
nati2009:


What i ask is there any familiar reason why at back test the EA make trade and at real time it dosent make any trade ? maybe something at the options ? 

as i said before i 

the "Auto trading " and "Allow live trading "  is on 

also , there is happy smiling at the top right corner ( As i know that mean that the EA allowed to work)

Hi Nati2009,

I had the same issue with one of my accounts only to find out that my Broker blocked my account from using Expert Advisors.

Use the following code to see if you are allowed to use an expert advisor on your account.

bool AccountTradeExpert = AccountInfoInteger (ACCOUNT_TRADE_EXPERT);//Is Expert Advisor allowed on my account true/false?
Comment ("Is EA allowed:",AccountTradeExpert);
Reason: