Sure! Could you please provide the context or the code snippet where you'd like the lot size to be included as an input? For example, is this for a trading bot, a form, or some other application? That way, I can tailor the code specifically to your needs.
User
Assistant
To include Lot Size as an input parameter so you can easily specify the position size for trades, you'll need to:
//+------------------------------------------------------------------+
//| MT5-Scalper-EA-FINAL.mq5 |
//| Open trades at specified time only |
//| with trailing stop functionality |
//+------------------------------------------------------------------+
#property copyright "2025"
#property version "2.20"
#property description "Open one or more buy/sell trades at specified time with TP/SL, spread filter and trailing stop."
#include <Trade\Trade.mqh>
//---- INPUTS
input int Slippage = 3; // Allowed slippage (points)
input int TP_Points = 200; // Take-profit (points)
input int SL_Points = 200; // Stop-loss (points)
input int MaxSpread_Points = 18; // Max allowed spread (points)
input int MagicNumber = 123456;
// New inputs for timed trades
input int TradeHour = 0; // Trade execution hour (0-23)
input int TradeMinute = 30; // Trade execution minute (0-59)
input int TradesToOpen = 1; // Number of trades to open at the specified time
input int TradeDirection = 0; // 0=Buy, 1=Sell, 2=Both (buy & sell)
// Trailing stop input
input int TrailingStop_Points = 50; // Trailing stop distance in points. 0 = disable
//---- GLOBALS
CTrade trade;
// Track if trades have been placed at specified time today
datetime lastTradeDay = 0;
bool tradeExecutedToday = false;
//+------------------------------------------------------------------+
//| Helper function to get date-only (time at 00:00:00) |
//+------------------------------------------------------------------+
datetime DateOfDay(datetime time)
{
MqlDateTime tm;
TimeToStruct(time, tm);
tm.hour = 0; tm.min = 0; tm.sec = 0;
return StructToTime(tm);
}