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
If the error persists, check that the SL and TP are not closer than SYMBOL_TRADE_STOPS_LEVEL.
Also, the order opening price should not be closer than MarketInfo (Symbol(), MODE_STOPLEVEL) to сurrent price.
If MarketInfo (Symbol (), MODE_STOPLEVEL) is equal to zero, then this value is floating and it is necessary to use an offset from the current price of at least two spreads.
STOPLEVEL = Getting 8.0
Still not understanding the issue
You are setting the TP at 20 points, that is ridiculously close. If the spread is 20 Points or more the trade would be closed immediately if it was opened.
Is this is the main reason or getting 130 error?
You are setting the TP at 20 points, that is ridiculously close. If the spread is 20 Points or more the trade would be closed immediately if it was opened.
Could you write an example code with dummy values ?
I want for pending sell order SL to be 3 pips below of 2nd last candle i.e ( SL = Low[2] - 3 pips)
TP = TradeOpenPrice - 10 pips
TradeOpenPrice = Low[1] - 3 pips
how could I code this? Please write an example code I am stuck on this unable to understand.
I want my EA to work in this manner:
Try this code. I didn't check it myself. The point is: the open Price of BUY STOP should be higher than the current price plus two spreads (I use two spreads instead of MarketInfo (Symbol (), MODE_STOPLEVEL)), SL should be lower than the open price. The open price of the SELL STOP should be below the current price and minus two spreads, SL should be above the open price plus two spreads.
Note that it is not clear from your code what the value of the variable is TpFirstOrder. In the code, it is not implanted anywhere of any value.
Try this code. I didn't check it myself. The point is: the open Price of BUY STOP should be higher than the current price plus two spreads (I use two spreads instead of MarketInfo (Symbol (), MODE_STOPLEVEL)), SL should be lower than the open price. The open price of the SELL STOP should be below the current price and minus two spreads, SL should be above the open price plus two spreads.
What is spreads? why u have used it?
What is spreads? why u have used it?
This is the difference between Ask and Bid. I used two spreads, because it happens that the value of MarketInfo (Symbol (), MODE_STOPLEVEL) is zero. If it is equal to zero, it means that it is "floating" and each time can be different. Therefore, I usually use the value of two spread sizes ((Ask-Bid)*2 ).
Try this code. I didn't check it myself. The point is: the open Price of BUY STOP should be higher than the current price plus two spreads (I use two spreads instead of MarketInfo (Symbol (), MODE_STOPLEVEL)), SL should be lower than the open price. The open price of the SELL STOP should be below the current price and minus two spreads, SL should be above the open price plus two spreads.
Note that it is not clear from your code what the value of the variable is TpFirstOrder. In the code, it is not implanted anywhere of any value.
Here it is TpFirstOrder = 10 which you have already set in
but your code is still not working still getting error.
See the log messages, most of the errors are not correct SL