error 130

 

Hi all,

So I've the EA running well on a ECN Broker without any error 130 return  but once running on a STP Broker the opening of orders is fine and when TrailingStop should "start is work" error  130 pops up.

As far I understood ECN Broker runs on a commission base and STP on a spread base. Don't the code should run in any of the Brokers  or is anything missing here ?

void Trail()
  { 
       
       int TrailingStop =1;
       double StopLevel = MarketInfo(Symbol(),MODE_STOPLEVEL)*Point;
                
      for(int OrderCounter = 0; OrderCounter <= OrdersTotal()-1; OrderCounter++)
         {//23
        if(!OrderSelect(OrderCounter,SELECT_BY_POS))continue;
         if(OrderType()==OP_BUY && OrderSymbol()== Symbol() 
            && OrderMagicNumber()== MagicNumber)                                                         
            {//24
             RefreshRates();
            if(OrderStopLoss() < (Bid - TrailingStop * pips2dbl) && Bid - OrderOpenPrice() >= (MinimumProfit*pips2dbl)) 
               {//25
               if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid - TrailingStop * pips2dbl, OrderTakeProfit(),0,Yellow))
                Print("Buy TrailingStop Failed, error # ", GetLastError());
               }//25
             }//24
           }//23          
           if(OrderType()==OP_SELL && OrderSymbol()== Symbol() 
              && OrderMagicNumber()== MagicNumber)
              {//26
              if(OrderStopLoss() > (Ask + TrailingStop * pips2dbl) && OrderOpenPrice() - Ask >= (MinimumProfit*pips2dbl))
                 {//27
                  RefreshRates();
                 if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask + TrailingStop * pips2dbl,OrderTakeProfit(),0,Yellow))                 
                 Print("Sell TrailingStop Failed, error # ", GetLastError());
               }//27                            
            return(0);     
          }//26   
  }

 

Thank in advance for any clue to follow

Luis 

 
luisneves:

Hi all,

So I've the EA running well on a ECN Broker without any error 130 return  but once running on a STP Broker the opening of orders is fine and when TrailingStop should "start is work" error  130 pops up.

As far I understood ECN Broker runs on a commission base and STP on a spread base. Don't the code should run in any of the Brokers  or is anything missing here ?

 

Thank in advance for any clue to follow

Luis 

The best way for you to fix this is by fully understanding what is required,  the mathematics are pretty simple but what is involved can seem like a lot of effort,  but it you can take the time to understand it is well worth it.

All you need to know is on one page,  if you can read it, follow and understand it then you can code checks to avoid error 130:   Requirements and Limitations in Making Trades

One difference between ECN and STP brokers is Stop and Freeze levels,  ECN usually have them at 0  so for a Buy on an STP you need to ensure  that your new SL complies with this  Bid - SL >= Stoplevel (* point)

Reason: