Lot value calculation off by a factor of 100

To add comments, please log in or register
Anthony Garot
3329
Anthony Garot  

Scenario:

2 separate brokers who both have a NASDAQ100 index. When I calculate Lot value in USD (base currency), Broker 2 is 100X greater than Broker 1.

The Calculation:

double GetLotValue(string symbol, const double lotSize, double& pointValue, double& pipValue)
{
        double contract = SymbolInfoDouble(symbol,SYMBOL_TRADE_CONTRACT_SIZE);
        double tickValue = SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE);
        double tickSize = SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_SIZE);
        double lotValue = lotSize * (tickValue / tickSize);

        pointValue = lotValue * SymbolInfoDouble(symbol,SYMBOL_POINT);
        pipValue = lotValue * AdjustedPoint(symbol);

        PrintFormat("%s(%s): contract [%.2f] tickValue [$%.2f] tickSize [%.7f] lotValue [%s] pointValue [%s] pipValue [%s]",
                                __FUNCTION__,
                                symbol,
                                contract,
                                tickValue,
                                tickSize,
                                Currency(lotValue),
                                Currency(pointValue),
                                Currency(pipValue) );

        return lotValue;
}

double AdjustedPoint(string symbol)
{
        int digits_adjust = GetDigitsAdjust(symbol);
        return digits_adjust * SymbolInfoDouble(symbol, SYMBOL_POINT);
}

int GetDigitsAdjust(string symbol)
{
        long digits = SymbolInfoInteger(symbol, SYMBOL_DIGITS);         // Decimal places for price

        int digits_adjust=1;
        if(digits==3 || digits==5)
        {
                digits_adjust=10;
        }
        return digits_adjust;
}

Result for Broker #1:

Broker 1

2019.07.18 08:51:32.893    Test - MoneyManagement (#USNDAQ100,H4)    CPips::GetLotValue(#USNDAQ100): contract [1.00] tickValue [$0.01] tickSize [0.0100000] lotValue [$1.00] pointValue [$0.01] pipValue [$0.01] - clsPips.mqh (80)

Result for Broker #2:

Broker 2

2019.07.18 08:47:52.983    Test - MoneyManagement (USTECHIndex,H4)    CPips::GetLotValue(USTECHIndex): contract [10.00] tickValue [$1.00] tickSize [0.0100000] lotValue [$100.00] pointValue [$1.00] pipValue [$1.00] - clsPips.mqh (80)


The Issue:

I've been using the above code for ForEx without a hitch. Thus, when I calculate a SL or TP, I can determine the value in USD (the base currency). However, when I looked at the SL/TP generated on the index chart for Broker 2, the values were 100X what I expected. So I pulled up the same index (although a different symbol) on Broker 1. The results for Broker 1 were in line with what I expected.

Notes:

  • The contract size for Broker 2 is 10 whereas it is only 1 for Broker 1. I don't actually use the contract size in my calculation.
  • The tickSize is the same for both brokers.
  • The website for Broker 2 says the Pip value is $0.10, whereas my calculation says $1.00. Is this there the contract size comes into play?

One further oddity:

Broker 2's tickValue is $0.10 as stated on the website.

Broker 2 TickValue

This is different from:

SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE);

My Questions:

(1) Is this a Broker 2 issue? Like maybe they have their settings wrong?

(2) Should my calculation consider the contract size, and if so, how? (For ForEx, this value is typically 100000)

Or . . .

(3) Am I missing something else in my calculation?

Alain Verleyen
38608
Alain Verleyen  
Anthony Garot:

My Questions:

(1) Is this a Broker 2 issue? Like maybe they have their settings wrong?

Most probably, unfortunately it's something which happens relatively often.

(2) Should my calculation consider the contract size, and if so, how? (For ForEx, this value is typically 100000)

Or . . .

(3) Am I missing something else in my calculation?

When the data provided by a broker are not reliable you have to find a way to calculate it by yourself.

You can also ask the broker to fix his symbol settings.

Anthony Garot
3329
Anthony Garot  
Alain Verleyen:
Most probably, unfortunately it's something which happens relatively often.

When the data provided by a broker are not reliable you have to find a way to calculate it by yourself.

You can also ask the broker to fix his symbol settings.

Thank you Alain.

I sent an E-mail to the broker to see if they will fix it.

If not, I will add some work-around code to trap for that symbol.

Anthony Garot
3329
Anthony Garot  

Alain Verleyen:

You can also ask the broker to fix his symbol settings.

Wow! Not only did the broker respond, but they changed it!

Thanks for the advice Alain.

Alain Verleyen
38608
Alain Verleyen  
Anthony Garot:

Wow! Not only did the broker respond, but they changed it!

Thanks for the advice Alain.

Very good :-)
To add comments, please log in or register