XAUUSD wrong lot sizing on GBP denominated account? - page 5

 
DomGilberto:
Thank you :) - I'll check it out now!

Also, in your opinion, is FXCM in the wrong with how I am seeing the Tick Value? They're adamant that it's perfectly normal? You wouldn't know why it is they're screwing it up would you?
I don't know why they are doing what they are doing . . . if you want some weight behind your arguments install a few of their competitors and see how they have the Tick Value set then tell them what their competitors are doing . . . and ask if they still feel "normal" . . .
 
Oh believe me, I've checked about 5-6 different brokers! I'm so annoyed because I have already started trading with them. Of all brokers I wouldn't have thought FXCM would make such a cock up :(

Just out of curiosity - I've read that previous link you attached; is it not easier to do it like this? - The prints are there too. I've just dropped that onto my live account with FXCM... It gives me a pretty accurate TickValue now based off of GBPUSD tick value and simply * 0.10 ?

The only thing I do not know is how to create a switch, where-by, as you've said, if the broker has the correct details, use them??? (able to point me in right direction?)
   double risk_amount = AccountBalance( )* 2.00 / 100;
   double Lot_Step = MarketInfo(Symbol(), MODE_LOTSTEP);
   double ts = MarketInfo(Symbol(), MODE_TICKSIZE);
   double tv = MarketInfo(Symbol(), MODE_TICKVALUE);
   double minlot = MarketInfo(Symbol(), MODE_MINLOT);
   
   double GBPUSD = MarketInfo( "GBPUSD", MODE_TICKVALUE);
   
      double CustomTickValue = 0.10 * GBPUSD;
         Print(" Custom Tick Value is: ", 0.10, " * ", GBPUSD, " = ", CustomTickValue);

2013.11.12 11:32:33     Tick Value test XAUUSD,H1:  Custom Tick Value is: 0.1 * 0.6296 = 0.063

            
      double loss_for_1_lot = 25.25 / ( 0.10 * GBPUSD ) * ts ;
         Print(" loss_for_1_lot formula: ", 25.25, " / ", ts, " * (", CustomTickValue,") = ", loss_for_1_lot );

2013.11.12 11:32:33     Tick Value test XAUUSD,H1:  loss_for_1_lot formula: 25.25 / 0.01 * (0.063) = 4.0106

      
      double LotSize_Buy = MathFloor( risk_amount / loss_for_1_lot/ Lot_Step) * Lot_Step ;
         Print(" LotSize_Buy: ( ", risk_amount, " / ", loss_for_1_lot, " / ", Lot_Step, " ) * ", Lot_Step, " = ", LotSize_Buy); 

2013.11.12 11:32:33     Tick Value test XAUUSD,H1:  LotSize_Buy: ( 76.0598 / 4.0106 / 1 ) * 1 = 18
 
DomGilberto:
Oh believe me, I've checked about 5-6 different brokers! I'm so annoyed because I have already started trading with them. Of all brokers I wouldn't have thought FXCM would make such a cock up :(

Just out of curiosity - I've read that previous link you attached; is it not easier to do it like this?

That might/will work ( I've not looked in enough detail ) where the Symbol is XXXUSD and your acccount currency is GBP, wouldn't you rather have a function that works for a symbol like XXXYYY and an account currency of ZZZ ? then you are done and don't have to be concerned again about this subject . . .

The only thing I do not know is how to create a switch, where-by, as you've said, if the broker has the correct details, use them??? (able to point me in right direction?)
You could simply do the calculation and compare the calculated value against the MarketInfo() value and if the differ by more than 10%, 20% . . . whatever you think is a big enough error, you use the calculated value. You just need to be certain that the values you are using in your calculation are correct, to that end if you get the Tick Value for a symbol whose base currency (EURGBP) is the same as your account currency (GBP) it will be 1.0 ( 5 digit Broker ) then work back from that to the symbol you need to find the Tick Value for.
 
Good shout! Ok, so I've had a play around - if you get a minute, would you mind glancing over this to see what you think? I appreciate I have not made this very robust - I am merely looking for a temporary fix (which I know the word temporary is a dangerous word!) that will remain robust specifically with FXCM in the interim... This one below is specifically for XAGUSD! (sorry I needed to update it as I posted wrong one!)

minLot is always either 50.00 for silver or 1.00 for gold.
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
 

  
   double ts = MarketInfo(Symbol(), MODE_TICKSIZE);
   double tv = MarketInfo(Symbol(), MODE_TICKVALUE);
   
   double GBPUSD_BID = MarketInfo( "GBPUSD", MODE_BID);
   double CustomTickValue;
   
   double EqualityTickValue = (( 0.10 / GBPUSD_BID * minLot ) - tv ) * 1000;
      Print(" EqualityTickValue formula is: ( ", 10, " / ", GBPUSD_BID, " * ", 50, " ) - ", tv, ") * ", 1000, " = ", EqualityTickValue);

2013.11.12 14:40:08     Tick Value test XAUUSD,H1:  EqualityTickValue formula is: ( 10 / 1.5911 * 50 ) - 0.01) * 1000 = 3132.401


      
   
   if( EqualityTickValue > 20.00 ) 
     {
      CustomTickValue = (0.10 / GBPUSD_BID  * minLot );
      Print(" CustomTickValue is custom: ", 10, " / ", GBPUSD_BID, " * ", 50.00, " = ", CustomTickValue); 

2013.11.12 14:40:08     Tick Value test XAUUSD,H1:  CustomTickValue is custom: 10 / 1.5911 * 50 = 3.1424

     }
   if( EqualityTickValue < 20.00)
     { 
      CustomTickValue = tv;
      Print(" CustomTickValue is MarketInfo: ", tv);



     } 
     
//----
   return(0);
  }
 
DomGilberto:
Good shout! Ok, so I've had a play around - if you get a minute, would you mind glancing over this to see what you think? I appreciate I have not made this very robust - I am merely looking for a temporary fix (which I know the word temporary is a dangerous word!) that will remain robust specifically with FXCM in the interim... This one below is specifically for XAGUSD! (sorry I needed to update it as I posted wrong one!)

minLot is always either 50.00 for silver or 1.00 for gold.


Here is something more generic...

It can be expanded to cover other symbols by different brokers.

The key inputs to note here are BidUSD and AskUSD. BidUSD is the dollar price of the margin currency so lets say your TradeSymbol was GBPJPY, then the BidUSD would be the price of GBPUSD. Similarly the AskUSD would be USDJPY. If any one of the margin or profit currencies are USD for example any of the majors, then your BidUSD==AskUSD==the TradeSymbol's current price.

What is returned by this function is the gain/ loss for holding one lot (1.0) of the TradeSymbol through a specified PriceDelta (one of the inputs).

//+------------------------------------------------------------------+
//|                                                       Profit.mqh |
//|                                                              ssn |
//+------------------------------------------------------------------+
#property copyright "ssn"

//#property version   "3.31"

double Profit(string TradeSymbol,double PriceDelta,double BidUSD,double AskUSD)
   {
      double _profit=0.0;
      
      if(StringFind(TradeSymbol,"TNOTE",2)>=0||
         StringFind(TradeSymbol,"aTND",0)>=2){
         _profit+=MarketInfo(TradeSymbol,MODE_LOTSIZE)*BidUSD;
         _profit*=PriceDelta;}
      
      else if(StringFind(TradeSymbol,"US500",0)>=0||
               StringFind(TradeSymbol,"a500",0)>=0||
               StringFind(TradeSymbol,"SPY",0)>=0){
         _profit+=MarketInfo(TradeSymbol,MODE_LOTSIZE)*BidUSD;
         _profit*=PriceDelta;}
      
      else if(StringFind(TradeSymbol,"XAG",0)>=0||StringFind(TradeSymbol,"XAU",0)>=0){
         _profit+=MarketInfo(TradeSymbol,MODE_LOTSIZE)*BidUSD;
         _profit*=PriceDelta; }
      
      else if(StringFind(TradeSymbol,"EUR",0)>=0||
         StringFind(TradeSymbol,"GBP",0)>=0||
         StringFind(TradeSymbol,"AUD",0)>=0||
         StringFind(TradeSymbol,"NZD",0)>=0){
         _profit+=MarketInfo(TradeSymbol,MODE_LOTSIZE)*BidUSD;
         if(StringFind(TradeSymbol,"USD",0)>=0){ 
            _profit*=PriceDelta; }
         else if(StringFind(TradeSymbol,"USD",0)<0){
            if(StringFind(TradeSymbol,"GBP",0)>=0||
               StringFind(TradeSymbol,"AUD",0)>=0||
               StringFind(TradeSymbol,"NZD",0)>=0){
               _profit*=PriceDelta*AskUSD; }
            else if(StringFind(TradeSymbol,"CAD",0)>=0||
                  StringFind(TradeSymbol,"CHF",0)>=0||
                  StringFind(TradeSymbol,"JPY",0)>=0){
               _profit*=PriceDelta;
               if(AskUSD!=0.0) { _profit/=AskUSD; }
               else if(AskUSD==0.0) {
                  Print(" Ask's USD price is zero! ensure it's provided. ");
                  return(0.0); }}}}
      
      else if(StringFind(TradeSymbol,"USD",0)>=0){
         _profit = MarketInfo(TradeSymbol,MODE_LOTSIZE);
         if(StringFind(TradeSymbol,"CAD",0)>=0||
            StringFind(TradeSymbol,"CHF",0)>=0||
            StringFind(TradeSymbol,"JPY",0)>=0){
            _profit*=PriceDelta;
            if(AskUSD!=0.0) { _profit/=AskUSD; }
            else if(AskUSD==0.0) {
               Print(" Ask's USD price is zero! ensure it's provided. ");
               return(0.0); }}}
               
      else if( StringFind(TradeSymbol,"CAD",0)>=0||
               StringFind(TradeSymbol,"CHF",0)>=0){
         if(BidUSD!=0.0) { _profit = MarketInfo(TradeSymbol,MODE_LOTSIZE)/BidUSD; }
         else if(BidUSD==0.0) {
            Print(" Bid's USD price is zero! ensure it's provided. ");
            return(0.0); }
         _profit*=PriceDelta;
         if(AskUSD!=0.0) { _profit/=AskUSD; }
         else if(AskUSD==0.0) {
            Print(" Ask's USD price is zero! ensure it's provided. ");
            return(0.0);  }}
             
      return(_profit);
   }
 

Thanks for your post mate - Not entirely sure what I am taking away from that though - will have a closer look tomorrow...

Reason: