FXDD Gold and Silver MarketInfo problem

 

Hello all,

I have been working on this for days, but have been unable to correct my code to get correct mini lot for Gold, without getting zero divide error (where objects don't even show on chart).

TO CORRECT TICKVALUE FXDD GIVES YOU:

Gold:

PairPipValuePerLot = (MarketInfo("XAUUSD", MODE_TICKVALUE))*1000;

Silver:

PairPipValuePerLot = (MarketInfo("XAUUSD", MODE_TICKVALUE))*100;

TO CALCULATE GAINS:

PairPipGains*PairPipValuePerLot*MiniLot; (Note: You get Pair Pip Gains by subtracting close from open, then multiplying result by 100 if JPY pair, Gold, or Silver, or 10000 otherwise)

The part that messes me up:

I can even use:

extern double MiniLot = 0.1;

… and Silver returns correct value (after fixes above to what info FXDD gives through MT4), but Gold returns zero divide error and blank chart.

Any ideas how to fix this? Any input appreciated. Thanks in advance.

Kind regards,

Don

 
Tick value must be a ratio
double  PointValuePerLot(string pair="") {
    /* Value in account currency of a Point of Symbol.
     * In tester I had a sale: open=1.35883 close=1.35736 (0.00147)
     * gain$=97.32/6.62 lots/147 points=$0.10/point or $1.00/pip.
     * IBFX demo/mini       EURUSD TICKVALUE=0.1 MAXLOT=50 LOTSIZE=10,000
     * IBFX demo/standard   EURUSD TICKVALUE=1.0 MAXLOT=50 LOTSIZE=100,000
     *                                  $1.00/point or $10.00/pip.
     *
     * https://forum.mql4.com/33975 CB: MODE_TICKSIZE will usually return the
     * same value as MODE_POINT (or Point for the current symbol), however, an
     * example of where to use MODE_TICKSIZE would be as part of a ratio with
     * MODE_TICKVALUE when performing money management calculations which need
     * to take account of the pair and the account currency. The reason I use
     * this ratio is that although TV and TS may constantly be returned as
     * something like 7.00 and 0.00001 respectively, I've seen this
     * (intermittently) change to 14.00 and 0.00002 respectively (just example
     * tick values to illustrate).
     * https://forum.mql4.com/43064#515262 zzuegg reports for non-currency DE30:
     * MarketInfo(Symbol(),MODE_TICKSIZE) returns 0.5
     * MarketInfo(Symbol(),MODE_DIGITS) return 1
     * Point = 0.1
     * Prices to open must be a multiple of ticksize */
    if (pair == "") pair = Symbol();
    return(  MarketInfo(pair, MODE_TICKVALUE)
           / MarketInfo(pair, MODE_TICKSIZE) ); // Not Point.
}