# calculate exact costs of a market move

969

Hello,

many posts here are about this problem. However, it seems this is not solved and the desk did not answer for this so far or in russian language.

The Problem: i do a trade , entry at price p1 and exit at price p2. MetaTrader  shows the profit for this trade.

I like to calculate this profit with MQL5 methods, exactly this profit, so profit in account currency.

How to do this, given i have

a) symbol

b) p1

c) p2

d) volume

Thank you

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
• www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
Moderator
35109

Hello,

many posts here are about this problem. However, it seems this is not solved and the desk did not answer for this so far or in russian language.

The Problem: i do a trade , entry at price p1 and exit at price p2. MetaTrader  shows the profit for this trade.

I like to calculate this profit with MQL5 methods, exactly this profit, so profit in account currency.

How to do this, given i have

a) symbol

b) p1

c) p2

d) volume

Thank you

How is this related to an answer from Service Desk ?
Moderator
35109

ssn:
For the attached class, PriceDelta would be difference btn p1 an p2. The profit returned is for one lot, so multiply it by you volume to get the loss or profit for your volume.

The method used is uselessly overcomplicated.

You don't have to convert yourself to account currency, simply use SYMBOL_TRADE_TICK_VALUE in your formula.
5241

angevoyageur:

The method used is uselessly overcomplicated.

You don't have to convert yourself to account currency, simply use SYMBOL_TRADE_TICK_VALUE in your formula.
Obviously you and I come from different backgrounds...
5241

angevoyageur:

The method used is uselessly overcomplicated.

You don't have to convert yourself to account currency, simply use SYMBOL_TRADE_TICK_VALUE in your formula.
There was a time when SYMBOL_TRADE_TICK_VALUE was buggy... If it works ok now, that's fine...
Moderator
35109

ssn:
There was a time when SYMBOL_TRADE_TICK_VALUE was buggy... If it works ok now, that's fine...

If it's buggy, then ask the correction of the bug.

Why did you remove your post ?

Get in touch with developers using Service Desk!
• www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
5241

Sorry I removed the code, chinaski can PM me for it or use SYMBOL_TRADE_TICK_VALUE
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
• www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
5241

angevoyageur:

If it's buggy, then ask the correction of the bug.

Why did you remove your post ?

It should not have been made available free in the first place. My err in judgement. Sorry.
Moderator
35109

ssn:
It should not have been made available free in the first place. My err in judgement. Sorry.
Ok, no problem.
969

Hello guys,

thank you for replies gentlemen.

Can one of you give a simple formular for my problem ? So other users, having the same problem can just copy this formular.

opened and price when position closed and resulting profit i can't calculate this profit using

Of course in my tests no other symbols were opened at this time.

If you can calculate exaclty the profit, please just post your formular here and this problem should be solved for all times.

Thank you.

formular input

a) symbol

b) p1

c) p2

d) volume

output: costs in account currency.

(I mentioned the desk because i posted my question there along with detailed sample, screenshots, my code for this

Moderator
35109

Hello guys,

thank you for replies gentlemen.

Can one of you give a simple formular for my problem ? So other users, having the same problem can just copy this formular.

opened and price when position closed and resulting profit i can't calculate this profit using

Of course in my tests no other symbols were opened at this time.

If you can calculate exaclty the profit, please just post your formular here and this problem should be solved for all times.

Thank you.

formular input

a) symbol

b) p1

c) p2

d) volume

output: costs in account currency.

(I mentioned the desk because i posted my question there along with detailed sample, screenshots, my code for this