Skip to main content

How to Create, Edit, and Use Inputs and Variables

Need to create, edit, or fix Inputs and Variables? Learn where to find Inputs & Variables in the Builder, how to add them, choose the right type, name them correctly, use them in blocks, and show variables on the MT5 chart.

Summary

Inputs and Variables both store values for your EA, but they are used for different jobs.

The simple rule:

Inputs = settings you choose before the EA starts 
Variables = values the EA can remember and update while it runs

Use Inputs for settings you want to adjust in MT5 before running or backtesting, like risk %, stop loss size, or indicator period.

Use Variables when the bot needs to store, update, or remember something during the strategy, like today’s high, previous candle low, a daily trade gate, or a custom calculation.

Also known as: bot settings, MT5 inputs, stored values, dynamic values, variable logic, Formula values, Modify Variables, previous candle high, session high/low.


Where to find Inputs and Variables

You can find Inputs and Variables in the bottom-left corner of the Builder.

Click:

Inputs & Variables

A window will open where you can create, edit, search, and manage your Inputs and Variables.

Use this window to:

  • add new Inputs

  • add new Variables

  • edit names

  • choose the type

  • set default values

  • show Variables on the MT5 chart with the eye icon

Click Inputs & Variables in the bottom-left corner of the Builder to create, edit, and manage all Inputs and Variables used in your project.


How to create a new Input or Variable

Inside the Inputs & Variables window, there are separate sections for:

Inputs
Variables

To add a new one:

  1. Click the plus icon in the Input or Variable section.

  2. Give it a clear name.

  3. Choose the correct type.

  4. Add a suitable default value if required.

  5. Use the Input or Variable inside your blocks.

Use an Input when the value should be adjustable before running or backtesting the EA.

Use a Variable when the EA needs to remember, update, or reuse the value while it runs.

Example:

Input: Risk_Per_Trade = 1
Variable: London_High = 0

Risk_Per_Trade is an Input because the user may want to change it in MT5 before testing.

London_High is a Variable because the EA calculates and updates it while the strategy runs.


The core mental model

Think of your EA like a simple decision system.

It needs three things:

  1. Settings
    Values you choose before the EA starts -> INPUTS

  2. Memory
    Values the bot stores and updates while it runs -> VARIABLES

  3. Logic blocks
    Blocks that read, compare, calculate, or change those values.

In the Builder, that means:

Input = setting Variable = memory 
Formula block = calculate and store a value Modify
Variables block = directly change a variable
Trade Rule block = compare two values

Example:

Input: Risk_Per_Trade = 1% 
Variable: Previous_High = 0

Run per Candle
→ Modify Variables: Previous_High = Candle High ID 1
→ Trade Rule: Bid crosses above Previous_High
→ Buy Now

The input controls the risk setting.
The variable stores the previous candle high.
The Trade Rule checks whether price breaks that stored level.

That is the basic flow.


Inputs vs Variables in one table

Question

Use Input

Use Variable

Should the user set this before the EA starts?

Yes

No

Should it appear in the MT5 EA settings?

Yes

No

Should it change while the EA is running?

No

Yes

Is it used for optimization/backtesting settings?

Yes

Sometimes

Is it used to remember market data or strategy state?

No

Yes

Can Formula or Modify Variables update it?

No

Yes

Can it be visualized on the MT5 chart?

No

Yes


Inputs

What is an Input?

An Input is a fixed setting.

You choose it before starting the EA or before running a backtest in MT5.

Once the EA is running, the input stays the same.

Use inputs for values you want to test, optimize, or adjust without rebuilding the project.


Common Input examples

Use inputs for:

  • Risk per trade

  • Lot size

  • Stop loss size

  • Take profit size

  • Moving Average period

  • RSI period

  • Maximum spread

  • Session start time

  • Session end time

  • On/off switches for optional logic

Example:

Input: Risk_Per_Trade = 1 
Input: Stop_Loss_Pips = 30
Input: Take_Profit_Pips = 60
Input: MA_Period = 20

These are settings. The user can adjust them in MT5 before running the EA.


When should I use an Input?

Use an input when the value should be adjustable from MT5 before the EA starts.

Good question to ask:

“Do I want to change this setting before running or backtesting?”

If yes, use an Input.

Example:

You want to test a Moving Average strategy with different periods:

MA_Period = 20 
MA_Period = 50
MA_Period = 100

That should be an input because you want to adjust it before testing.


Important limitation

Inputs do not update while the EA runs.

If the value needs to change during the strategy, use a Variable instead.

Bad use of input:

Today_High = input

The daily high changes while the market moves. That should be a variable, not an input.


Variables

What is a Variable?

A Variable is a value the EA can store, update, and reuse while it runs.

Think of a variable as the bot’s memory.

At first, a variable usually starts with a default value like 0.

Then blocks can update it later.

Example:

Variable: London_High = 0

At the start, the bot knows nothing yet, so the value is 0.

Later, the EA can update it:

Modify Variables: London_High = Highest High of London session

Now the bot remembers the London high and can use it in a Trade Rule.


Common Variable examples

Use variables for:

  • Previous candle high

  • Previous candle low

  • Session high

  • Session low

  • Daily high

  • Daily low

  • Trade gate: 0 or 1

  • Counter

  • Custom indicator signal

  • Candle range

  • ATR stop size

  • Breakout level

  • Last trade time

  • Whether a condition already happened

Example:

Variable: Buy_Gate = 0 
Variable: Previous_High = 0
Variable: London_High = 0
Variable: ATR_Stop_Size = 0

Show variables on the MT5 chart

You can show variable values directly on the MT5 chart while testing your EA. In the Inputs & Variables window, click the eye icon next to the variable you want to track. After exporting and running the EA in MT5 Visual Mode, the selected variable appears on the chart. This is useful for checking if values like Previous_High, London_High, Buy_Gate, or ATR_Stop_Size are being stored, updated, and reset correctly. Use this as a simple debugging method before changing your strategy logic.


When should I use a Variable?

Use a variable when the EA needs to remember or update something while it runs.

Good question to ask:

“Does the bot need to calculate, store, update, or remember this value?”

If yes, use a Variable.


How Variables connect to blocks

Variables do nothing by themselves.

They become useful when blocks interact with them.

1. Create the variable

Example:

Variable: Previous_High = 0

This creates a named storage container.


2. Modify the variable

Use Modify Variables when you want to directly assign a value.

Example:

Previous_High = Candle High ID 1

This stores the high of the last closed candle.


3. Calculate a variable

Use Formula when you need a calculation.

Example:

Candle_Range = Candle High ID 1 - Candle Low ID 1

The 'Formula' block calculates the range and stores the result in Candle_Range.


4. Compare the variable

Use a Trade Rule when you want to compare the variable against another value.

Example:

Bid crosses above Previous_High

If true, the bot can continue to the next block.


5. Use the variable in execution or management

Variables can be used for:

  • Entry levels

  • Stop loss distances

  • Take profit distances

  • Trade filters

  • Management logic

  • Daily limits

  • Session breakout levels

Example:

Buy Pending Order at London_High

The EA uses the stored variable as the order level.


Example 1: Stock example

Goal

Buy a stock CFD if price breaks above the previous candle high.

Use an input for risk and a variable for the previous high.

Setup

Input: Risk_Per_Trade = 1 Variable: Previous_High = 0

Logic

Run per Candle → Modify Variables: Previous_High = Candle High ID 1

This updates Previous_High once every new candle.

Then:

Run per Tick 
→ Trade Rule: Bid crosses above Previous_High
→ Count Trades: Buy trades = 0
→ Buy Now

Why this works

Risk_Per_Trade is an input because it is a setting you choose before running.

Previous_High is a variable because it changes every candle.


Example 2: Forex example

Goal

Trade a breakout of the London session high on EURUSD.

Use an input for maximum spread and a variable for the London high.

Setup

Input: Max_Spread = 20 Variable: London_High = 0

Logic

At the end of the London session:

Run at Time: 15:00 → Modify Variables: London_High = Highest Candle High from Candle ID 1 to Candle ID 8

During the New York session:

Run in Session: 15:00 to 21:00 
→ Check Spread: spread below Max_Spread
→ Trade Rule: Bid crosses above London_High
→ Count Trades: Buy trades = 0
→ Buy Now

Why this works

Max_Spread is an input because you may want to adjust it before testing.

London_High is a variable because it changes every day based on the session.


Example 3: Previous candle high and low

Goal

Store the previous candle high and low, then use them as breakout levels.

Setup

Variable: Previous_Candle_High = 0 Variable: Previous_Candle_Low = 0

Store the values

Run per Candle 
→ Modify Variables:
Previous_Candle_High = Candle High ID 1
Previous_Candle_Low = Candle Low ID 1

Candle ID 1 means the last fully closed candle.

Do not use Candle ID 0 for this example, because Candle ID 0 is still forming and can change.

Use the values

Buy breakout:

Trade Rule: Bid crosses above Previous_Candle_High 
→ Count Trades: Buy trades = 0
→ Buy Now

Sell breakout:

Trade Rule: Bid crosses below Previous_Candle_Low 
→ Count Trades: Sell trades = 0
→ Sell Now

Why this works

The EA stores the previous candle levels first.

Then it uses those stored levels in Trade Rules.

That is the logic flow:

Store level 
→ Compare price to level
→ Execute trade if true

Example 4: Daily trade gate

Goal

Allow only one buy trade per day.

Setup

Variable: Buy_Gate = 0

Meaning:

0 = buy allowed 
1 = buy blocked

Entry logic

Run per Candle 
→ Trade Rule: Buy_Gate = 0
→ Buy Now
→ Modify Variables: Buy_Gate = 1

After the trade opens, the EA changes Buy_Gate from 0 to 1.

Now the next buy trade is blocked.

Reset logic

Run at Time: 01:00 
→ Modify Variables: Buy_Gate = 0

The next day, the gate resets and buying is allowed again.

Why this works

The variable remembers whether the bot already traded today.

An input cannot do this because the value must change while the EA runs.


Choosing the right data 'type'

Every Input and Variable needs a type. The type tells the Builder what kind of value it should expect.

Type

Use for

Example

Number

Prices, risk %, lot size, indicator values, pip values

Risk_Per_Trade = 1, London_High = 1.08500

Boolean

True/false or on/off settings

Use_RSI_Filter = true

Timeframe

Selecting a chart timeframe

Signal_Timeframe = H1

Time

Session times or time-based settings

Session_Start = 09:00

For many strategy examples, we also use 0 and 1 variables:

0 = off / false / inactive
1 = on / true / active

Example:

Buy_Gate = 0
HMA_Green = 1

Important: use a value that matches the selected type.

Bad:

Risk_Per_Trade = one

Good:

Risk_Per_Trade = 1

Use 1.5, not 1,5, for decimal values.


How to check if variables work

You can show variables directly on the MT5 chart.

In the Inputs & Variables panel, click the eye icon next to the variable.

Then export and test in MT5 Visual Mode.

Use this to check:

  • Is the variable updating?

  • Is the value correct?

  • Does it reset at the right time?

  • Is the stored price level correct?

  • Does the Trade Rule compare against the right value?

Example:

If London_High should store the session high, show it on the chart and confirm the value before trusting the breakout logic.


Naming rules for Inputs and Variables

Good names prevent export errors.

Use clear, unique names that explain what the value is used for.

Good examples:

Risk_Per_Trade
London_High
Buy_Gate
ATR_Stop_Size
Previous_Candle_Low

Avoid names that cause problems after export to MQL5.

Bad examples:

double
string
2endsession
end session
start-session
session #1
buy-gate
risk-per-trade

Better examples:

endSession2
startSession1
session_1_start
session_2_end
Buy_Gate
Risk_Per_Trade

Rules:

  • use unique names

  • avoid spaces

  • avoid hyphens

  • avoid special characters

  • do not start names with a number

  • use underscores if needed

  • do not use reserved words like float, bool, double, or string

  • keep spelling exactly the same across all blocks

The debug article already shows these naming issues as common Builder/project errors: invalid names, duplicate variables, renamed variables still referenced by blocks, unsupported characters, and missing default values can all break export or cause project errors.

If you rename an Input or Variable, check the blocks that used the old name. You may need to reselect the renamed Input or Variable inside those blocks.


Common mistakes

Mistake 1: Using an Input when the value should update

Bad:

Previous_High = Input

Better:

Previous_High = Variable 
Run per Candle → Modify Variables: Previous_High = Candle High ID 1

If the value changes while the EA runs, it should be a variable.


Mistake 2: Creating a variable but never modifying it

If you create:

London_High = 0

but never update it, the value stays 0.

You need a block like:

Modify Variables: London_High = Highest High of session

Mistake 3: Modifying a variable too often

If you place a Modify Variables block after Run per Tick, the variable may update many times per second.

That can be useful for live price tracking, but dangerous if you only wanted one update per candle.

Use:

Run per Candle

when the value should update once per candle.


Mistake 4: Using Candle ID 0 when you need a closed candle

Candle ID 0 is the current forming candle.

Its high, low, close, and indicator values can still change.

For most stable logic, use:

Candle ID 1 = last fully closed candle

Mistake 5: Expecting variables to appear in MT5 settings

Inputs appear in the MT5 EA settings.

Variables do not.

Variables are controlled by the strategy logic while the EA runs.


Best practice workflow

Use this order when building with inputs and variables:

1. Decide what should be adjustable before running    
→ create Inputs

2. Decide what the bot must remember while running
→ create Variables

3. Decide when the variable should update
→ Run per Candle / Run at Time / Run in Session / Run per Tick

4. Store or calculate the value
→ Modify Variables / Formula

5. Use the value
→ Trade Rule / Buy Now / Sell Now / Pending Order / Management block

6. Export and test in MT5 Visual Mode
→ use the eye icon to check the variable values

Quick decision guide

Use this when you are unsure.

You want to...

Use

Adjust risk before testing

Input

Adjust stop loss before testing

Input

Test different MA periods

Input

Enable or disable a filter

Input

Store previous candle high

Variable

Store London session high

Variable

Store today’s low

Variable

Count candles

Variable

Remember if a trade happened today

Variable

Calculate candle range

Formula + Variable

Reset a value daily

Run at Time + Modify Variables

Compare price to stored level

Trade Rule

Show value on MT5 chart

Variable eye icon


Quick answer: where do I edit Inputs and Variables?

Open the Builder and click Inputs & Variables in the bottom-left corner.

There you can:

Add Inputs
Add Variables
Edit names
Choose types
Set values
Enable the eye icon for Variables

Use Inputs for settings you want to change before running the EA.

Use Variables for values the EA should remember or update while it runs.


Conclusion

Inputs and Variables are not the same.

Use this simple rule:

Inputs are settings. Variables are memory. Blocks control when values are read, changed, calculated, compared, or used.

If the value should be chosen before the EA starts, use an Input.

If the value should update while the EA runs, use a Variable.

When building, always think in this flow:

Create value → Update value → Compare value → Use value → Test in MT5 Visual Mode
Did this answer your question?