MQL5 Tutorial – How to simply adjust user input with MQL5



  1. Introduction to Enhancing a Simple Expert Advisor (00:00 – 00:07) Introduction to improving a simple expert advisor by allowing user adjustments, following the results of a year-long test.
  2. Reviewing the Year-Long Test Results (00:07 – 00:19) Overview of the test results: 73 trades made, with 54 short trades and 19 long trades, and the lack of adjustable inputs.
  3. Enabling User Adjustments for Lot Size (00:19 – 00:30) The goal to enable users to adjust the lot size of trades, which is currently hard-coded in the source code.
  4. Modifying the Expert Advisor to Include Input Variables (00:30 – 00:43) Steps to modify the expert advisor to include input variables, specifically for adjusting the lot size.
  5. Creating a Dynamic Input Variable for Lot Size (00:43 – 00:56) Instructions on creating a dynamic input variable for lot size, allowing it to be changed by the user.
  6. Replacing Fixed Lot Size with the New Variable (00:56 – 01:03) Replacing the fixed lot size in the code with the new variable and saving the changes.
  7. Compiling the Code and Testing the New Feature (01:03 – 01:17) Compiling the updated code and testing the new feature in Metatrader, with visualization enabled.
  8. Observing the Adjustable Lot Size in Action (01:17 – 01:28) Observing the first trade with the new adjustable lot size and stopping the test to change the input.
  9. Changing the Lot Size and Testing Again (01:28 – 01:43) Adjusting the lot size to a different value and testing again to demonstrate the flexibility of the new input feature.


In one of our other videos we have created a simple buy trade system and this is the result of a whole year.
It made seventy three trades, fifty four were short trades and nineteen were long trades.
You see under the input tab we have absolutely no values here so we cannot set anything that is not hardcoded in our source code.
Now we want the user to be able to adjust the Lot Size of a trade here, to do that we simply click on Simple Buy Trade and click Modify.
This is how our short E.A. looks like and this is the Lot Size.
To create a dynamic value that can be changed by the user you have to make it an input variable and will be a double variable, and we will call it MyLotSize.
Let’s assign ten Micro Lot here, copy the name and exchange the fixed ten Micro Lot Size here with our new variable.
I will save it as Simple Buy Trade with input. Let’s compile the code and hit F4 to bring up the Meta Trader.
I will select the system here, check the visualization option and start the test. This is our first trade and its ten Micro Lot.
Let’s stop the test, go to inputs and change it to 0.2, now it is 20 Micro Lot.
If you make something adjustable by the user, you can do it by making it an input.
Afterwards the value can be simply changed without recompiling the code.

Download “MQL5 Simple Buy Trade with User Input EA from MQL5 Tutorial”

SimpleBuyTradeWithInput.txt – Downloaded 453 times – 381.00 B