Calculate lot size from Takeprofit(distance in pips) and expected profit in Dollars(or any deposit currency)

 

Hi,

Im currently using this formula to get the lot size:

ThisLot = NormalizeDouble(( (MarketInfo(Symbol(), MODE_TICKVALUE)  * ( (TakeProfit + SPREAD())*Ponto(Symbol()) ) ) / MathAbs(EPTotalBuyProfit) ),lotDigits) ;

Function Ponto()

double Ponto(string symbol) {
        if (StringFind(symbol,"JPY") >=0) {
                return(0.01);
        } else {
                return(0.0001);
        }
}

I have read that the correct way to calculate the profit would be:

profit = MarketInfo(Symbol(), MODE_TICKVALUE) * OrderLots() * pips;

Im not getting the expected results.. Any input on how to solve this equation?

Thnaks

 
Try looking at my code here.