can't make trades

 

Hi all !

I've recently reinstalled MT-4 platform and for some reason my EA stopped executing trades, although It has worked before

when the EA tries to make a trade, I get the following messages:

I've enabled live trading

here is the code:

//+------------------------------------------------------------------+
//|                                                EURUSD trader.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "sergey antipin"
#property link      "http://www.metaquotes.net"



extern double buffer=0;           
extern double stoploss=20;            
extern double takeprofit=350;                
extern double filter=50;               
extern double ma_value=218;  
double max_account_balance=0;
double max_spread=4;   
extern double Z=1;
bool price_above=false;


double M=1;  // risk 

bool trade_ok=true;
int ticket1=-1;


//------------------------------------------------------------------------------------------------~~~~~~!!!!!!!!!!!!!!!!






//------------------------------------------------------------------------------------------------~~~~~~!!!!!!!!!!!!!!!!

     
double entryprice=0;
//++++ These are adjusted for 5 digit brokers.
int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)

int     init(){
    if (Digits == 5 || Digits == 3)
    {    // Adjust for five (5) digit brokers.
                pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
    } 
    else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    
    
if (Bid>iMA(Symbol(),15,ma_value,0,MODE_SMA,PRICE_TYPICAL,0))
price_above=true;
else
price_above=false;
}



int deinit()
  {
   return(0);
  }
  
  
  
  
int start()
  {
  
//Alert(price_above);
  

double SMA_10day=iMA(Symbol(),15,ma_value,0,MODE_SMA,PRICE_TYPICAL,0);  //  simple ma_value day moving average value 
double ATR=iATR(Symbol(),60,200,0);


//-----risk management

M=(AccountBalance()*0.005*Z)/(0.1*stoploss) ;  // x% risk per trade

if (M<1) M=1;




if (AccountBalance()>max_account_balance)
max_account_balance=AccountBalance();

//-----end of risk



//---------------- open new trades



//--- * short trade




if  (trade_ok)

{

if ( ( Bid- SMA_10day  < buffer* pips2dbl ) && (price_above) && (ATR<40*pips2dbl) )     
  
  {  

     ticket1=-1;
     
   Alert(MarketInfo(Symbol(),MODE_ASK)-MarketInfo(Symbol(),MODE_BID),"short trade"," atr=", ATR);
      
    
      while (Ask-Bid < max_spread* pips2dbl) //spread < 4

     {
  
     RefreshRates();
     ticket1 = OrderSend(Symbol() , OP_SELL , 0.01*M , Bid , 2*pips2points , 0 ,0); 

     Sleep(2000);

     if (ticket1>0)
     { 
     Alert("short-trade");
     Sleep(2000);
     OrderModify(ticket1,Bid,Ask+stoploss* pips2dbl , Ask-takeprofit* pips2dbl,0,White);
      Sleep(2000);
     entryprice=Bid; 
     break;
     }
     else
     GetLastError();
     }

trade_ok=false; 

  }
  
    //--- * end of short trade
     
     else 
     
    
       
//--- * long trade

if ( ( SMA_10day -  Ask < buffer* pips2dbl ) && (!price_above) && (ATR<40*pips2dbl))     
  
  {   
  
          Alert(MarketInfo(Symbol(),MODE_ASK)-MarketInfo(Symbol(),MODE_BID),"long trade"," atr=", ATR,price_above);
     ticket1=-1;
     

     

     while (Ask-Bid<max_spread* pips2dbl) //spread < 4

     {

     RefreshRates();     
     ticket1 = OrderSend(Symbol() , OP_BUY , 0.01*M , Ask , 2*pips2points , 0 , 0);
     
     Sleep(2000);
     if (ticket1>0)
     {
     Alert("long-trade");
     Sleep(2000);
     OrderModify(ticket1,Ask,Bid-stoploss* pips2dbl , Bid+takeprofit* pips2dbl,0,White);
      Sleep(2000);
     entryprice=Ask;
     break;
     } 
     else
     GetLastError();
     }
     

     trade_ok=false;    
  }

//--- * end of long trade
  
}
  
  
  

//---- end of open new trades






//-----x pip noice filter
          
       if (!trade_ok)
      {
         if  (price_above)  //-- price currently above 
           
           {
                if (Bid < entryprice - filter* pips2dbl)       //-- price moved below and is not random noice
                
                  {
                       price_above=false;
                       trade_ok=true;
                  }
                  
                  
              else
              
               
                if (Ask > entryprice + filter* pips2dbl)     //-- price stayed above and is not random noice
                   trade_ok=true;
               
           }

      else


         if (!price_above)  //-- price currently below
  
           {

                if (Ask > entryprice + filter* pips2dbl)  //-- price moved above and is not random noice
  
                  {
                      price_above=true;
                      trade_ok=true; 
                  }   
   
             else
               
               if (Bid < entryprice - filter* pips2dbl)  //-- price stayed below and is not random noice
               trade_ok=true;
          
           }
        }   
  
  //----- end of filter
  
  
   return(0);
  }
  

please help !

 
sergeyrar:

Hi all !

I've recently reinstalled MT-4 platform and for some reason my EA stopped executing trades, although It has worked before

when the EA tries to make a trade, I get the following messages:

I've enabled live trading

here is the code:

please help !

Install MT from other broker, see if your EA still working.

BTW, there's no need for sleep (2000) after OrderSend(), you don't have to use that sleep().

:D

 

OK, you get the last error and do what with it ? nothing, what is the point . . . you need to understand the code you are copying and pasting together . . .

else
     GetLastError();
     }

Read this carefully, understand it, apply what you learn to the code you have posted above: https://www.mql5.com/en/forum/139592

 
What's the build of your 'just re-installed' MT. Update it to last version, this June MT build below 416 won't be able to connect to server and thus trade is disable, Some broker may already blocked it.
 
sergeyrar:

when the EA tries to make a trade, I get the following messages:

I've enabled live trading

Does your Broker allow EAs ? there are some that do not.
 
RaptorUK:

OK, you get the last error and do what with it ? nothing, what is the point . . . you need to understand the code you are copying and pasting together . . .

Read this carefully, understand it, apply what you learn to the code you have posted above: https://www.mql5.com/en/forum/139592


hello

thanks for the advice

but I don't get any error number.. I get nothing..

 
sergeyrar:


hello

thanks for the advice

but I don't get any error number.. I get nothing..

If you have no Print statement then you will get nothing . . . did you bother to read the post I gave a link to ?

Perhaps you can answer my question ?

"OK, you get the last error and do what with it ? nothing, what is the point ? "

If you want to be able to write meaningful code you need to be able to think . . .

 
RaptorUK:

If you have no Print statement then you will get nothing . . . did you bother to read the post I gave a link to ?

Perhaps you can answer my question ?

"OK, you get the last error and do what with it ? nothing, what is the point ? "

If you want to be able to write meaningful code you need to be able to think . . .


I can think..

give me a router and I do wonders with it

I forgot how to write programs.. it was just a hobby of mine long time ago

thanks for the help

 
sergeyrar:


I can think..

give me a router and I do wonders with it

Cool . . can you tell me how to get my Cisco WRVS4400N to synchronise it's time to my internal time server (both on the same IP range) ? I don't use the WAN port on the WRVS at all . . .
 
sergeyrar:
I've recently reinstalled MT-4 platform and for some reason my EA stopped executing trades, although It has worked before
here is the code:
sergeyrar:
I can think..

Apparently not. If it use to work, you haven't changed the code, then the problem is NOT the code, but you posted it anyway.

Trading Disabled is a setting problem, not a code problem.

  1. Do you have a smiley face on the chart.
  2. Did you set options -> experts.
  3. Using tester? ex prop -> testing -> positions = long & short
  4. Did you install in \program files* on Vista/Win7
 

MOV Converter

MOV Converter is specially designed for users to convert MOV files to other video formats, via it, we can convert MOV to AVI, MPEG, 3GP, WMV. M4V, DivX, XviD, ASF, WMV, MPEG-1, MPEG-2, 3GP, 3GPP, MKV, FLV, SWF, etc formats. Before converting videos, you can conveniently set video effects, adjust video brightness, saturation, contrast, join several videos to one file, trim any segment of your video exactly.