Capital At Risk (not getting it right)

 

Can anyone see whats wrong here?

It calculates true risk, that is $ loss if all open trades goes to StopLoss, and displays that

in an info board in the UL corner.

But it shows too low values, at least some 500% too low. Seems to vary

from one symbol to another.

Can't see what I've done wrong here...

//---------------- CalcSymbolDigits -------------------
void  CalcSymbolDigits() {
//Disregarding broker digits, we ONLY consider actual Symbol digits
//All pip values are entered as decimal pips, 4-digit broker style..
//E.g: 20.5 (20.5 pips) This goes for 2,3,5 digit symbols for both
//4-digit and 5-digit brokers. The decimal denotes true pip for
//5-digit brokers only. For 4-digit brokers the decimal should be
//set to "0".
   SymbolPointMul=1;
   if(Digits==2) SymbolPointMul=1;
   if(Digits==3) SymbolPointMul=10;
   if(Digits==4) SymbolPointMul=1;
   if(Digits==5) SymbolPointMul=10;
return (0);
}
//-----------------------------------------------------

//---------------- CapitalAtRisk ----------------------
double CapitalAtRisk() {
   //Capital At Risk (in $ ) for a given order = Lots * (StopLoss+spread) * Pipvalue
   //search through our open orders and sum up:
   double   CAR = 0;
   double   SLpips;//Selected order's SL level in pips, incl spread
   double   Spread = MarketInfo(Symbol(), MODE_SPREAD);//True pips
   for(int pos=0; pos < OrdersTotal(); pos++) {
      if(OrderSelect(pos,SELECT_BY_POS)==false) continue;//All done, or none found      
         if( (OrderMagicNumber() == MagicNumber) && (OrderSymbol() == Symbol())) {
            SLpips = (MathAbs(OrderOpenPrice() - OrderStopLoss()) /(Point * SymbolPointMul)) + Spread;                        
            CAR = CAR + OrderLots() * SLpips * MarketInfo(Symbol(),MODE_TICKVALUE);
            }
         }     
return (CAR);
}
//-----------------------------------------------------
 

Replace Point to MarketInfo(OderSymbol(),MODE_POINT)

The same problem with Spread

 

Why?

Isn't Point the same as MarketInfo(Symbol(), MODE_POINT) ??

 
No, this Point for the symbol, what chart your EA was launched only. And if you trade few currencies, it will mess you. But if you use the one currency only, its are equal.