Hi,
I have two problems with Buy-Stop and Sell-Stop Orders
1.If my aktuell price (Ask for Buy-Stop and Bid for Sell-Stop) is too near on my pending price (0.00002) I alwas get the order-send error 130.
I have already read this side: https://book.mql4.com/appendix/limits
Does my Offset has to be as much as the Stoplevel from this underlying??
2.In my EA I calculate my Lotsize per percent of my equity (f.e. 5%)
Sometimes I can send my Buy-Stop or Sell-Stop order and when the limit is reached, the order would be deleted by the metatrader (before I can send my stop)!
1. Write your code to check that the order you are about to send complies with the information set out in Requirements and Limitations in Making Trades
2. Do you validate your Lotsize ? are you setting an expiration that is being reached ?
Are you checking your trading function return values ? are you reporting errors and other relevant variables when you find that a function has failed ? What are Function return values ? How do I use them ?
1. My Code looks like this
if(Ask < (Ask+Offset*pips2dbl)) int res = OrderSend(Symbol(),OP_BUYSTOP,Lot,NormalizeDouble(Ask+Offset*pips2dbl,Digits),Slippage * pips2points,0,0,0,MagicNumber,0,Green); if(res < 0 && GetLastError() == 130) { OrderSend(Symbol(),OP_BUYSTOP,Lot,NormalizeDouble(Ask+MarketInfo(Symbol(), MODE_STOPLEVEL)*pips2dbl,Digits),0,0,0,"AverageLimit_reached",MagicNumber,0,Green); }
I only want to know, if I could go nearer to my calculated price "Ask+Offset*pips2dbl" than the StopLevel?
2. I have no expiration for my orders and it is deleted, when the entry price is reached.
I validate my lotsize that way:
lot = NormalizeDouble(NormalizeDouble(lot/LotStep,0)*LotStep,LotDigit); lot = MathMax(MathMin(lot,MaxLots),MinLots);
And there is no other position open (only ONE pending order!)
1. My Code looks like this
I only want to know, if I could go nearer to my calculated price "Ask+Offset*pips2dbl" than the StopLevel?
It's specified in Requirements and Limitations in Making Trades for a BuyStop - OpenPrice-Ask ≥ StopLevel
I validate my lotsize that way:
And there is no other position open (only ONE pending order!)
And what is the reason, that the MetaTrader deleted my position, when it should be opend!?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have two problems with Buy-Stop and Sell-Stop Orders
1.If my aktuell price (Ask for Buy-Stop and Bid for Sell-Stop) is too near on my pending price (0.00002) I alwas get the order-send error 130.
I have already read this side: https://book.mql4.com/appendix/limits
My code for sending the pending orders is like this
-for OP_Buystop: Ask+Offset*pips2dbl
and for OP_Sellstop: Bid-Offset*pips2dbl
Does my Offset has to be as much as the Stoplevel from this underlying??
2.In my EA I calculate my Lotsize per percent of my equity (f.e. 5%)
Sometimes I can send my Buy-Stop or Sell-Stop order and when the limit is reached, the order would be deleted by the metatrader (before I can send my stop)!