OrderSend() not executing - page 2

 
deVries :


i told you already the problem


Sorry deVries. You lost me here. The code must close all open Long trades. I am not using magicnumbers and the Tally is only used to determine the lot size when opening trades. Maybe I am missing what you are trying to explain.

Once again, thanks for the help.

 
Sjarko : I have removed all the code except the OrderSend code and the exception handling. Still nothing, no message, not even in the Journal.
You DO NOT HAVE any exception handling in your post. Check your return codes and Print them in the journal.
 
WHRoeder :
You DO NOT HAVE any exception handling in your post. Check your return codes and Print them in the journal.

Hi WHRoeder,

Sorry I was very vague in my previous post. What I meant was that I removed all other code except the OrderSend() instruction and ADDED exception handling. This is how the complete code look like:

int init()
   {
   }
 
//--------------------------------------------------------------------
int start()  
  {   
   //--------------------------------------------------------------- 4 --   
      // Trading criteria 
 
   static datetime lastbar = 0;
   datetime curbar = Time[0];
   if(lastbar!=curbar)
      {
         Comment("Starting");
         int TicketNumber;
 
         TicketNumber = OrderSend(Symbol(),OP_SELL,0.01,Bid,30,0,0,NULL,0,0,Red);
 
         if( TicketNumber > 0 )
         {
            Print("Order placed # ", TicketNumber);
            Comment("SUCCESS !!");
         }
         else
         {
            Print("Order Send failed, error # ", GetLastError() );
         }                
 
      }
      
      lastbar=curbar;
 
}  
 
 
 

Screen print

I added the Comment "Starting" just to make sure that the program does in fact execute and also that it executes within the "if" statement. I made a print screen of the results and as can be seen the comment is displayed within the chart and as can be seen in the Journal tab, there is absolutely nothing. It is as if the OrderSend does not run at all.

 
Sjarko :

Hi WHRoeder,

Sorry I was very vague in my previous post. What I meant was that I removed all other code except the OrderSend() instruction and ADDED exception handling. This is how the complete code look like:

I added the Comment "Starting" just to make sure that the program does in fact execute and also that it executes within the "if" statement. I made a print screen of the results and as can be seen the comment is displayed within the chart and as can be seen in the Journal tab, there is absolutely nothing. It is as if the OrderSend does not run at all.

Don't use Comment(), it is easy to get fooled by it . . . OK it says Starting on the chart but is that from the current run or from an older version of the code ? do you clear the comment in deinit() ? use Print() then you can see the information sequentially and contemporaneously.

Please change your Comment() to a Print(), re-run the EA and post the expert log file . . .

 
RaptorUK :

Don't use Comment(), it is easy to get fooled by it . . . OK it says Starting on the chart but is that from the current run or from an older version of the code ? do you clear the comment in deinit() ? use Print() then you can see the information sequentially and contemporaneously.

Please change your Comment() to a Print(), re-run the EA and post the expert log file . . .

I found the problem. It had to do with the lot size. Thanks all for your help. I got some good tips here that improved my other code, such as the correct way to close all open trades and how to do good exception handling.

Many thanks.

Reason: