0% found this document useful (0 votes)
22 views10 pages

Url-0001

The document discusses the challenges of backtesting an Elliott Wave-based Expert Advisor (EA) that utilizes three timeframes in the MetaTrader 5 Strategy Tester. The main issue is the inability to test the synchronized interaction between the timeframes due to the tester's limitations, which can lead to code conflicts and inaccurate results. Suggestions include developing a custom indicator to manage the analysis across timeframes, but the author emphasizes the need for a testing environment that accurately reflects real-time interactions among the EAs.

Uploaded by

sstumbekobwby
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views10 pages

Url-0001

The document discusses the challenges of backtesting an Elliott Wave-based Expert Advisor (EA) that utilizes three timeframes in the MetaTrader 5 Strategy Tester. The main issue is the inability to test the synchronized interaction between the timeframes due to the tester's limitations, which can lead to code conflicts and inaccurate results. Suggestions include developing a custom indicator to manage the analysis across timeframes, but the author emphasizes the need for a testing environment that accurately reflects real-time interactions among the EAs.

Uploaded by

sstumbekobwby
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

How to Backtest an EA That Uses Three Timeframes in Strategy Tester?

1 2 3 New comment

210

Ahmd Fwzy Hamd ʿLy Albshbyshy 2025.02.07 08:06


Hey everyone,
I'm developing an Elliott Wave‐based EA that relies on three timeframes to analyze market structure and
find trade entries:

Higher timeframe (e.g., H1) → Identifies the larger Elliott Wave cycle.
Current timeframe (e.g., M15) → Trades based on wave structure.
Lower timeframe (e.g., M5) → Fine‐tunes entry timing.

I have no issues testing each timeframe separately, but my challenge is testing the relationship between
them in the Strategy Tester.

Key Problem:

The Strategy Tester only runs on one chart at a time, so I can’t simulate how my EA interacts
across multiple timeframes. In live trading, I use Global Variables to share data between
charts, and it works perfectly, but I need a way to validate this interaction in backtesting.

Things to Consider:

My EA is over 3000 lines of code and deeply structured for Elliott Wave analysis, so merging all
timeframes into a single instance isn’t practical.
I need to ensure that my higher timeframe waves correctly influence my lower timeframe trades
during backtesting.

Testing and optimization of Expert Advisors

MetaTrader 5 Built‐in Trading Strategy Tester

Testing visualization: chart, objects, indicators

Moderator
36632

Fernando Carreiro 2025.02.07 08:38 #1

Ahmd Fwzy Hamd ʿLy Albshbyshy: The Strategy Tester only runs on one chart at a time

The MT5 Strategy Tester is not limited to the default chart's time‐frame or symbol. Those are just the
"default".
Your EA can access and use multiple time‐frames and multiple symbols at the same time and trade all of
This website uses cookies. Learn more about our Cookies Policy.
them at the same time. The EA does not even need to depend on the current chart at all.
If your EA is incapable of that, then it is because it was programmed to only access and use the current
default time‐frame and symbol.
There are examples of multi‐time‐frame and/or multi‐symbol EAs in the CodeBase and even series of
articles dedicated to such EAs.
The limitation here is your own code logic, not the Strategy Tester.
There are many ways to do it, but here is one suggestion ...

1. Develop a custom indicator that carries out all of your "Elliot Wave" technical analysis for the current
symbol/time‐frame based on input parameters, and store the resulting data in various buffers.
2. From your EA, instantiate the custom indicator for each of the time‐frames you wish to analyse (e.g.
H1, M15, M5).
3. Access the buffers of each instantiated indicator (each of different time‐frame), and collate the data
to be used for your overall strategy rules.
4. Apply those rules and trade the symbol.

Back testing taking hours Problem during submitting EA Coding help

210

Ahmd Fwzy Hamd ʿLy Albshbyshy 2025.02.07 09:11 #2


Thank you for your suggestions, and I truly appreciate your insights on working with multiple timeframes
and symbols. However, I fully understand the approach you’re describing, and my question is more specific.
The issue I’m facing is that I need to test the strategy on three synchronized timeframes. The analysis I’m
performing is heavily reliant on the interaction between these timeframes, which means each timeframe
needs to constantly update based on the others. This isn’t just about handling multiple timeframes
individually; it’s about making sure that they work together and influence each other in real time for
accurate decision‐making.
I am already using a custom indicator across these three timeframes, which performs an initial scan and
then improves based on the relationship between the timeframes. This interaction is essential for precise
Elliott Wave analysis, and it’s crucial that all three timeframes are synchronized in their data to give me a
full picture of the market.
The problem arises when I try to implement this in a test environment. If I were to call smaller timeframes
from each larger timeframe, and then those smaller timeframes call even smaller timeframes in return, it
would create an infinite loop. This means that each timeframe could be calling data from the other in a
continuous cycle, which leads to code conflicts, unintended recursion, and system instability. This is a
major issue, as it would make the entire testing process unreliable and incorrect.
Additionally, if the timeframes are all interdependent, it’s essential that they are properly separated in
the logic to prevent them from triggering each other in a way that causes a breakdown in processing.
Without this separation, the logic would conflict, resulting in endless loops or incorrect calculations,
which would essentially make testing inaccurate.
In live trading conditions, this synchronization is crucial. The real‐time adjustments across the timeframes
are what allow me to correctly identify waves and make the right trading decisions. The problem isn’t
simply about analyzing multiple timeframes; it’s about making sure that they interact in a controlled,
synchronized manner without causing these issues. So, my main concern is about synchronized testing
across the three timeframes to reflect how the strategy works in a live scenario.
To summarize:

I understand how to implement and test multiple timeframes individually, but I need to test them
I understand how to implement and test multiple timeframes individually, but I need to test them
together in synchronization.
Without proper synchronization, I risk infinite loops, code conflicts, and incorrect data processing.
The real‐time interaction between the timeframes is essential for the accuracy of my Elliott Wave
analysis and trading decisions.

I’m looking for a way to perform synchronized testing on these three timeframes to ensure the strategy
functions as expected when the timeframes interact in real‐time.

General principles for executing Error fixing and debugging MetaTrader 5 Built‐in Trading

Moderator
36632

Fernando Carreiro 2025.02.07 09:35 #3

Ahmd Fwzy Hamd ʿLy Albshbyshy #: This isn’t just about handling multiple timeframes
individually; it’s about making sure that they work together and influence each other in real time
for accurate decision‐making.

And that is exactly what I answered. Your EA has to have the logic to handle all the necessary time‐frames
simultaneously, synchronously and globally. That is what multi‐time‐frames EAs do.

Ahmd Fwzy Hamd ʿLy Albshbyshy #: If I were to call smaller timeframes from each larger
timeframe, and then those smaller timeframes call even smaller timeframes in return, it would
create an infinite loop.

Then that is a design problem of you code logic. It is not an issue with the tester.

Ahmd Fwzy Hamd ʿLy Albshbyshy #: Additionally, if the timeframes are all interdependent, it’s
essential that they are properly separated in the logic to prevent them from triggering each other
in a way that causes a breakdown in processing.

Again, that is what your design logic needs to properly implement in your EA. The Strategy Tester is not
limiting that in any way.

Ahmd Fwzy Hamd ʿLy Albshbyshy #: The problem isn’t simply about analyzing multiple timeframes;
it’s about making sure that they interact in a controlled, synchronized manner without causing
these issues. So, my main concern is about synchronized testing across the three timeframes to
reflect how the strategy works in a live scenario.

It is up to you the developer, to implement that in your EA logic. Both the MQL5 language and the Strategy
Tester environment fully support you doing that.

Ahmd Fwzy Hamd ʿLy Albshbyshy #: I understand how to implement and test multiple timeframes
individually, but I need to test them together in synchronization.

Then implement it. Nothing is stopping you. You are only limited by your own coding skill and knowledge.

Ahmd Fwzy Hamd ʿLy Albshbyshy #: Without proper synchronization, I risk infinite loops, code
conflicts, and incorrect data processing.
Then that is a design flaw of your code. You will need to refactor it.

Ahmd Fwzy Hamd ʿLy Albshbyshy #: The real‐time interaction between the timeframes is essential
for the accuracy of my Elliott Wave analysis and trading decisions.

The Strategy Tester full supports and allows that. It is not preventing you from doing that.

Ahmd Fwzy Hamd ʿLy Albshbyshy #: I’m looking for a way to perform synchronized testing on these
three timeframes to ensure the strategy functions as expected when the timeframes interact in
real‐time.

Again, the Strategy tester fully allows you to access the data of every single time‐frame and every single
symbol, all simultaneously and synchronously. The "limits" you describe, are your own code logic, be it in
your EA or Custom Indicator design.

adding expiration date and EA will not run How To Restrict The

5351

Soewono Effendi 2025.02.07 14:04 #4


You might want to read this nice chapter in AlgoBook:
MQL5 Book: Creating application programs / Creating custom indicators / Multicurrency and multitimeframe
indicators

enjoy and good luck

MQL5 Book: Creating application programs / Creating custom indicators /


Multicurrency and multitimeframe indicators
www.mql5.com
Until now, we have considered indicators that work with quotes or ticks of the
current chart symbol. However, sometimes it is necessary to analyze...

210

Ahmd Fwzy Hamd ʿLy Albshbyshy 2025.02.07 17:45 #5

Fernando Carreiro #:

I’ve been a software developer for over 30 years, and I can confidently say that you’re completely missing
the point. The issue here is not about whether MQL5 allows multi‐timeframe access—it obviously does. The
real question is whether the Strategy Tester can effectively test interactions between multiple
interdependent timeframes in a realistic and synchronized environment.
Let me break it down for you:

1. You’re Confusing MQL Capabilities with Strategy Tester Limitations


1. You’re Confusing MQL Capabilities with Strategy Tester Limitations

You keep arguing that multi‐timeframe analysis works fine in MQL5 which is true. But that’s not what I’m
talking about. The problem isn’t the language itself; it’s how the Strategy Tester handles these
interactions when testing.
There’s a huge difference between:

Writing an EA that correctly accesses multiple timeframes in live trading (which is easy).
Accurately testing how those timeframes interact inside the Strategy Tester (which is the real
issue).

By insisting that the solution is to rewrite the EA, you’re completely ignoring the limitations of the
testing framework itself.

2. A Testing System Should Adapt to the Code, Not the Other Way Around

In professional software development, a QA team or testing framework doesn’t dictate how a system
should be built—it adapts to test real‐world functionality.
A proper testing framework should:
‐Allow multiple test cases to cover different use scenarios.
‐Support real‐time interactions between components.
‐Simulate actual market conditions without forcing artificial constraints.
If a QA team told a software engineer, “Your application design is wrong because our test framework can’t
handle it,” that would be embarrassing for the QA team, not the developer. That’s exactly what’s
happening here.

3. The "Infinite Loop" Argument Shows a Lack of Understanding

You mentioned the infinite loop issue as if it proves something about my coding approach. Actually, it
proves something about your misunderstanding of multi‐threaded and event‐driven systems.

In live trading, if an EA calls a higher timeframe for confirmation, that’s a natural and logical flow.
In the Strategy Tester, this can lead to loops not because the logic is wrong, but because the tester
is not designed to handle interdependent timeframes correctly.
The fact that third‐party tools exist to fix this should be enough proof that this is a tester issue, not
a developer issue.

4. External Tools Exist Because the Strategy Tester is Limited

If the Strategy Tester were already sufficient, we wouldn’t need external simulators. But professional
traders and developers use tools like:
+Soft4FX Simulator – Enables realistic multi‐timeframe and multi‐EA backtesting.
+FX Blue Trading Simulator – Allows interactive trade management during testing.
+QuantAnalyzer – Helps analyze multiple strategies and timeframe interactions.
Why do these tools exist if, according to you, the Strategy Tester is already perfect?

5. The Strategy Tester Would Be Better With These Modifications

I’m not saying the Strategy Tester is useless—far from it. It’s a great tool, but it could be significantly
improved by:
‐Supporting synchronized multi‐timeframe execution without breaking logical dependencies.
‐Simulating real‐time interactions accurately instead of forcing an artificial step‐by‐step approach.
‐Allowing multiple EAs (or strategies) to be tested together in a controlled environment.

Bottom Line

This isn’t a developer issue—it’s a Strategy Tester limitation. If you still believe that the solution is to
“just rewrite the EA,” then you’ve completely misunderstood the core problem. A real testing system
should adapt to real‐world logic, not force developers to modify their approach just to fit its constraints.
Until these improvements are made, the Strategy Tester will remain useful for basic validation, but
inadequate for serious multi‐timeframe and multi‐EA strategy testing.
inadequate for serious multi‐timeframe and multi‐EA strategy testing.

"Strategy Test" = joke Can a buffer update is there any solution

210

Ahmd Fwzy Hamd ʿLy Albshbyshy 2025.02.07 18:26 #6

Soewono Effendi #:
You might want to read this nice chapter in AlgoBook:
MQL5 Book: Creating application programs / Creating custom indicators / Multicurrency and
multitimeframe indicators

enjoy and good luck

Thank you so much for your assistance, I really appreciate your support.
I wanted to clarify that the issue I’m facing isn’t about working with multiple timeframes within a single
expert advisor, as I have already implemented that successfully. I’ve written over 3000 lines of code, and
everything is working fine, with the integration of both larger and smaller timeframes for Elliott Wave
analysis within the same expert.
The real challenge is that I need to test three separate instances of the expert advisor simultaneously,
each on its own chart with its own environment. The goal is to ensure that these three instances can
communicate with each other, as they would in a live scenario, and each of them would be running in its
own world, considering the three timeframes they operate on.
These three experts would be communicating with each other via Terminal’s global variables, enabling
significant improvements in the overall performance and coordination between them.
In other words, I’m looking for a way to test all three instances working together on different charts,
exchanging information and coordinating their actions. This integration and interaction need to be
properly tested.
Additionally, there are channels, Fibonacci retracements, and expansions being drawn on each chart. For
example, when I’m on the 15‐minute timeframe and taking a channel from the 5‐minute chart, the channel
may not appear correctly on the 15‐minute chart, but it’s accurate on the 5‐minute timeframe. While
running the backtest, I should be able to visually see the scenarios I’ve drawn, and to do this, all three
charts need to be running simultaneously. This is because the channel drawn on the 15‐minute chart might
span over 5 bars, and it will be correctly represented on the 5‐minute chart, but not on the 15‐minute one.
Moreover, there’s the issue of wave labeling for both smaller and larger waves. When all these elements are
drawn together on a single chart, the visual representation can become quite cluttered and imprecise. It
would be extremely difficult to assess the results accurately by eye unless all elements are functioning
correctly on their respective charts.
After reviewing the solution you provided, I believe it hasn’t fully resolved this issue. I would greatly
appreciate any further guidance you can offer on how to perform such a test.
Thanks again for your help, and I look forward to hearing from you soon.
Client terminal global variables Testing and optimization of Scripts and services

6059

Conor Mcnamara 2025.02.07 18:49 #7


To prevent an error like 4806, you simply need to use the highest timeframe out of the three as the testing
timeframe in the strategy tester. Then it (should) work correctly. As regards visually seeing 3 charts at the
same time, I'm not sure about this, I believe the the strategy tester only allows you to visualize one chart
at a time in visualization mode, but you can have 3 MTF indicators that each run in a separate window to
provide the visualizations that you need. It's possible to construct candlestick charts or line charts within
indicators (that run on the separate window).

EA gets diffrent indicator Any questions from newcomers See Indicators in Backtest

210

Ahmd Fwzy Hamd ʿLy Albshbyshy 2025.02.07 22:17 #8

Conor Mcnamara #:
To prevent an error like 4806, you simply need to use the highest timeframe out of the three as the
testing timeframe in the strategy tester. Then it (should) work correctly. As regards visually seeing
3 charts at the same time, I'm not sure about this, I believe the the strategy tester only allows you
to visualize one chart at a time in visualization mode, but you can have 3 MTF indicators that each
run in a separate window to provide the visualizations that you need. It's possible to construct
candlestick charts or line charts within indicators (that run on the separate window).

Thank you for your response and suggestions.


I just wanted to clarify that I am not encountering any errors. My expert advisor runs on any chart while
handling three timeframes:

The current timeframe, which is the main operational one.


The higher timeframe, used to identify the larger impulsive waves.
The lower timeframe, used to refine entries in small corrective movements.

The EA processes all calculations internally and uses indicators to plot waves for each timeframe. The
current timeframe is visualized directly on the chart, while the higher and lower timeframes are drawn
using indicators in the background. This setup allows for deep calculations, including channeling, Fibonacci
expansions, wave labeling, and re‐labeling, all dynamically adjusting based on price movements and cross‐
timeframe reviews.
This approach works perfectly in backtesting with no errors, producing good results. However, for live
trading, I have taken things a step further by running separate instances of the EA on different charts:

One on the lower timeframe.


Another on the higher timeframe.

This allows the current timeframe on each chart to act as the lower or higher timeframe relative to the
other, enabling the same deep calculations to be applied at each level. The EAs communicate using global
variables, refining wave structures and synchronizing critical data between timeframes. This enhancement
has significantly improved performance.
Unfortunately, the strategy tester does not allow testing all three instances together, which is the main
limitation I am facing. If you have any ideas on how to overcome this within the tester, I would greatly
appreciate your insights.
I’ve attached two images—one with the 4 months backtest result (1‐9‐2024 to 16‐1‐2025) and another while
the backtest is running. Please take a look at the green channel.In this case, I am in Wave 4 on the current
timeframe. To analyze its internal structure and determine the correct entry point as Wave 4 nears
completion ,I’ve actually managed to implement this successfully , I moved to the lower timeframe (5‐
minute chart) and identified a ZigZag (ABC correction). The channel was drawn on the lower timeframe
using the price and time of points A, B, and C. I then projected this channel onto the current timeframe
(where Wave 4 is forming) to visualize it properly. However, if the channel is not perfectly aligned, it does
not appear clearly on the higher timeframe, making it difficult to assess. All of this was drawn and
executed entirely through code on the three timeframes without any manual intervention.
The issue is that I can’t properly visualize these interactions in the strategy tester. In live trading, I can
see how the channels and structures adjust dynamically across timeframes, but in backtesting, I can’t fully
analyze these refinements to know what needs improvement.
My problem is not with handling the three timeframes or with the test itself.
The issue is that the backtest does not take into account the refined data written by each expert while
running, which is used to adjust the latest formation of each wave on each timeframe as they are
continuously updated.
I want to see three instances of the expert running together in the backtest, interacting and refining
each other, and watch the three charts running in front of me during the visual test. This way, I can
identify any issues with the analytical drawings on any timeframe, such as channels, waves, or internal
labeling.
Thank you so much for your help and valuable insights. I really appreciate the time and effort you've put
into understanding my issue. I look forward to any further suggestions you may have.
Files: Screenshot_l3705q.png 192 kb
Screenshot_x3706s.png 174 kb

Program types and their Determining Expert Advisor parameters Client terminal global variables

6059

Conor Mcnamara 2025.02.08 00:34 #9


It's a limitation in the software. The Strategy Tester's visual mode is primarily designed to display a single
chart. It would have to be a future development request.
You can relay information from different charts, you can have multi‐timeframe drawings or indicators from
different charts, but you can't display 3 different charts simultaneously.
Why don't you make a custom indicator that draws everything on a specific time period in the separate
window on top of candles. Then make one EA run 3 instances of the indicator (on different periods) for all
visuals. There may be problems as iCustom can really slow down the strategy tester, but this is all I can
think of as a solution.

Drag and drop SL Machine learning in trading: Find ChartID by periode


210

Ahmd Fwzy Hamd ʿLy Albshbyshy 2025.02.08 01:00 #10

Conor Mcnamara #:
It's a limitation in the software. The Strategy Tester's visual mode is primarily designed to display a
single chart. It would have to be a future development request.
You can relay information from different charts, you can have multi‐timeframe drawings or
indicators from different charts, but you can't display 3 different charts simultaneously

What I actually need is to see the lower timeframe on the lower chart and the higher timeframe on the
higher chart, so I can visually analyze the patterns and price actions directly on those charts.This way, I
can see how everything is fitting together, just like how the price action is displayed on the current chart,
without needing a separate window for the indicator.
So, my goal is to have everything running directly on the charts for each timeframe (current, higher, and
lower) in real‐time to observe how the patterns and price action are aligning. This allows me to visualize
everything in sync, as shown on the current chart.
Indeed, I can retrieve information from multiple charts, and that part works fine. However, the real
challenge arises when trying to test multiple Expert Advisors that interact with each other, or even testing
the same Expert Advisor in different instances, all running on the same tick simultaneously. Unfortunately,
this capability is currently limited, and it's not possible to conduct such tests effectively within the
strategy tester at the moment.
I believe this could be relatively straightforward for MetaQuotes to implement. By creating two or three
threads or more as required, each working on a different chart, (and allowing each thread to write to and
read from the terminal’s global variables which already exist and i tested it), it would be possible to sync
the tests. The strategy tester could then handle the synchronization, ensuring all three run together at
the same tick without one leading the other. This seems like a manageable task for those who already have
the framework in place for the strategy tester.
This is exactly how it works in enterprise systems, where different components or services operate
independently but interact with each other through defined interfaces. Each part has its own input and
output, and they work in harmony to achieve the overall goal without being aware of each other's inner
workings.
This approach allows me to leverage each expert as an independent unit within the system. If I need
information from one, I can simply access it through the global variables without modifying the core code.
This also means I can easily integrate and communicate with experts developed by others, ensuring a
smooth exchange of data and functionality, all while keeping everything modular and adaptable.
All of this is fully supported within MetaQuotes and works perfectly. I’ve tested it and it functions as
expected. However, the issue arises when trying to conduct a test with these components working
together simultaneously. Unfortunately, the testing functionality doesn't currently support this kind of
integration.

My approach. The core If you preset the Quantitative trading

1 2 3 New comment

MetaTrader 5 Trading About MetaTrader 5


Platform
Platform
Timeline
MetaTrader 5 latest updates
Terms and Conditions
News, implementations and
Recurring Payment
technology
Agreement MQL5 Channels
MetaTrader 5 User Manual
Agency Agreement – Offer
MQL5 language of trading
Privacy and Data Protection
strategies
Policy Economic Calendar
MQL5 Cloud Network
Cookies Policy
End‐to‐End Analytics
Contacts and requests
Download MetaTrader 5 Follow us on
socials for top
Install Platform articles and
Uninstall Platform CodeBase updates

Not a broker, no real trading


accounts
35 Dodekanisou str, Germasogeia,
4043, Limassol, Cyprus
Copyright 2000‐2025, MetaQuotes Ltd

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy