Symbol Point Value - page 4

 
EdFuk #:

Thanks Dominik,


Yes that is what I thought. I have to admit I seem to have bypassed the documentation (always a bad idea) and calculated using something that worked for FX. I will now get to work and base the calculations on the documentation. As you say where tick value is used in the calculation, like for exchange futures, hopefully it will be in account currency. I will check using the AMP global example I posted above.


It seems that for the calculation types that don't use tick value the brokers just output the value which could either be in account currency or profit. I'm hoping where it is required it comes out in account currency otherwise there is no standard and it's impossible to use.


Thanks for your help.


Cheers,


Ed

Think about what you just said, concerning tick_value.

It will for sure only be occasionally in account currency, but it will always be in base currency of the asset, as that is the currency, profits are calculated on.

Think about it, SP500 is an Index, calculated from Stocks, if a broker wants to create some product from it, they have to base its value on some currency, but for sure not your account currency.

It would not make sense to base an assets contract on someones account currency.


BTW, I had to fix the lot-formula, because it was faulty. - I seem to have copied it from an old file.



// Long

double vol = (1.0 * (account_currency_risk / tick_value) / ((_open - _sl) * MathPow(10, SymbolInfoInteger(Symbol(), SYMBOL_DIGITS))));

// Short

double vol = (1.0 * (account_currency_risk / tick_value) / ((_sl - _open) * MathPow(10, SymbolInfoInteger(Symbol(), SYMBOL_DIGITS))));



EDIT:

if base currency is not available, it will most likely be in profit currency, as it is as well applicable as a fall-back.

 
Dominik Christian Egert #:

Think about what you just said, concerning tick_value.

It will for sure only be occasionally in account currency, but it will always be in base currency of the asset, as that is the currency, profits are calculated on.

Think about it, SP500 is an Index, calculated from Stocks, if a broker wants to create some product from it, they have to base its value on some currency, but for sure not your account currency.

It would not make sense to base an assets contract on someones account currency.


BTW, I had to fix the lot-formula, because it was faulty. - I seem to have copied it from an old file.





EDIT:

if base currency is not available, it will most likely be in profit currency, as it is as well applicable as a fall-back.

I hear what you're saying but why then when I look at EURUSD is tick value given in GBP (my account currency)? The broker must have done a conversion their end before returning the value. There doesn't seem like there is a standard?

 
EdFuk #:

I hear what you're saying but why then when I look at EURUSD is tick value given in GBP (my account currency)? The broker must have done a conversion their end before returning the value. There doesn't seem like there is a standard?

Really? I thought we already sorted out, it depends on the asset.

As long as the tick_value is not necessary for calculating the base value of an asset, its unreliable. - Brokers set it the way they want. - But for an asset, like an Index, where the value is part of the assets contract, its mandatory to have this value.

Take a look at the asset you have shown in post 28. MESU22 from AMP Global. It even states in the name of the asset, the value is 5$. with a tick size of 0.25 you will get 1.25$ per tick_size. (5$ / (1.0 / 0.25)) = 1.25$ per 0.25 value change.

Again you did take any asset, without taking into account the underlying contract type. - A Future is a contract based product, thats why they have expiry dates. A CFD is a contract type of a different kind.

Thus you will have different calculation formulas, as documented.


Watch for the asset type you are talking about. - So in short, as I posted on post 29, in the code it shows the formulas. When the formula requires the tick_value, it will be set accordingly by the broker,. If that is not the case, then the value presented by tick_value can be anything the broker wants to deliver. 


Got it now?

EDIT:

BTW, it is not adviseable, as show in post 29, to have interest or liquidity_rate be a cacheable value, they change over time. so it is necessary to update these values, either every time you use them, or based on some cache timeout technique.

 
Dominik Christian Egert #:

Really? I thought we already sorted out, it depends on the asset.

As long as the tick_value is not necessary for calculating the base value of an asset, its unreliable. - Brokers set it the way they want. - But for an asset, like an Index, where the value is part of the assets contract, its mandatory to have this value.

Take a look at the asset you have shown in post 28. MESU22 from AMP Global. It even states in the name of the asset, the value is 5$. with a tick size of 0.25 you will get 1.25$ per tick_size. (5$ / (1.0 / 0.25)) = 1.25$ per 0.25 value change.

Again you did take any asset, without taking into account the underlying contract type. - A Future is a contract based product, thats why they have expiry dates. A CFD is a contract type of a different kind.

Thus you will have different calculation formulas, as documented.


Watch for the asset type you are talking about. - So in short, as I posted on post 29, in the code it shows the formulas. When the formula requires the tick_value, it will be set accordingly by the broker,. If that is not the case, then the value presented by tick_value can be anything the broker wants to deliver. 


Got it now?

EDIT:

BTW, it is not adviseable, as show in post 29, to have interest or liquidity_rate be a cacheable value, they change over time. so it is necessary to update these values, either every time you use them, or based on some cache timeout technique.

Yes it seems to be exactly as you say. What looks like something that should be quite straight forward on the surface is turning into a minefield. As you say though I will stick to the documentation calculations. Just coding them as we speak.


Thanks for the help.

Ed

 
EdFuk #:

Yes it seems to be exactly as you say. What looks like something that should be quite straight forward on the surface is turning into a minefield. As you say though I will stick to the documentation calculations. Just coding them as we speak.


Thanks for the help.

Ed

Well, wait until you get into margin calculations, thats mind blowing. A minefiled is nothing compared to that.

Especially when you try to make it work across the sea of brokers out there. 

Did you know, Leverage in the EU is not limited to 1:30, but only for CFDs. So my broker has set my account leverage to 200 and uses some factor given in margin_rate to increase margin requirements for certain symbols. 

Had fun figuring out that stuff...

Profit and tick_value calculations seems almost like 1+1, in comparison.

Wish you success in coding, hope my posted code helps.


EDIT:

As a gimmic, after understanding the margin claculations, I created a function that takes in the account currency amount and gives you the corresponding volume for a specific symbol. This is one of my most useful functions in money management.

You will notice, not all symbols have the same leverage value, some are higher, some are lower. Gold, for example, or the FX-Crosses, like Kiwi or SGDHKD, depending on the broker of course.

 
Well I've coded everything up and amazingly it all seems to working as I expected. Thanks for your help and pointers Dominik. The key for me was, like you said, following the MQL5 calculation mode guidance verbatim Symbol Properties

as detailed here https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_calc_mode. Following the formulas there and using the relevant details from the symbol specification (calculation mode and profit currency, tick value (where applicable), tick size (where applicable)) produces results a expected. Currently I have tried Forex No Leverage, CFD and Exchange Futures. With the Broker Fernando suggested for futures (AMP Global) the tick value is given in the profit currency and hopefully this will always be the case when the value is required for the calculation. I will monitor.


 

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Very nice.

Welcome.
 
Dominik Christian Egert #:
  1. * MathPow(10, SymbolInfoInteger(Symbol(), SYMBOL_DIGITS)

    This is just the same as dividing by _Point.

  2. double vol = (1.0 * (account_currency_risk / tick_value) / ((_open - _sl) * MathPow(10, SymbolInfoInteger(Symbol(), SYMBOL_DIGITS))));

    You need tick_value and tick_size, not point. As was pointed out in #4.

    Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk (on leveraged symbols). Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.
    1. You place the stop where it needs to be — where the reason for the trade is no longer valid. E.g. trading a support bounce, the stop goes below the support.

    2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around $10/PIP, but it takes account of the exchange rates of the pair vs. your account currency.)

    3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
                MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
                Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
                Lot value calculation off by a factor of 100 - MQL5 programming forum (2019)

    4. You must normalize lots properly and check against min and max.

    5. You must also check Free Margin to avoid stop out

    6. For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)

    Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5 or 0.1 Lots maximum.


Reason: