"invalid price for OrderSend function,OrderSend error 4107."How to fix these errors?

To add comments, please log in or register
Jun Feng
362
Jun Feng  

The following is the code:

if(distance<MarketInfo(Symbol(),MODE_STOPLEVEL)+5)distance=MarketInfo(Symbol(),MODE_STOPLEVEL)+5;

if(CheckMoneyForTrade(Symbol(),startposition,OP_BUY)==true&&IsNewOrderAllowed()==true)

     {

     if(open=!OrderSend(Symbol(),OP_BUYSTOP,NormalizeDouble(startposition,2),NormalizeDouble(Ask+distance*MarketInfo(Symbol(),MODE_TICKSIZE),Digits),50,0,0,"The seed of a big tree",Magiccode,0,clrNONE))

     Print("OrderSend error ",GetLastError());

     }


The MT4 of my own computer can be tested and run without errors.But sending MQL5 backstage tests always feedback these two errors:"invalid price for OrderSend function,OrderSend error 4107",I don't know what's going on,Please give me a finger,Thanks.

whroeder1
17945
whroeder1  
  1. Jun Feng: Please give me a finger
    OK Finger

  2. And a SL of 50 is probably above your startposition.

  3. if(open=!OrderSend
    What is open and why are you compare it to a ticket or -1?
Jun Feng
362
Jun Feng  
whroeder1:
  1. OK

  2. And a SL of 50 is probably above your startposition.

  3. What is open and why are you compare it to a ticket or -1?

Thank you for your finger。but "50" is  the Maximum price slippage,"open=!OrderSend" is an Another expression for orders.Can you give me another finger?

Anthony Garot
1821
Anthony Garot  

I spit up my coffee laughing when I saw this picture of the finger!

whroeder1
17945
whroeder1  
Jun Feng: but "50" is  the Maximum price slippage

I misread that long line. Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling (or moving my eyes) back and forth trying to read it.

Finger


Check your return codes for errors, report them and you would know why. Don't just silence the compiler, it is trying to help you.
          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
Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.
To add comments, please log in or register