Vladimir Karputov:
It is necessary to take into account the position time and store it in a variable. Implementation example: Last position type:
Can it be possible to add the position type?
As long as its the last opened position.
Can it be possible to add the position type?
As long as its the last opened position.
Run the example and see.
Run the example and see.
ok sir I'll try. thanks.
Run the example and see.
Can You add the price value of last opened position sir?
Can You add the price value of last opened position sir?
You can do it yourself:
Gets the price of position opening |
- www.mql5.com
You could go ahead and assume following two states:
First, the Ticket-Number is sequencial and increases.
Second position index used internally by MT5 is: highest = last added position.
Then the following code will give you access to the last positions data:
PositionSelectByTicket(PositionGetTicket(PositionsTotal()-1));
or what ever your need is:
https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties#enum_position_property_integer
You could go ahead and assume following two states:
First, the Ticket-Number is sequencial and increases.
Second position index used internally by MT5 is: highest = last added position.
Then the following code will give you access to the last positions data:
or what ever your need is:
https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties#enum_position_property_integer
Can You please elaborate, i'm just learning how to code. I just need the value of last open price to make a condition for closing orders. Example is if the last open position is 100 pips below the current price it will execute the command to close all open positions. Thats all I need for the last open position.
Can You please elaborate, i'm just learning how to code. I just need the value of last open price to make a condition for closing orders. Example is if the last open position is 100 pips below the current price it will execute the command to close all open positions. Thats all I need for the last open position.
In this case, you need to know the type of position and two prices:
Access to double type properties |
|
---|---|
Gets the price of position opening | |
Gets the current price by position symbol |
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can anyone share to me how to get the price of latest open position if I have 2 or more open positions.
double OpenTrade = PositionGetDouble(POSITION_PRICE_OPEN);
I guess this code does not get the latest open position I opened.