Code in mql4
I'm using mql5
if(last_tick.last<iMA_buf[0])
"Not working", what that means exactly ? why are you checking position type, volume or open price when Position.Select() is false ?
What I'm trying to do is after the Sell position is open m_Trade.Sell(1,my_symbol) I'm gonna set the StopLoss and TakeProfit based on the Price that I've openned. To do this I'm trying to use the code: m_Trade.PositionOpen(my_symbol,ORDER_TYPE_SELL,1,last_tick.ask,Open_Price+1,Open_Price-5). MetaTrader5 says that sl=1 and tp=-5 are invalid. It seens that Open_Price is "0".
So, how can I get obtain the price of an open position?
Thanks
What I'm trying to do is after the Sell position is open m_Trade.Sell(1,my_symbol) I'm gonna set the StopLoss and TakeProfit based on the Price that I've openned. To do this I'm trying to use the code: m_Trade.PositionOpen(my_symbol,ORDER_TYPE_SELL,1,last_tick.ask,Open_Price+1,Open_Price-5). MetaTrader5 says that sl=1 and tp=-5 are invalid. It seens that Open_Price is "0".
So, how can I get obtain the price of an open position?
Thanks
If position.Select() is false, that means there is no position.
Your code to set sl/tp must in the true case, not false.
![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
How can I obtain the price of an open position? I'm gonna use this price to specify the StopLoss and TakeProfit.
I've traied PositionGetDouble(POSITION_PRICE_OPEN) but it's not working.
Thanks