Position Size Calculation

 
double pipValue(string sym)
   {
   double pValue=0;
   if (sym=="") { sym=Symbol(); }
   double bid   =MarketInfo(sym,MODE_BID);
   double ask   =MarketInfo(sym,MODE_ASK); 
   int lotsize = MarketInfo(sym,MODE_LOTSIZE);   
   if (StringFind(sym,CURRENCY)!=-1) { pValue=(Point * lotsize) / bid ; }    else
   if (StringFind(sym,CURRENCY,3)!=-1) { pValue=Point * lotsize; }   else { return(1/Point); }
   return (pValue/Point);   
   } 

double RiskLots = DollarRisk / (pValue * ((Ask - SL) / Point ));

RiskLots=MathMin(RiskLots,maxlots);


i have such routine. it works good on pairs which contain the base currency. For example if base currency is USD this calculation is exact for */USD USD/*. Does someone has a tip for me on pairs which dont have the base currency? For exampe EURJPY or GBPJPY?


thank you

 

Does someone has a tip for me on pairs which dont have the base currency? For exampe EURJPY or GBPJPY?

fx1, Lest I'm mistaken... 

if (StringFind(sym,CURRENCY)!=-1) { pValue=(Point * lotsize) / bid ; } // pValue will return 10. 
else  if (StringFind(sym,CURRENCY,3)!=-1) { pValue=Point * lotsize; } // will return 10 also. 
else { return(1/Point); } // will return 1000

TICKVALUE is essentially Point(1-pip) worth of movement in counter currency presented in your deposit currency. 

  • USDJPY - 1000 JPY pip movement when your deposit currency is in JPY 
  • GBPUSD - 10 USD pip movement when your deposit currency is in USD 
  • GBPCHF - 1000 CHF pip movement when your deposit is in CHF (convert that with USDCHF if your deposit is in USD and you have the same by calling TICKVALUE)

so on.... the above definition will hold. 1000 & 10 are QUOTE_TICKVALUE if you will. That is TICKVALUE in counter currency of any particular symbol. Any JPY counter Symbol will have 10 while others will have 1000.  

See here, page 5 also has the attachment you need.  I hope this won't be price per pip revisited... (crossing my fingers :)).