error EA when run

To add comments, please log in or register
xinbye
9
xinbye  

hello, My EA auto buy or sell on Gold terminal. When orderbuy or ordersell is close, the lots is higher lots orderbuy or odrersell . I don't know why Max lots orderbuy or ordersell  EA can create is 0.02. How can i to get a lots (0.04,0.08...) Thanks

This is my EA

//+------------------------------------------------------------------+ 
//|                                                 Experts test.mq4 | 
//|                        Copyright 2017, MetaQuotes Software Corp. | 
//|                                             https://www.mql5.com | 
//+------------------------------------------------------------------+ 
#property copyright "Copyright 2017, MetaQuotes Software Corp." 
#property link      "https://www.mql5.com" 
#property version   "1.00" 
#property strict 
 
 
extern double pointbuy = 1290; 

//+------------------------------------------------------------------+ 
//| Expert initialization function                                   | 
//+------------------------------------------------------------------+ 
int OnInit() 
  { 
//--- 
 
//--- 
   return(INIT_SUCCEEDED); 
  } 
//+------------------------------------------------------------------+ 
//| Expert deinitialization function                                 | 
//+------------------------------------------------------------------+ 
void OnDeinit(const int reason) 
  { 
//--- 
    
  } 
//+------------------------------------------------------------------+ 
//| Expert tick function                                             | 
//+------------------------------------------------------------------+ 
void OnTick() 
  { 
//--- 
   string sym = "Gold"; 
   int cmdbuy = OP_BUY; 
   int cmdsell = OP_SELL; 
   double lot = 0.01; //lot 
   double b = 5.11; // check lot 
   double c = 2; // x lot 
   double buy = Ask; 
   double sell = Bid; 
   double stoploss_ask = Ask - 5; 
   double stoploss_bid = Ask + 5; 
   double takepropit_ask = Ask + 5; 
   double takepropit_bid = Bid - 5; 
   int magic = 155; 
   Comment(" phien ban 1"); 
   
  while(lot < b) 
   { 
       while( Ask > pointbuy && OrdersTotal()==0) 
       { 
        int newbuy = OrderSend(sym,cmdbuy,lot,buy,NULL,stoploss_ask,takepropit_ask,NULL,magic,NULL,SYMBOL_ARROWUP);  
            if(  OrdersTotal()==0) continue; 
            lot=lot*c; 
            Comment ("LOT "+ (string)lot) ; 
        } 
       while( Bid < pointbuy && OrdersTotal()==0) 
       { 
         int newsell = OrderSend(sym,cmdsell,lot,sell,NULL,stoploss_bid,takepropit_bid,NULL,magic,NULL,SYMBOL_ARROWDOWN); 
         if( OrdersTotal()==0) continue; 
            lot=lot*c; 
            Comment ("LOT "+ (string)lot) ; 
       } 
      
      } 
  } 
//+------------------------------------------------------------------+ 
Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
Choose a suitable trading strategy and subscribe to it with a few clicks. All Signals are provided with detailed statistics and informative charts. Become a trading signal provider and sell subscriptions to thousands of traders around the world. With the Signals service, your successful strategy can generate income with a small start-up budget...
William Roeder
22428
William Roeder  
xinbye: When orderbuy or ordersell is close, the lots is higher lots orderbuy or odrersell . I don't know why Max lots orderbuy or ordersell  EA can create is 0.02. How can i to get a lots (0.04,0.08...)
  1. When you post code please use the SRC button! Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  3. Your post is almost unintelligible. If you are using mechanical translation, you must use simple language structure.

  4. double buy = Ask;
    int newbuy = OrderSend(sym,cmdbuy,lot,buy,NULL,stoploss_ask,takepropit_ask,NULL,magic,NULL,SYMBOL_ARROWUP);  
    Your code loops forever without a Sleep and without a RefreshRates. Therefor Bid/Ask will not be current and your OrderSend fails. Check your return codes for errors and report them.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

  5. What color is SYMBOL_ARROWUP?
              OrderSend - Trade Functions - MQL4 Reference

  6. Same as Martingale: Martingale, guaranteed to blow your account eventually.
xinbye
9
xinbye  
whroeder1:
  1. When you post code please use the SRC button! Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  3. Your post is almost unintelligible. If you are using mechanical translation, you must use simple language structure.

  4. Your code loops forever without a Sleep and without a RefreshRates. Therefor Bid/Ask will not be current and your OrderSend fails. Check your return codes for errors and report them.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

  5. What color is SYMBOL_ARROWUP?
              OrderSend - Trade Functions - MQL4 Reference

  6. Same as Martingale: Martingale, guaranteed to blow your account eventually.

Hello, 

2. I don't know, forum mt5 and mt4 is difference. I think it's one Next time i'll post in the correct place :)

3. I will try to improve english :)

4. i have update code: it not error when compile,  i am testing and see you soon :) 

Thanks for helps.


To add comments, please log in or register