Skip to main content

Inputs & Variables Overview

Inputs are fixed settings, variables update dynamically—use both for smarter trading logic.

Updated over a month ago

Purpose

Inputs and variables define parameters for your EA. Inputs (constants) are set before execution and stay fixed, while variables update dynamically during runtime.

How It Works

  • Inputs → Predefined settings adjustable in MetaTrader before starting the EA.

  • Variables → Values that change automatically during execution based on trade logic.

  • Inputs are static, while variables adapt based on conditions.

Data Types (Used in both Inputs & Variables)

  • Double → Decimal numbers (e.g., lot size, price levels, risk percentage).

  • Boolean → True/False values (e.g., enable/disable trade conditions).

  • Timeframe → Select a timeframe for strategy execution.

  • Datetime → Store or reference specific timestamps for trading events.

Use Case

  • Use inputs for user-adjustable strategy settings like stop-loss levels.

  • Use variables to store trade counts, dynamic price levels, or custom calculations.

Note: Inputs must be set before execution, while variables update in real time.

Also, check out the below articles for a complete view on variables, inputs and how to use them:

Inputs (Constants)

Purpose

An Input (constant) is a predefined value that can be adjusted before running the EA but remains unchanged during execution.

How It Works

  • Defined in the MetaTrader parameters window before execution.

  • Cannot be modified while the EA is running—restart required.

  • Used in all EA blocks to customize behavior without editing code.

Use Case

  • Set default risk settings like lot size or stop-loss distance.

  • Adjust indicator parameters for testing different conditions.

  • Enable/disable trading features before running the EA.

Note: Inputs do not change dynamically—if adjustments are needed, variables should be used instead.

Variables

Purpose

A Variable stores and updates data dynamically during EA execution, allowing for real-time adjustments to trade logic.

How It Works

  • Variables are updated while the EA runs—no restart needed.

  • Used in logic calculations, tracking trade conditions, and modifying strategy parameters.

  • Can be changed using blocks like Modify Variables and Formula.

Use Case

  • Track the number of open trades dynamically.

  • Store price values for use in trailing stops.

  • Adjust trading logic based on real-time market conditions.

Tracking Variables on a Chart

Within the Inputs and Variables pane, you can select which variables you want to view live on your chart in Metatrader 5. This is a great feature for checking whether your variables are behaving as you expect. This can be great for debugging and checking EA data in real-time or in a backtest in Visual Mode.

Click the "eye" icon next to the variable you want to track on the chart. The variable will be visible on your Metatrader chart in the top-left corner.


Note: Unlike inputs, variables do not appear in the EA settings—they are controlled within the strategy.

Did this answer your question?