calculate exact costs of a market move - page 2

 
ssn:
It should not have been made available free in the first place. My err in judgement. Sorry.
I tried your class for EURUSD, account in USD and it doesn't return the right value.
 

Hello Angevoyageur,

i need the possible profit in account currency before doing a trade, as most exact as possible.

 

My mistake is a thinking error.

I just put entry and exit price of a trade in my formular and it was not matching to  the  profit exposed for this trade in backtest log.

The reason for this seems to be that

 

SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE)

 

depends on CURRENT market as it reflects current exchange value for symbol-currency against account currency.

my formular:

        double _SYMBOL_POINT=SymbolInfoDouble(symbol,SYMBOL_POINT);
        double _SYMBOL_TRADE_TICK_SIZE=SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_SIZE);

        /// so, this value can change every tick as it reflects value against account currency
        double _SYMBOL_TRADE_TICK_VALUE=SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE);       


        double point_value= _SYMBOL_TRADE_TICK_VALUE / (_SYMBOL_TRADE_TICK_SIZE/ _SYMBOL_POINT);         

        double price_diff=p1-p2;
        double nbr_pips=price_diff / _SYMBOL_POINT;
        double costs_for_std_lot_symbol=nbr_pips * point_value;
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
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
 
chinaski:
...

Yes, TICK_VALUE depends on "current exchange value for symbol-currency against account currency". Unless profit currency and account currency are the same.

But it also depends if your trade is in profit or in loss, this why there is SYMBOL_TRADE_TICK_VALUE_PROFIT and SYMBOL_TRADE_TICK_VALUE_LOSS. Your formula is right for a profit.

 

Hello,

thank you for this detail. Will integrate this in my formular. 

 
double cost=((p2-p1)/_Point)*(volume/SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN))*SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE);
Reason: