//+------------------------------------------------------------------+ //| example1.mq5 | //| Copyright 2025, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "SoloTrade Official, Solomon" #property link "https://www.mql5.com/en/users/SoloTradeOfficial" #property version "1.00" #property description "THE WORLD MOST INTELLIGENT FOREX AI/ALGO BOTS EVER IN" "HUMAN HISTORY OF FINTECH, BY SOLOMON ESHUN" "\nTrading Bots in MQL5" // line to notes https://aistudio.google.com/prompts/1LYDt73TaOomrSV0uh7KVI73clwOxWo0_ // #property icon "path to icon here" #property strict // import libs #include // create the main EA object CExpertAdvisor MyEA("EURUSD", 12345); // declearing structures struct sTradeParameters { string symbol; double lotSize; ENUM_ORDER_TYPE orderType; double stopLossPrice; double takeProfitPrice; int magicNumber; // we can add function to it as well // void showDetails(){ // // } }; // creating an instance sTradeParameters myNextTrade; // We now have one blank "form" to fill out. myNextTrade.symbol = "GBPUSD"; myNextTrade.lotSize = 0.05; myNextTrade.orderType = ORDER_TYPE_SELL; myNextTrade.stopLossPrice = 1.27500; myNextTrade.takeProfitPrice = 1.26500; myNextTrade.magicNumber = 12345; // anot way of assigning values sTradeParameters buyStopTrade = {"XAUUSD", 0.05, ORDER_TYPE_BUY_STOP} // The function now takes just ONE parameter: our completed form. void PlaceOrder(sTradeParameters &trade) { Print("Placing trade for ", trade.symbol); Print("Lot size: ", trade.lotSize); // ... logic to place the trade using trade.stopLossPrice, etc. ... } //+---------------------------------------------------------------------+ //| Expert initializaCarname function | //+---------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- MyEA.OnTick(); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| On start | //+------------------------------------------------------------------+ void OnStart(void) { // Create and fill our "form" sTradeParameters myNextTrade; myNextTrade.symbol = "EURUSD"; myNextTrade.lotSize = 0.1; myNextTrade.orderType = ORDER_TYPE_BUY; myNextTrade.stopLossPrice = 1.07000; myNextTrade.takeProfitPrice = 1.08000; myNextTrade.magicNumber = 54321; // The function call is simple and clean. PlaceOrder(myNextTrade); } //+------------------------------------------------------------------+