OrderModify Error 0

To add comments, please log in or register
lancastersteve
46
lancastersteve  
void rolLongStopA()
   {
   

   
   
   for(int b=OrdersTotal()-1; b>=0; b--)
      {
      bool LongA;
      
      if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
         if(OrderMagicNumber()==Magic)
               if(OrderType()==OP_BUY)
                  if(Bid>OrderOpenPrice()+x1*(OrderOpenPrice()-OrderStopLoss()))
                      LongA= OrderModify(OrderTicket(),ND(OrderOpenPrice()),ND(OrderStopLoss()+x1*(OrderOpenPrice()-OrderStopLoss())),ND(OrderTakeProfit()),0,clrPurple);       
                     
                           if(!LongA) Print("Error modifying LongStopA", GetLastError()); else Print("LongStopA rolled to ", OrderStopLoss());      
                           rolLongA=false;
                           rolLongB=true;
                           rolShortA=false;
                           rolShortB=false;
                           
       }
       
    }

Hi

Can anyone see any reason why the above OrderModify is generating an error zero? The Order Modify is trying to move the stop loss  of the open position, and it's definitely not doing it. I just can't see why as error 0 code is not that helpful when I have looked it up in the reference manual



Apologies, I thought I'd included it. x1= 0.5 at the moment, I've tried a couple of different numbers though.

Thanks

Keith Watford
Moderator
19342
Keith Watford  
lancastersteve:

Hi

Can anyone see any reason why the above OrderModify is generating an error zero? The Order Modify is trying to move the stop loss  of the open position, and it's definitely not doing it. I just can't see why as error 0 code is not that helpful when I have looked it up in the reference manual

Thanks

Show your code so people may be able to help you.

Do you check that the new SL is different to the old SL?

William Roeder
20070
William Roeder  
  1. Did you bother to look up error 0?

  2. Check your return codes for errors, and report them including GLE/LE. Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
lancastersteve
46
lancastersteve  

Yes, I looked up error 0. According to the error Appendix it's ERR_NO_ERROR (i.e no error returned). But, the stop is definitely not moving when it should.

The error does not occur in Compiler, it occurs when attach to a chart in Tester. Prints on the Journals tab.

William Roeder
20070
William Roeder  
if(Bid>OrderOpenPrice()+x1*(OrderOpenPrice()-OrderStopLoss()))   LongA= OrderModify(…);
if(!LongA) Print("Error modifying LongStopA", GetLastError()); else Print("LongStopA rolled to ", OrderStopLoss());      

Now that you have posted your code, remember I said "don't look at LE unless you have an error"

Your code looks at it even if you don't call OrderModify.

tickfenix
99
tickfenix  
lancastersteve:

Hi

Can anyone see any reason why the above OrderModify is generating an error zero? The Order Modify is trying to move the stop loss  of the open position, and it's definitely not doing it. I just can't see why as error 0 code is not that helpful when I have looked it up in the reference manual



Apologies, I thought I'd included it. x1= 0.5 at the moment, I've tried a couple of different numbers though.

Thanks

void rolLongStopA()
   {
   

   
   
   for(int b=OrdersTotal()-1; b>=0; b--)
      {
      bool LongA;
      
      if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
         if(OrderMagicNumber()==Magic)
               if(OrderType()==OP_BUY)
                  if(Bid>OrderOpenPrice()+x1*(OrderOpenPrice()-OrderStopLoss()))
		
                      LongA= OrderModify(OrderTicket(),ND(OrderOpenPrice()),ND(OrderStopLoss()+x1*(OrderOpenPrice()-OrderStopLoss())),ND(OrderTakeProfit()),0,clrPurple);       
                     
                           if(!LongA) Print("Error modifying LongStopA", GetLastError()); else Print("LongStopA rolled to ", OrderStopLoss());      
                           rolLongA=false;
                           rolLongB=true;
                           rolShortA=false;
                           rolShortB=false;
		
                           
       }
       
    }
lancastersteve
46
lancastersteve  
tickfenix:
Great help, thank! can't believe I missed that.
To add comments, please log in or register