XAUUSD wrong lot sizing on GBP denominated account?

 

I appreciate this has been briefly touched upon in the past but I wanted to bring it up again as I am forward testing my EA with a small live account.

All the position sizing's with the currency pairs are correct. Because my account is denominated in GBP the minimum tick sizing is larger to that of a trading account that was denominated in USD (of course).

Either way, as I am trading with FXCM, the minimum position size within MT4 is "1.00" troy ounce. This roughly equates to 0.0624 pence per 1 cent move. (i.e. excluding spreads 1,200.00 > 1,200.01 = £ 0.0624).

This is the code I am using... For some reason, I am sure it is not calculating the correct position sizing...

//+------------------------------------------------------------------+
//| Order Enter Function                                             |
//+------------------------------------------------------------------+
void OrderEntry(int direction)
{
   //Padding for the stop and padding for the entry too. 
   double ATR_Pad = iATR(NULL,60,14,1) / 2; 
   double Buy_Pad = NormalizeDouble(ATR_Pad,Digits);
   double Sell_Pad = NormalizeDouble(ATR_Pad,Digits);
   
   //Stop calculations.    
   double ATR = iATR(NULL,60,14,1);
   double MA = iMA(NULL,60,MA_Period,0,1,0,1);
  
   //Lot calculation.
   double risk_amount = AccountBalance( ) * RiskPercent / 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);
         
          
//+-------------------------------------------------------------------------------------+
//| Order Buy Function                                                                  |
//+-------------------------------------------------------------------------------------+   

//Place a pending buystop if no orders exists. Pending or otherwise.
if(direction==0)
{ 
      
      //Get Highest Price in our lookback range and set buy price above it.
      int iTBT = iBarShift(NULL,60, triggerBarTime, true),
      iHH = iHighest( NULL,60, MODE_HIGH, iTBT + CandlesBeforeBiasObtained, 0 );
      double Buy_Here = High[iHH] + Buy_Pad;
      double buyPrice = NormalizeDouble( Buy_Here,Digits);
            
      double BuyStopPriceMath = MA - ATR;
      double BuyStopPrice = NormalizeDouble( BuyStopPriceMath,Digits );

      //get our buystop price from below the ma and our takeprofit based on our r:r ratio.
      double pips_to_bsl = buyPrice - BuyStopPrice;
      double buy_tp_price = ( pips_to_bsl * RewardRatio ) + buyPrice;
      double buy_takeprofit_price = NormalizeDouble( buy_tp_price, Digits );
      
      double loss_for_1_lot = pips_to_bsl/ ts * tv ;
      double LotSize_Buy = MathFloor( risk_amount / loss_for_1_lot/ Lot_Step) * Lot_Step ;


...
 

??

double buyPrice = NormalizeDouble( Buy_Here,Digit s);
 
Why would that be the reason for the smaller than usual lots allocated to the position on XAUUSD?
 
DomGilberto:
Why would that be the reason for the smaller than usual lots allocated to the position on XAUUSD?
So do you get a compile error ? or is it a typo ? or did you declare Digit and s as something ? and if you declared Digit what is it's value ?
 

None - I'm saying that what I have shown you in that code above works on all the FX pairs perfectly... On the XAUUSD, it works perfectly but the lots allocated to the trade is like half of what it probably should be; in accordance to what % risk of my balance I intend on using per trade...

So in layman's terms; I want to risk 2%, if that trade (XAUUSD) stops out, it'll be more like a 1% loss instead.... its weird?

UPDATE: sorry I accidentally spaced out the s from Digit... So you lot could read it easier! It is supposed to be Digits (the function).

I guess what I'm trying to say is, my account being GBP denominated is having an affect on the correct lot sizing that should be allocated... where as if I had a USD account, would it not be more accurate (correct me if I am way off!).

 
DomGilberto:
None - I'm saying that what I have shown you in that code above works on all the FX pairs perfectly... On the XAUUSD, it works perfectly but the lots allocated to the trade is like half of what it probably should be; in accordance to what % risk of my balance I intend on using per trade...

So in layman's terms; I want to risk 2%, if that trade (XAUUSD) stops out, it'll be more like a 1% loss instead.... its weird?
OK, so print all the variables involved in the calculation, run it on XAUUSD and see which variable or variables are incorrect . . . then you will be closer to knowing why it's wrong.
 

double LotSize_Sell = MathFloor( risk_amount / loss_for_1_lot1/ Lot_Step) * Lot_Step ;
2013.11
.08 23:40:30     2013.06.19 19:00  V1 - XAUUSD XAUUSD,H1:  LotSize_Sell formula: ( 200 / 23.64 / 1 ) * 1 = 8
double loss_for_1_lot1 = pips_to_ssl/ ts * tv ;
2013.11.08 23:40:30     2013.06.19 19:00  V1 - XAUUSD XAUUSD,H1:  loss_for_1_lot1 formula: 23.64 / 0.01 * 0.01 = 23.64
 double pips_to_ssl = SellStopPrice - sellPrice;

2013.11.08 23:40:30     2013.06.19 19:00  V1 - XAUUSD XAUUSD,H1:  pips_to_ssl formula: 1378.45 - 1354.81 = 23.64

That's within the ST though... so as you've told me before, it'll be no different on the denomination of the account....

Does that look ok to you? "23.64" points?


(Update: Just so you know, they're the prints for the sell side! Sorry if that's confused you... I didnt realise :P)

 

As far as I can see, that should work ok.

Only thing that is a bit odd is TV = 0.01, seems low even for a micro account and wouldn't expect that for a GBP account.

Is it a spread betting account by any chance?

 
DomGilberto:
double pips_to_ssl = SellStopPrice - sellPrice;
Does that look ok to you? "23.64" points?

That's a change in price, not a number of points (2364.) You are not converting the change to number of points.

You don't want points in your

pips_to_bsl/ ts * tv

calculation. Rename the variable to change_to_ssl

 
No it's not a spread betting account.

@WHRoader - What do you mean I don't want points in that calculation? :s?

How can I apply the correct risk to the given trade based upon the distance to the stop if I don't include points in the formula...? (confused).

23.64 || 2,364 points... That's what I am trying to get my head around... To be frank, I'm convinced that I am applying too little 1 troy ounce positions because I have a GBP denominated account... I just need someone to tell me I am right / wrong from what I've shown?
 
DomGilberto:
No it's not a spread betting account.

@WHRoader - What do you mean I don't want points in that calculation? :s?

How can I apply the correct risk to the given trade based upon the distance to the stop if I don't include points in the formula...? (confused).

23.64 || 2,364 points... That's what I am trying to get my head around... To be frank, I'm convinced that I am applying too little 1 troy ounce positions because I have a GBP denominated account... I just need someone to tell me I am right / wrong from what I've shown?


Can you please show your code that results in this print?

double loss_for_1_lot1 = pips_to_ssl/ ts * tv ;

2013.11.08 23:40:30 2013.06.19 19:00 V1 - XAUUSD XAUUSD,H1: loss_for_1_lot1 formula: 23.64 / 0.01 * 0.01 = 23.64

Maybe you could add this print

Print("Account currency = ",AccountCurrency() );

to confirm that you are actually trading GBP in the ST because I can see no way that tv can be 0.01