Logic help

 

I've searched for ordermodify error 1 but it still hasn't helped. The system keeps giving me order modify error 1 but there seems to be no logical reason...

if(OrderType()== OP_SELL && Bid < SOOP30)
                   {                                                                 
                      switch(trailsequencer)
                         {                              
                            case 1 :                      
                                while(Bid > SOOP60 && OrdersTotal() > 0 && ma1 != ma1p)
                                 {
                                 checkstop1();
                                 }                                 
                            trailsequencer++;
                            break;    
 

SOOP30=  OrderOpenPrice() + 30*Point; 
SOOP60=  OrderOpenPrice() - 60*Point;

ma1            = iMA(NULL, 0, MA1, 0, MODE_EMA, PRICE_CLOSE,0);
ma2            = iMA(NULL, 0, MA2, 0, MODE_EMA, PRICE_CLOSE,0);
ma3            = iMA(NULL, 0, MA3, 0, MODE_EMA, PRICE_CLOSE,0);

ma1p           = iMA(NULL, 0, MA1, 0, MODE_EMA, PRICE_CLOSE,1);
ma2p           = iMA(NULL, 0, MA2, 0, MODE_EMA, PRICE_CLOSE,1);
ma3p           = iMA(NULL, 0, MA3, 0, MODE_EMA, PRICE_CLOSE,1);



void checkstop1()
{

if(NormalizeDouble(ma3,4) != NormalizeDouble(OrderStopLoss(),4))
   {                                  
   OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(ma3,4), OrderTakeProfit(),0,Blue);   
                            
   Print("stoploss",DoubleToStr(OrderStopLoss(),Digits));
   Print("ma3",DoubleToStr(ma3,Digits));
   Sleep(5000);
   }
}
 

Not enough to normalize your stop, you have to check how close your stop to Ask or Bid

 
Roger wrote >>

Not enough to normalize your stop, you have to check how close your stop to Ask or Bid

ma3 is very far from the market (its a 55 period ma)

 
Bauer_Boy wrote >>

ma3 is very far from the market (its a 55 period ma)

So, you print ma3 and stoploss, show us results.

 

2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: ma31.4034
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: stoploss1.3898
2009.09.16 08:03:05 2009.01.02 10:02 NEW_Code Test 4_Working Lebeaus MA POS SIZE EURUSD,H1: OrderModify error 1

 

Try replacing your conditional with the following.


CB

if (NormalizeDouble(ma3 - OrderStopLoss(), 8) == 0)

 

CB:

Thanks for the suggestion but still no luck. I feel like i've tried everything, i've tried having the conditional nested within the while() and have recently moved to having it in a function with still no luck.

 

Sorry - should have posted:

if (NormalizeDouble(ma3 - OrderStopLoss(), 8) != 0)


CB

 
I assumed thats what you meant and tried it without luck
 
Bauer_Boy:
I assumed thats what you meant and tried it without luck

Ok.


Assumption:

- Error 1 is caused due to all parameters issued in OrderModify() being identical to those already associated with the existing order.


So potential cause is either:

- Difference between the methodology between the 2 comparisons ie. yours vs. MT4 internal - invoked by OrderModify()

or

- One of (or both) the numbers have changed from one comparison to the other.


Does that seem sound?


CB

 

OK, next step. Reaplace

void checkstop1()
{

if(NormalizeDouble(ma3,4) != NormalizeDouble(OrderStopLoss(),4))
   {                                  
   OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(ma3,4), OrderTakeProfit(),0,Blue);   
                            
   Print("stoploss",DoubleToStr(OrderStopLoss(),Digits));
   Print("ma3",DoubleToStr(ma3,Digits));
   Sleep(5000);
   }
}

to

void checkstop1()
{

if(NormalizeDouble(ma3,4) != NormalizeDouble(OrderStopLoss(),4))
   {                                  
   Print("Bid - ",MarketInfo(OrderSymbol(),MODE_BID)," type - ",OrderType()," stop - ",OrderStopLoss()," newstop - ",ma3);
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(ma3,4), OrderTakeProfit(),0,Blue);   
                            
   //Print("stoploss",DoubleToStr(OrderStopLoss(),Digits));
   //Print("ma3",DoubleToStr(ma3,Digits));
   Sleep(5000);
   }
}

and show us.

Reason: