Learning to Automate Trade

To add comments, please log in or register
bdelphia
14
bdelphia  
Hello, I am just starting to experiment in mql5 and I am still learning but I get an error in this code in price which doesn't make sense since it should just buy the symbol at whatever price as long as there is not an open order. If you could help me understand what is going on that would help me a lot. Thanks
#include <Trade\Trade.mqh>
void OnTick()
  { 
  //Declare an initialize the trade request and result of trade request
   MqlTradeRequest request;
   MqlTradeResult result;
   ZeroMemory(request);
   //Defining of the Trade request
   request.action    =TRADE_ACTION_DEAL;
   request.type      =ORDER_TYPE_BUY;
   request.symbol    =Symbol();
   request.volume     =0.01;
   request.type_filling     =ORDER_FILLING_FOK
   request.price =SymbolInfoDouble(Symbol(),SYMBOL_ASK);
   request.tp      =0;
   request.deviation     =50;
   
   //If variable action based on content
if (!PositionSelect(_Symbol)) // If open Position does not exist
      {
      OrderSend (request,result);
      }
}
   
  
   
  
Seng Joo Thio
395
Seng Joo Thio  
bdelphia:
Hello, I am just starting to experiment in mql5 and I am still learning but I get an error in this code in price which doesn't make sense since it should just buy the symbol at whatever price as long as there is not an open order. If you could help me understand what is going on that would help me a lot. Thanks
   
  

Hi, this line, you need to end it with ';':

   request.type_filling     =ORDER_FILLING_FOK;

without ';', the compiler will not recognise that this line has ended, and will therefore give you an error in 'price' of the following line.

Liam Neeson
17
Liam Neeson  
As mentioned already the missing ;
bdelphia
14
bdelphia  
Okay Thank you
To add comments, please log in or register