Hello everyone. Ive been trying to figure this out for some time now but havnt been able to. Some help with this would be fine. The code below is what implements my long transactions but I keep receiving OrderSend mistake 4051 invalid lots sum for OrderSend function. Ive tried different methods but nothing seems to work. By using this code within my lot dimensions im trying to get a lot dimensions that is only going to risk my percentage per trade but using a variable stoploss in reference. The stoploss varies from trade to trade since its the lowest low in 50 candle back. If you know of a simpler or better way that would also be valued.

Edit:'m seeking to incorporate risk/money management into my transactions using this method.

Variables Code:
Inserted Code extern int Risk_Percent = 3; //Percent of the account to risk per trade. Dual LowestShift = iLowest(Symbol(), PERIOD_H1, MODE_LOW, 50, 1); //Find the candle using the lowest non in 50 candles back. Double Lowest = iLow(Symbol(), PERIOD_H1, LowestShift); //Find the low of the candle utilized by LowestShift double Buy_Take_Profit = ((Bid-Lowest) Ask); //To make the trade 1:1
Execution Code:
Inserted Code if (Condition1 gt; Condition2) if (Condition3 lt; Condition4) if (Condition5 lt; Bid) if (getOpenOrders() == 0) double Buy_Lots = NormalizeDouble(((AccountBalance()*(Risk_Percent/100))/(((Bid-Lowest)*100000)*(MarketInfo(Symbol(),MODE_TICKVALU E)))),2); Buy_Order = OrderSend(Symbol(),OP_BUY,Buy_Lots,Ask,30,Lowest,B uy_Take_Profit,NULL,2000,0,clrGreen);