Invalid Stops - page 2

 
Sicco:

Hello, I'm trying to figure out what the cause of the error "Invalid Stops" is inside my EA.

I have been reading this forum and googling around for days but have not found the solution yet, hence I'm creating a topic here.


So, In my EA I'm getting this error when opening an order and modifying an order, probably only once per 50 times.

I will show you the code and the printed results from the code:



As you can see, all the printed values seem fine, so.... I'm clueless.

Beside what the documentation says as posted by Keith, an invalid Stops error (130) can also be an open price error. So in a fast market, as your pending open price is only 5 points of the market (Bid), it may happens the market has moved between the time you send the order and the server receive it. You can try to print the updated Bid/Ask to check it (you need to use RefreshRates() after OrderSend() for that).

What broker/account type is it ?

 
Alain Verleyen:

Beside what the documentation says as posted by Keith, an invalid Stops error (130) can also be an open price error. So in a fast market, as your pending open price is only 5 points of the market (Bid), it may happens the market has moved between the time you send the order and the server receive it. You can try to print the updated Bid/Ask to check it (you need to use RefreshRates() after OrderSend() for that).

What broker/account type is it ?

Good idea, I just tested it with this code:
        if(OrderSend(Symbol(), OP_SELLSTOP, Lotsize, Sell_OpenPrice, Maximum_Slippage, Sell_StopLoss, Sell_TakeProfit, NULL, MagicNumber, 0) == -1)
        {
                Print("XXXXXXXXXX Error: ", ErrorDescription(GetLastError()));
                Print("XXXXXXXXXX: Tried to open a SellStop Order, values:.....");
                Print("XXXXXXXXXX: Lotsize: " + Lotsize);
                Print("XXXXXXXXXX: Sell_OpenPrice: " + Sell_OpenPrice);
                Print("XXXXXXXXXX: Sell_StopLoss: " + Sell_StopLoss);
                Print("XXXXXXXXXX: Sell_TakeProfit: " + Sell_TakeProfit);
                Print("XXXXXXXXXX: Ask: " + Ask);
                Print("XXXXXXXXXX: Bid: " + Bid);
                Print("XXXXXXXXXX: Refreshed Rates");
                RefreshRates();
                Print("XXXXXXXXXX: Ask: " + Ask);
                Print("XXXXXXXXXX: Bid: " + Bid);
                Print("XXXXXXXXXX: StopLevel: " + MarketInfo(Symbol(), MODE_STOPLEVEL));
                Print("XXXXXXXXXX: FreezeLevel: " + MarketInfo(Symbol(), MODE_FREEZELEVEL));
        }

And here is the printed result when it got an Invalid Stops error:

sellstop

As you can see there is a difference of 12 points in both the Bid and Ask price...

So apparently the actual Bid price was already lower than the OpenPrice of my SellStop, which makes it an invalid OpenPrice obviously.


I'm testing all this on a IC Markets Raw Spread Demo account, I believe it's ECN?

And I'm having a connection with about 90ms latency.


What do you think that would potentially fix (or lessen) this error? I'd guess a faster connection?

 
Sicco:
Good idea, I just tested it with this code:

And here is the printed result when it got an Invalid Stops error:


As you can see there is a difference of 12 points in both the Bid and Ask price...

So apparently the actual Bid price was already lower than the OpenPrice of my SellStop, which makes it an invalid OpenPrice obviously.


I'm testing all this on a IC Markets Raw Spread Demo account, I believe it's ECN?

And I'm having a connection with about 90ms latency.


What do you think that would potentially fix (or lessen) this error? I'd guess a faster connection?

Yes you could try the Metaquotes VPS service, it gives very low latency ( you can see it in your Journal log):

2019.10.23 17:47:20.990    Trades: use hosting service to speed up the execution - 1.27 ms via 'MQL5 London 10 (MQL5.community)' instead of 105.53 ms

Reason: