You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In the case of erroneous or unnormalized stop levels, the error 130 (ERR_INVALID_STOPS) will be generated. This can occur if the order was opened with high slippage from the bot's requested open price, which causes the requested tp/sl prices to be invalid.
I suggest to set tp/sl in a separate step, and compensate for any slippage that may have occurred during opening the order.
Here are my changes to the previous code:
Hi @ amrali,
maybe i found the problem this morning while i was trying your code.
While i was debugging, i noticed that the second parameter (the operation type, OP_BUY, OP_SELL, ecc) was always 0, i passed the type as order_params[1] that is a string containing "OP_BUY"/"OP_SELL" ecc and i thought that it was automatically convert in the correspective number correspondig to the right opetation: https://docs.mql4.com/constants/tradingconstants/orderproperties
Instead, maybe due to it is a string, it was always converted to 0 (BUY operation); Indeed i remember the BUY operation worked, i had problems with the other types.
I changed my code to right manage that parameter and to convert it in the right integer value and now it seems works! :)
At this point, maybe, the first problem was the wrong SL and TP fit value, but then the problem could have been this...
I hope this is the happy ending of this long topic :)
Always pay attention to the compiler's warnings about implicit type conversions, it often leads into logical errors during the run time.
While i was debugging, i noticed that the second parameter (the operation type, OP_BUY, OP_SELL, ecc) was always 0, i passed the type as order_params[1] that is a string containing "OP_BUY"/"OP_SELL" ecc
@Dominik The compiler should had warned about an implicit typecast string to int parameter to OrderSend().