Error 130 :S

 
Hi!

I created this EA for testing (an EA with fixed TP and trailing Stop Loss) but, for same reason, I’m receiving the error 130. Why!? What’s the problem!? The code is very very simple. There is none error!

Mladen, I bet that you will the 1st to help me, so, since now, thanks man!!! xDDD

Thx,

 

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(OrdersTotal()<2)
     {
      OrderSend(Symbol(),OP_BUY ,1,Ask,0,0,Bid+0.00050,"",0,0,clrNONE);
      OrderSend(Symbol(),OP_SELL,1,Bid,0,0,Ask-0.00050,"",0,0,clrNONE);
     };
  
  
  
    
  for(int i=0; i<OrdersTotal(); i++)
    {
     OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
          
          
     
     if(OrderType() == OP_BUY && (OrderOpenPrice()-Bid)>0.00100)
       {
        double SLBC = (OrderOpenPrice()-((50/100)*(OrderOpenPrice()-Bid)));
        double SLBF = MathMin(SLBC, OrderStopLoss());
        OrderModify(OrderTicket(), OrderLots(), SLBF, OrderTakeProfit(), OrderExpiration(), clrNONE);
       };
              
       
       
     if(OrderType() == OP_SELL && (Ask-OrderOpenPrice())>0.00100)
       {
        double SLSC = (OrderOpenPrice()+((50/100)*(Ask-OrderOpenPrice())));
        double SLSF = MathMax(SLSC, OrderStopLoss());
        OrderModify(OrderTicket(), OrderLots(), SLSF, OrderTakeProfit(), OrderExpiration(), clrNONE);
       };
    };
  
  
  
    
  }
//+------------------------------------------------------------------+

 

 
JHenry:
Hi!

I created this EA for testing (an EA with fixed TP and trailing Stop Loss) but, for same reason, I’m receiving the error 130. Why!? What’s the problem!? The code is very very simple. There is none error!

Mladen, I bet that you will the 1st to help me, so, since now, thanks man!!! xDDD

Thx,

 

 

Of course MLADEN is the first and last one able to help us all.

any way 130 error comes mostly cause because of invalid stop loss take profit in EAs.

case 130: return(pref+"INVALID STOPS"); "

here is list of errors number wise (reasons)

but moderators can better guide us :)

regards

--------------------------------------------------------------------------------------------------------

string fMyErDesc(int aErrNum){

   string pref="Err Num: "+aErrNum+" - ";
   switch(aErrNum){
      case 0: return(pref+"NO ERROR");
      case 1: return(pref+"NO RESULT");                                
      case 2: return(pref+"COMMON ERROR");                             
      case 3: return(pref+"INVALID TRADE PARAMETERS");                 
      case 4: return(pref+"SERVER BUSY");                              
      case 5: return(pref+"OLD VERSION");                              
      case 6: return(pref+"NO CONNECTION");                            
      case 7: return(pref+"NOT ENOUGH RIGHTS");                        
      case 8: return(pref+"TOO FREQUENT REQUESTS");                    
      case 9: return(pref+"MALFUNCTIONAL TRADE");                      
      case 64: return(pref+"ACCOUNT DISABLED");                        
      case 65: return(pref+"INVALID ACCOUNT");                         
      case 128: return(pref+"TRADE TIMEOUT");                          
      case 129: return(pref+"INVALID PRICE");                          
      case 130: return(pref+"INVALID STOPS");                          
      case 131: return(pref+"INVALID TRADE VOLUME");                   
      case 132: return(pref+"MARKET CLOSED");                          
      case 133: return(pref+"TRADE DISABLED");                         
      case 134: return(pref+"NOT ENOUGH MONEY");                       
      case 135: return(pref+"PRICE CHANGED");                          
      case 136: return(pref+"OFF QUOTES");                             
      case 137: return(pref+"BROKER BUSY");                            
      case 138: return(pref+"REQUOTE");                                
      case 139: return(pref+"ORDER LOCKED");                           
      case 140: return(pref+"LONG POSITIONS ONLY ALLOWED");            
      case 141: return(pref+"TOO MANY REQUESTS");                      
      case 145: return(pref+"TRADE MODIFY DENIED");                    
      case 146: return(pref+"TRADE CONTEXT BUSY");                     
      case 147: return(pref+"TRADE EXPIRATION DENIED");                
      case 148: return(pref+"TRADE TOO MANY ORDERS");                  
      //---- mql4 run time errors
      case 4000: return(pref+"NO MQLERROR");                           
      case 4001: return(pref+"WRONG FUNCTION POINTER");                
      case 4002: return(pref+"ARRAY INDEX OUT OF RANGE");              
      case 4003: return(pref+"NO MEMORY FOR FUNCTION CALL STACK");     
      case 4004: return(pref+"RECURSIVE STACK OVERFLOW");              
      case 4005: return(pref+"NOT ENOUGH STACK FOR PARAMETER");        
      case 4006: return(pref+"NO MEMORY FOR PARAMETER STRING");        
      case 4007: return(pref+"NO MEMORY FOR TEMP STRING");             
      case 4008: return(pref+"NOT INITIALIZED STRING");                
      case 4009: return(pref+"NOT INITIALIZED ARRAYSTRING");           
      case 4010: return(pref+"NO MEMORY FOR ARRAYSTRING");             
      case 4011: return(pref+"TOO LONG STRING");                       
      case 4012: return(pref+"REMAINDER FROM ZERO DIVIDE");            
      case 4013: return(pref+"ZERO DIVIDE");                           
      case 4014: return(pref+"UNKNOWN COMMAND");                       
      case 4015: return(pref+"WRONG JUMP");                            
      case 4016: return(pref+"NOT INITIALIZED ARRAY");                 
      case 4017: return(pref+"DLL CALLS NOT ALLOWED");                 
      case 4018: return(pref+"CANNOT LOAD LIBRARY");                   
      case 4019: return(pref+"CANNOT CALL FUNCTION");                  
      case 4020: return(pref+"EXTERNAL EXPERT CALLS NOT ALLOWED");     
      case 4021: return(pref+"NOT ENOUGH MEMORY FOR RETURNED STRING"); 
      case 4022: return(pref+"SYSTEM BUSY");                           
      case 4050: return(pref+"INVALID FUNCTION PARAMETERS COUNT");     
      case 4051: return(pref+"INVALID FUNCTION PARAMETER VALUE");      
      case 4052: return(pref+"STRING FUNCTION INTERNAL ERROR");        
      case 4053: return(pref+"SOME ARRAY ERROR");                      
      case 4054: return(pref+"INCORRECT SERIES ARRAY USING");          
      case 4055: return(pref+"CUSTOM INDICATOR ERROR");                
      case 4056: return(pref+"INCOMPATIBLE ARRAYS");                   
      case 4057: return(pref+"GLOBAL VARIABLES PROCESSING ERROR");     
      case 4058: return(pref+"GLOBAL VARIABLE NOT FOUND");             
      case 4059: return(pref+"FUNCTION NOT ALLOWED IN TESTING MODE");  
      case 4060: return(pref+"FUNCTION NOT CONFIRMED");                
      case 4061: return(pref+"SEND MAIL ERROR");                       
      case 4062: return(pref+"STRING PARAMETER EXPECTED");             
      case 4063: return(pref+"INTEGER PARAMETER EXPECTED");            
      case 4064: return(pref+"DOUBLE PARAMETER EXPECTED");             
      case 4065: return(pref+"ARRAY AS PARAMETER EXPECTED");           
      case 4066: return(pref+"HISTORY WILL UPDATED");                  
      case 4067: return(pref+"TRADE ERROR");                           
      case 4099: return(pref+"END OF FILE");                           
      case 4100: return(pref+"SOME FILE ERROR");                       
      case 4101: return(pref+"WRONG FILE NAME");                       
      case 4102: return(pref+"TOO MANY OPENED FILES");                 
      case 4103: return(pref+"CANNOT OPEN FILE");                      
      case 4104: return(pref+"INCOMPATIBLE ACCESS TO FILE");           
      case 4105: return(pref+"NO ORDER SELECTED");                     
      case 4106: return(pref+"UNKNOWN SYMBOL");                        
      case 4107: return(pref+"INVALID PRICE PARAM");                   
      case 4108: return(pref+"INVALID TICKET");                        
      case 4109: return(pref+"TRADE NOT ALLOWED");                     
      case 4110: return(pref+"LONGS  NOT ALLOWED");                    
      case 4111: return(pref+"SHORTS NOT ALLOWED");                    
      case 4200: return(pref+"OBJECT ALREADY EXISTS");                 
      case 4201: return(pref+"UNKNOWN OBJECT PROPERTY");               
      case 4202: return(pref+"OBJECT DOES NOT EXIST");                 
      case 4203: return(pref+"UNKNOWN OBJECT TYPE");                   
      case 4204: return(pref+"NO OBJECT NAME");                        
      case 4205: return(pref+"OBJECT COORDINATES ERROR");              
      case 4206: return(pref+"NO SPECIFIED SUBWINDOW");                
      case 4207: return(pref+"SOME OBJECT ERROR");   
      default: return(pref+"WRONG ERR NUM");               
   }



 

I modified the code, the OrderModify() for this:

OrderModify(OrderTicket(), OrderLots(), NormalizeDouble(SLBF, Digits), OrderTakeProfit(), OrderExpiration(), clrNONE);

 I added NormalizeDouble(), but, continues given the error 130. :S

 
JHenry:

I modified the code, the OrderModify() for this:

 I added NormalizeDouble(), but, continues given the error 130. :S

It is not about normalization

  1. Is your broker ECN/STP type of broker? If yes, in that case you have to add TA and / or SL in two steps
  2. In any case you have to check if TP and Sl are at least at "StopLevel" distance from the current price. Use the MarketInfo(_Symbol,MODE_STOPLEVEL) to check that
  3. Check your prices. I do not think that multiplication with 0.5 (the 50/100 part) will produce any usabe results
 
JHenry:

I modified the code, the OrderModify() for this:

 I added NormalizeDouble(), but, continues given the error 130. :S

OrderLots() is not source of problem? Can order size be modified later by OrderModify()?!
 
mladen:

It is not about normalization

  1. Is your broker ECN/STP type of broker? If yes, in that case you have to add TA and / or SL in two steps
  2. In any case you have to check if TP and Sl are at least at "StopLevel" distance from the current price. Use the MarketInfo(_Symbol,MODE_STOPLEVEL) to check that
  3. Check your prices. I do not think that multiplication with 0.5 (the 50/100 part) will produce any usabe results
Mladen, I didn't test this EA in none broker. I tested it backtest...

The problem persists and I don't know why! :S
 
JHenry:
Mladen, I didn't test this EA in none broker. I tested it backtest...

The problem persists and I don't know why! :S
Did you check what I have posted at that post?
 
IXI:
OrderLots() is not source of problem? Can order size be modified later by OrderModify()?!
That is wrong there too, but as far as I am aware, that parameter is ignored (since in that place OrderOpenPrice() should be used), and whatever price you use there, it is ignored (at least that is how in my tests it is working)
 
Done!

I found the problem!

The problem is solved!

Thank guys for your opnions!! :)

BTW, two programmer budgeted 400$ for make this EA...
:S
No comments!
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(OrdersTotal()<2)
     {
      OrderSend(Symbol(),OP_BUY ,1,Ask,0,0,Bid+0.00500,"",0,0,clrNONE);
      OrderSend(Symbol(),OP_SELL,1,Bid,0,0,Ask-0.00500,"",0,0,clrNONE);
     };
  
  
  
    
  for(int i=0; i<OrdersTotal(); i++)
    {
     OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
          
          
     
     if(OrderType() == OP_BUY && (OrderOpenPrice()-Bid)>0.01000)
       {
        OrderModify(OrderTicket(), OrderLots(), OrderStopLoss(), MathMin(Bid+0.5*(OrderOpenPrice()-Bid), OrderTakeProfit()), OrderExpiration(), clrNONE);
       };
              
       
       
     if(OrderType() == OP_SELL && (Ask-OrderOpenPrice())>0.01000)
       {
        OrderModify(OrderTicket(), OrderLots(), OrderStopLoss(), MathMax(Ask-0.5*(Ask-OrderOpenPrice()), OrderTakeProfit()), OrderExpiration(), clrNONE);
       };
    };
  
  
  
    
  }
//+------------------------------------------------------------------+
Reason: