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
I have 40 open positions now.
10 positions has same magic number.
I want calculate sum profit of these 10 positions; if was more than 70$, then i want close all 10 positions.
It was simple in MT4
But in MT5, it's complicating.
I tried this:
Total_Profit = POSITION_PROFIT + POSITION_COMMISSION + POSITION_SWAP + POSITION_FEE
I can't get POSITION_COMMISSION and POSITION_FEE
I know I should use " DEAL_COMMISSION " and " DEAL_FEE ", but i don't know how.
I can't find any relationship between DEAL and own POSITION
note: these positions are open (no in history)
I'm thankful of your answers.
In a cycle, go around all positions and summarize profit, swap and commission:
In a cycle, go around all positions and summarize profit, swap and commission:
Thank you very much man, for your quick answer.
I have 40 open positions now.
10 positions has same magic number.
I want calculate sum profit of these 10 positions; if was more than 70$, then i want close all 10 positions.
It was simple in MT4
But in MT5, it's complicating.
I tried this:
Total_Profit = POSITION_PROFIT+ POSITION_COMMISSION + POSITION_SWAP+ POSITION_FEE
I can't get POSITION_COMMISSION and POSITION_FEE
I know I should use "DEAL_COMMISSION" and "DEAL_FEE", but i don't know how.
I can't find any relationship between DEAL and own POSITION
note: these positions are open (no in history)
I'm thankful of your answers.
I found answer of my question in MT5.
Each closed position, has 2 deal and 1 opposite position.
commission is calculated in deals. then you need to have deals of each position by POSITION_IDENTIFIER
POSITION_IDENTIFIER
Position identifier is a unique number assigned to each re-opened position. It does not change throughout its life cycle and corresponds to the ticket of an order used to open a position.
Position identifier is specified in each order (ORDER_POSITION_ID) and deal (DEAL_POSITION_ID) used to open, modify, or close it. Use this property to search for orders and deals related to the position.
When reversing a position in netting mode (using a single in/out trade), POSITION_IDENTIFIER does not change. However, POSITION_TICKET is replaced with the ticket of the order that led to the reversal. Position reversal is not provided in hedging mode.
long
Each closed position, has 2 deal and 1 opposite position.
when position is open yet, it has just 1 deal with half commission. for calculate total commision of a open position, you need to multiply 2
Good Luck
This code is better