Calculate Lot Size and Trailling Stop – EA MetaTrader 5
I. Condition Buy-Sell 2. Backtest 1. Main function for calculate lot size //+——————————————————————+ //| caculate lot sisze Function | //+——————————————————————+ double calculate_lotsize(double sl, double price) { double lots=0.; double lotstep= SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP); double ticksize = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE); double tickvalue = SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE); double balance= AccountInfoDouble(ACCOUNT_BALANCE); double point= SymbolInfoDouble(_Symbol,SYMBOL_POINT); //double loss=MathRound((MathAbs(price-sl)/ ticksize) * ticksize ); double loss=MathAbs(price-sl)/point; m_symbol.NormalizePrice(loss); double Risk= initial_risk*balance; if(loss!=0) … Read more