Download MetaTrader 5
To add comments, please log in or register
Do you want to become a well-known developer? Execute the orders of traders in the Freelance service!
mark
9
mark 2015.01.09 13:42 

I try to open order with OrderSend function. But it makes error code 136

 

Code that i use 

 

void OnStart()

  {

//---/--- get minimum stop level

  double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);

   Print("Minimum Stop Level=",minstoplevel," points");

   double price=Ask;

//--- calculated SL and TP prices must be normalized

   double stoploss=NormalizeDouble(Bid-10*Point,Digits);

   double takeprofit=NormalizeDouble(Bid+10*Point,Digits);

   Print("price ", price);

   Print("stoploss ", stoploss);

   Print("takeprof ", takeprofit);

   Print("Ask ",Ask);

   Print("Bid ", Bid);

//--- place market order to buy 1 lot

   int ticket=OrderSend("USDCHF",OP_BUY,1,price,1000,stoploss,takeprofit,"My order",16384,0,clrGreen);

 Print("ticket ", ticket);

   if(ticket<0)

     {

      Print("OrderSend failed with error #",GetLastError());

     }

   else

      Print("OrderSend placed successfully");


  

   

  } 

 

Any assistance will be appriciated 

Carl Schreiber
5952
Carl Schreiber 2015.01.09 14:02  

1) use the SRC-button to post code (beside the camera!)

2) Do you know what error 136 means. It tells you where to search for a correction! (Look it up in the MQL4 Reference)

mark
9
mark 2015.01.09 14:53  
It said off quotes. But how to make work this function. I'm very new. Please assist on this issue
Carl Schreiber
5952
Carl Schreiber 2015.01.09 16:28  

Read the book or the Documentation (links at the top!).

Look for the examples of opening orders.

Study the sample EAs in the Expert folder how they set their prices for OrderSend(..)

Search for other examples...

whroeder1
13620
whroeder1 2015.01.09 17:39  
You are mixing apples and oranges. Ask/Bid are the current chart pair but you are opening a USDCHF pair. Fails if the current chart is not USDCHF
   double price=Ask;
:
// int ticket=OrderSend("USDCHF",OP_BUY,1,price, ...
   int ticket=OrderSend(NULL,    OP_BUY,1,price,
/
To add comments, please log in or register