I have the following situation:
Given Symbol, the desired profit (let's say 20 USD) and :
double spread = MarketInfo(Symbol(), MODE_SPREAD);
double stopLoss = Bid - 30; //30 pips
double takeProfit =Bid +spread +30; //30 pips
How can I calculate the lot size for a potentially buy or sell order so the profit / loss to be = desired amount (20 USD)
Do I need to use a huge switch (for any Symbol) or maybe there is a better solution instead ?
At once correct.
double stopLoss = Bid - 30 * _Point; //30 pips
double takeProfit =Bid + (spread + 30) * _Point; //30 pips
You can try it like this
double newLot = 20 / (spread + 30) / SymbolInfoDouble(Symbol(), SYMBOL_TRADE_TICK_VALUE);