Dear all,
As stated in the subject, since my EA constantly checks the price for each order to see if the order should be closed, the take profit and stop loss parameters seem unnecessary, but when I use the function SendOrder, I have to specify the take profit and stop loss. I tried to use 0 for both paramters, but in vain. I got an error code 129, which is invalid price. What should I do? Thanks.
Tom
Post your code.
Invalid price error 129 refers to the price you are attempting to enter the trade at- not a stops error (which would be 130).
Meanwhile tips (assuming you are attempting to trade the currency of the chart which the EA is attached to):
- Use the Ask and Bid variables as appropriate for your entry price.
- Make a RefreshRates() call directly before you issue your OrderSend() call.
CB
In that case, I think my price should be correct. Although I am not trading the currency on the corresponding chart, I am not using the Ask or Bid variables either. I was using a variable that is calculated by my function. The variable might not be at the current Ask/Bid price of the currency. Since the function is run every time the program ticks, so it doesn't matter whether the price equals to the current Ask/Bid price of that currency, right? The logic is if the calculated price equals to the Ask/Bid price of that currency, the order should be placed. Otherwise, it should fail. Does this mean whenever it fails, an error 129 is throwed?
Tom
If you're sure that the price you supply is within slippage of the current price, then I'd ask - are you normalizing it to the correct number of digits?
CB
What I am sure is in most cases the price I supply is NOT within the slippage of the current price. In this case, the OrderSend function should fail with an error code of 129, correct?
In other cases when the price I supply is within the slippage, the OrderSend function should run without any error. The logic is I just keep sending OrderSend with a certain price until the current price falls into the range.
Tom
Why don't you just use limit orders?
CB
![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
Dear all,
As stated in the subject, since my EA constantly checks the price for each order to see if the order should be closed, the take profit and stop loss parameters seem unnecessary, but when I use the function SendOrder, I have to specify the take profit and stop loss. I tried to use 0 for both paramters, but in vain. I got an error code 129, which is invalid price. What should I do? Thanks.
Tom