Invalid Stops in EA with account ECN

 

I have a Robot that works perfectly with the backtest in just a active. However, when I put the EA to run in real mode in several pairs it is causing conflicts in the order openings. The error 'Invalid Stops' appears.

I am using the VALUTRADES ECN broker

I researched and saw that ECN accounts cannot be opened with SL and TP defined.

I use the following command line to open pending orders: trade.BuyStop(lotSize,pendingBuyPriceAsk,_Symbol,stopLoss,takeProfit,0);

what should i do to work properly? I use MQL5


                    
Testing trading strategies on real ticks
Testing trading strategies on real ticks
  • www.mql5.com
The article provides the results of testing a simple trading strategy in three modes: "1 minute OHLC" using only Open, High, Low and Close prices of minute bars; detailed modeling in "Every tick" mode, as well as the most accurate "Every tick based on real ticks" mode applying actual historical data. Comparing the results allows us to assess...
 
galdinotrader: I researched and saw that ECN accounts cannot be opened with SL and TP defined.
There is no need to open an order and then set the stops. Simplify your code - do it in one step. TP/SL on OrderSend has been fine for years.
          Build 500 № 9 2013.05.09
 
William Roeder:
There is no need to open an order and then set the stops. Simplify your code - do it in one step. TP/SL on OrderSend has been fine for years.
          Build 500 № 9 2013.05.09
can you tell me how should i replace this buyStop with OrderSend?
 
Nope, I don't know MT5
 
galdinotrader:
can you tell me how should i replace this buyStop with OrderSend?

You don't need to use OrderSend directly, use CTrade as you did. But check you prices, an invalid stops error can be on the pending price and/or stoploss/takeprofit.

In general, the rules to follow are the same as with MT4.

 
Alain Verleyen:

You don't need to use OrderSend directly, use CTrade as you did. But check you prices, an invalid stops error can be on the pending price and/or stoploss/takeprofit.

In general, the rules to follow are the same as with MT4.

this error occurs with multiple execution pairs. I researched and saw that ECN accounts cannot set the STOP and start TakeProfit.


 
galdinotrader:

this error occurs with multiple execution pairs. I researched and saw that ECN accounts cannot set the STOP and start TakeProfit.


That's not the problem. William already answered you about that.
 
Alain Verleyen:
That's not the problem. William already answered you about that.

he talked about orderSend. How do I replace my Ctrade command line with orderSend?


 
 
Alain Verleyen: You don't need to use OrderSend directly, use CTrade as you did. But check you prices, an invalid stops error can be on the pending price and/or stoploss/takeprofit.

In general, the rules to follow are the same as with MT4.

Alain already answered you about that.

 

I make this:

   MqlTradeRequest neueOrder={0};

      MqlTradeResult result={0};

   //--- setting request

      neueOrder.symbol       = _Symbol;

      neueOrder.type         = ORDER_TYPE_BUY_STOP;

      neueOrder.action       = TRADE_ACTION_PENDING;

      neueOrder.type_time    = ORDER_TIME_GTC;

      neueOrder.volume       = lotSize;

      neueOrder.price        = pendingBuyPriceAsk;

      neueOrder.sl           = stopLoss;

      neueOrder.tp           = takeProfit;

      neueOrder.magic        = MagicNumber;

      

      OrderSend(neueOrder,result);


but still giving invalid stops

this problem is happening after you open 1 order on an asset. And then try to open another order on another asset


                    
 
maybe stoploss is smaller than the stoplevel