workaround to detect 2 decimal points pairs (e.g. gold)

Post Reply
User avatar
fxdaytrader
Trader
Posts: 190
Joined: Sun Jun 10, 2012 7:03 am
Location: Poon-Town (germany, se-asia, se-europe) ...

workaround to detect 2 decimal points pairs (e.g. gold)

Post by fxdaytrader »

At the brokers, gold is referred to as 3 digits pair. But it has 2 decimal points. There are some workarounds to deal with it at pips/point (pips2dbl = multiplier*Point) stuff (e.g. Steves PFactor-function).

Here is another approach of mine:

try to detect if Symbol() is XAU (GOLD) or any other "2 decimal places pair", used for MaxSpread detection (multiplier = 10 does not work, it must be 100), find the symbolname is not possible, because it may vary
so, e.g. if mode_spread = 5 and (ask-bid) = 0.5 the functions returns "2", so we have 2 decimal places behind the comma. It just looks at which place after the comma the integer value from mode_spread appears.

Code: Select all

   if (StringFind(DoubleToStr((Ask-Bid),Digits),DoubleToStr(MarketInfo(Symbol(),MODE_SPREAD),0),0)==2)
    {
     Print("RiskBased OrderSend script: Looks like the pair had 2 decimal places, ...");
     multiplier=100; // for pairs with 2 decimal places, e.g. GOLD
    } 
I use that code in my riskbased ordersend script, please have a look to that code for more details
Post Reply

Return to “Coders Hangout”