Print answer wrong

To add comments, please log in or register
Oliver Podolak
134
Oliver Podolak  

Hello,

I place an Order, but I get the Wrong Order open time. Can someone tell me, where the error is?

Error

My code:

if( OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,(Bid-0.0003),NULL,0,0,Red))
               {
               Print("SELL order opened : ",OrderOpenTime());
               delTimeOpen( cnt );
               }
            else
               Print("Error opening SELL order : ",GetLastError());
thank you :)
William Roeder
20233
William Roeder  
Oliver Podolak: I get the Wrong Order open time.
               Print("SELL order opened : ",OrderOpenTime());
  1. Why did you post your MT4 question in the Root / MT5 General 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.

  2. You can not use any Trade Functions until you select an order.
Oliver Podolak
134
Oliver Podolak  
whroeder1:
  1. Why did you post your MT4 question in the Root / MT5 General 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.

  2. You can not use any Trade Functions until you select an order.

Now I changed the bot a little and selected the Order, but it still doesn't print the right OrderOpenTime. Can you tell me what I did wrong now? Thanks!

This is the code:

#property strict
int buyTicket;
int counter = 1;
double price;
void Ontick)=
  {
   if(counter == 1)
   {
   buyTicket = OrderSend(_Symbol,OP_BUY,0.01,Ask,3,0,0,NULL,0,0,Blue);
   price = OrderOpenPrice();
   counter = 0;
   }

   OrderSelect(buyTicket,SELECT_BY_POS,MODE_TRADES);
      Print("Order Open Price: ",OrderOpenPrice());     
  }
//+------------------------------------------------------------------+

It prints that:


William Roeder
20233
William Roeder  
  1. Oliver Podolak:but it still doesn't print the right OrderOpenTime. Can you tell me what I did wrong now?
    You're not printing it.

  2. price = OrderOpenPrice();
    What part of "You can not use any Trade Functions until you select an order," was unclear?

  3. Check your return codes (OrderSend, OrderSelect) 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.

  4. What position is buyTicket?
Oliver Podolak
134
Oliver Podolak  
whroeder1:
  1. You're not printing it.

  2. What part of "You can not use any Trade Functions until you select an order," was unclear?

  3. Check your return codes (OrderSend, OrderSelect) 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.

  4. What position is buyTicket?
Thank you very much. Now it works :)
To add comments, please log in or register