Error 130 should sometimes just be ignored, but will my broker enjoy it?

 

hi,

so I implemented this strategy of mine where I draw some sloping fibots starting at the open of the day or week or month, and then track the sloping lines and place pending orders on the two lines that bracket price, both orders in the direction of the slope(bullish/bearish) and I do so through these little order entry loops that look like this

for(int j=1; j<=17; j++){
if(ObjectFind(d1aN[j]) == 0){
       vM = NormalizeDouble(ObjectGetValueByShift(d1aN[j],0),Digits);
       tmpsl = NormalizeDouble(ObjectGetValueByShift(d1aN[j-1],0),Digits);
       tmptp = NormalizeDouble(ObjectGetValueByShift(d1aN[j+1],0),Digits);
      sl = vM+0.236*(tmpsl-vM);
      tp = vM+(-0.718)*(vM-tmptp);
//------------------------------------------find Order of Line, check if none and place Stop and Limit entries-----    
   if(OrderFind(md1aN[j]) == false){
      if(Bid <= tmpsl && Bid >= tmptp && Bid <= vM){
         if(OrderSend(Symbol(),OP_SELLLIMIT, PositionSize,vM,3,sl,tp,"",md1aN[j],0,clrNONE)<0) 
            Print("Err (",GetLastError(), ") Open SellLimit Price= ",vM, " SL= ",sl," TP= ",tp);}
      else if(Bid <= tmpsl && Bid >= tmptp && Bid >= vM){ 
         if(OrderSend(Symbol(),OP_SELLSTOP,PositionSize,vM,3,sl,tp,"",md1aN[j],0,clrNONE) < 0) 
            Print("Err (",GetLastError(), ") Open SellStop Price= ", vM, " SL= ",sl," TP= ", tp);}
      }
//---------find Order of Line, check if any Order and if only one, place the second, + Modify if Pending-----(start)------             
   else if (OrderFind(md1aN[j]) == true)
   {
      if(glbOrderType == OP_SELLLIMIT){
         if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES)==true)
         if(vM != OrderOpenPrice())
         if(OrderModify(glbOrderTicket,vM,sl,tp,0,clrNONE) == false) 
            Print("Err (",GetLastError(), ") Modify SellLimit Price= ",vM," SL= ",sl," TP= ",tp);
         else if(glbOrderType != OP_SELLSTOP){
            if(Bid <= tmpsl && Bid >= tmptp && Bid >= vM){
            if(OrderSend(Symbol(),OP_SELLSTOP,PositionSize,vM,3,sl,tp,"",md1aN[j],0,clrNONE) < 0) 
               Print("Err (",GetLastError(), ") Open SellStop Price= ", vM, " SL= ",sl," TP= ", tp);}}}
      
      else if(glbOrderType == OP_SELLSTOP){ 
         if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES)==true)
         if(vM != OrderOpenPrice())
         if(OrderModify(glbOrderTicket,vM,sl,tp,0,clrNONE) == false) 
            Print("Err (",GetLastError(), ") Modify SellStop Price= ",vM," SL= ",sl," TP= ",tp);
         else if(glbOrderType != OP_SELLLIMIT){
            if(Bid <= tmpsl && Bid >= tmptp && Bid <= vM){
            if(OrderSend(Symbol(),OP_SELLLIMIT,PositionSize,vM,3,sl,tp,"",md1aN[j],0,clrNONE) < 0) 
               Print("Err (",GetLastError(), ") Open SellStop Price= ", vM, " SL= ",sl," TP= ", tp);}}}
}//---------find Order of Line, check if any Order and if only one, place the second, + Modify if Pending-----(end)-------   

}//close one level loop ...if(ObjectFind(d1aN[i]) == 0)
else if(ObjectFind(d1aN[i] == false)){
   if(OrderFind(md1aN[i]) == true){
      if(glbOrderType == OP_SELLLIMIT){
         if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES)==true) if(OrderDelete(glbOrderTicket)==true) continue;;}
      else if(glbOrderType == OP_SELLSTOP){
         if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES)==true) if(OrderDelete(glbOrderTicket)==true) continue;;}}}
}//close all 17 levels loop ...for()


, there's 17 in every direction, every duration, and every conviction, but that's beside the point...the issue is that

//---------find Order of Line, check if any Order and if only one, place the second, and Modify if Pending

...after this line, 1) I check to find if there's any pendings on this line, then I check if the order entry is currently alligned with the line itself, call it vector Main; so if the line is different from the existing Order Entry price set before, I modify the order and the stop, and target along with it, to basically trace the Pending Order along the slope...

...now the thing is that if the difference is not big enough, or something, the code still tries to Modify the order because vM is different from OrderOpenPrice(), ok, so it gives me the 130...and like, alot, yet, as soon as the difference of != is big enough it modifies the order properly, so it all seems to work fine, the thing that I find unsettling, though; is this-

errorerror130error

apparently there needs to be a verification that helps resolve the 130, or does there? because the whole EA compiles with 0 warnings, yet Err(130) is Printed, so vM was not equal to OrderOpenPrice() but maybe the difference was too small, or something, how would I check to resolve this and/or should I? ...and apparently the problem arises only in the

else if(glbOrderType == OP_SELLSTOP){

part because this -

Print("Err (",GetLastError(), ") Modify SellLimit Price= ",vM," SL= ",sl," TP= ",tp);

doesn't happen

 

...well, I thought I fixed it there, for a second, with this

//---------find Order of Line, check if any Order and if only one, place the second, and Modify if Pending-----(start)---
   if ((OrderFind(md1aN[j]) == true) && (glbOrderType == OP_SELLLIMIT))
   {
         if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES)==true)
         if(vM != OrderOpenPrice())
         if(OrderModify(glbOrderTicket,vM,sl,tp,0,clrNONE) == false) 
            Print("Err (",GetLastError(), ") Modify SellLimit Price= ",vM," SL= ",sl," TP= ",tp);
         else if(glbOrderType != OP_SELLSTOP){
            if(Bid <= tmpsl && Bid >= tmptp && Bid >= vM){
            if(OrderSend(Symbol(),OP_SELLSTOP,PositionSize,vM,3,sl,tp,"",md1aN[j],0,clrNONE) < 0) 
               Print("Err (",GetLastError(), ") Open SellStop Price= ", vM, " SL= ",sl," TP= ", tp);}}}
      
    if((OrderFind(md1aN[j]) == true) && (glbOrderType == OP_SELLSTOP))
    { 
         if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES)==true)
         if(vM != OrderOpenPrice())
         if(OrderModify(glbOrderTicket,vM,sl,tp,0,clrNONE) == false) 
            Print("Err (",GetLastError(), ") Modify SellStop Price= ",vM," SL= ",sl," TP= ",tp);
         else if(glbOrderType != OP_SELLLIMIT){
            if(Bid <= tmpsl && Bid >= tmptp && Bid <= vM){
            if(OrderSend(Symbol(),OP_SELLLIMIT,PositionSize,vM,3,sl,tp,"",md1aN[j],0,clrNONE) < 0) 
               Print("Err (",GetLastError(), ") Open SellStop Price= ", vM, " SL= ",sl," TP= ", tp);}}}
}//---------find Order of Line, check if any Order and if only one, place the second, and Modify if Pending-----(end)-----

but NO

now it gives me the 130 on both, however, when I have only one Symbol in a window, so like, only one chart with this EA in the active profile, it doesn't give err130, so this means that the problem lies in the fact that I'm using the same EA on different symbols, i.e. I must add a symbol verification of some kind something with Symbol(), OrderSymbol(), or ChartSymbol()

...well, if I use ChartSymbol() instead of just Symbol() I still get the same 130, after all Symbol() and ChartSymbol() are essentially the same, right?  so, I need to tie the OrderSymbol() to Symbol() somehow...but that's already being done in the bool OrderFind()...so maybe my problem is more in the price difference not being significant enough...and I should check in the ...or..., when I do

   if(OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES)==true)
         if(vM != OrderOpenPrice())
...this,I need to check about a solution from here https://www.mql5.com/en/forum/146370#comment_3693988
Trailing Bar Entry EA
Trailing Bar Entry EA
  • 2013.08.16
  • www.mql5.com
Hello, I have written an EA that trails one bar high or low and opens 2 positions. After that, it should halt and do nothing more...
 

my problem is probably here

       vM = NormalizeDouble(ObjectGetValueByShift(d1aN[j],0),Digits);
       tmpsl = NormalizeDouble(ObjectGetValueByShift(d1aN[j-1],0),Digits);
       tmptp = NormalizeDouble(ObjectGetValueByShift(d1aN[j+1],0),Digits);

but what to do?

double ts = MarketInfo(Symbol(), MODE_TICKSIZE)
//
tmpvM = ObjectGetValueByShift(d1aN[j],0);
tmpsl = ObjectGetValueByShift(d1aN[j-1]);
tmptp = ObjectGetValueByShift(d1aN[j+1],0);
sl1 = vM+0.236*(tmpsl-vM);
tp1 = vM+(-0.718)*(vM-tmptp);
vM = MathRound(tmpvM/ts) * ts;
sl = MathRound(sl1/ts) * ts;
tp = MathRound(tp1/ts) * ts;

?

well, it does seem to work faster this way, for sure, (about three times faster) but, now I'm also getting err1 too, which seems to me to be a situation that a price change is registered somewhere further in the decimal points than OrderSend/OrderModify takes so maybe I need to check for

if(vM != OrderOpenPrice())

in some different way, like my OrderOpenPrice() doesn't return a normalized price?...well, it does...now it's become err1 on all stop and limit, buy or sell, yet, I specifically ask for vM != OrderOpenPrice() why is it giving me an error as if it were in fact equal? Obviously, I'm misunderstanding something...please point me to my mistake ...(MODE_STOPLEVEL 14) ...so "external mechanisms for dynamic level control, which cannot be translated in the client terminal." so then my broker should be fine with error 1 or 130 this way, and it's not even an error for that matter, no compiler warning just a new line in Terminal Journal every tick, which I should be fine with, right?

err1and130