Discussing the article: "How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 2): Indicator Signals: Multi Timeframe Parabolic SAR Indicator"

 

Check out the new article: How to create a simple Multi-Currency Expert Advisor using MQL5 (Part 2): Indicator Signals: Multi Timeframe Parabolic SAR Indicator.

The Multi-Currency Expert Advisor in this article is Expert Advisor or trading robot that can trade (open orders, close orders and manage orders for example: Trailing Stop Loss and Trailing Profit) for more than 1 symbol pair only from one symbol chart. This time we will use only 1 indicator, namely Parabolic SAR or iSAR in multi-timeframes starting from PERIOD_M15 to PERIOD_D1.

The Multi-Currency Expert Advisor will use 1 indicator signals but with 5 Timeframes, starting from PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4 and PERIOD_D1

In this Expert Advisor, it does not use a fixed timeframe to calculate indicator signals, so there is no need to determine the signal calculation timeframe.

This means that the FXSAR_MTF_MCEA Expert Advisor can be used on any timeframe from PERIOD_M1 to PERIOD_MN1, and FXSAR_MTF_MCEA will still calculate signals based on iSAR PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4 and PERIOD_D1

These five Parabolic SAR Timeframes will determine the signal for open orders.

Meanwhile, to close orders when the signal weakens, use the iSAR indicator PERIOD_M15 provided the order is in profit condition.

And to do Trailing stop and Trailing profit, use the iSAR indicator PERIOD_H1.


iSAR Signals Condition Strategy Formula:

UP   = (PRICE_LOW[0] is greater than iSAR Line) or PRICE_LOW[0] > iSAR[0]

DOWN = (PRICE-HIGH[0] is smaller than iSAR Line) or PRICE-HIGH[0] < iSAR[0]

Where to get a BUY signal or SELL signal:

The five iSAR indicator timeframes must total 5 x UP for BUY and 5 x DOWN for SELL.

An illustration of the iSAR indikator untuk BUY atau SELL , can be seen in Figure 1

iSAR_Signal_Buy and Sell


Author: Roberto Jacobs

 

Boss, I learned some ideas about multiple varieties and multiple cycles, as well as some methods of drawing charts. Very practical.

thanks for your share

 
cloudchina #:

Boss, I learned some ideas about multiple varieties and multiple cycles, as well as some methods of drawing charts. Very practical.

thanks for your share

You're welcome.

 
Could you please elaborate the results of the optimization on the different pairs... will it return the best results for each pair? or the best results from among all pairs?
 
Camilo Mora #:
Could you please elaborate the results of the optimization on the different pairs... will it return the best results for each pair? or the best results from among all pairs?

This Expert Advisor does not trade only single pairs, but multi-currency or multi-pairs. So the test result is for all pairs (30 pairs provided).

 
Have you compare the time it takes to run say 1 loop of the entire EA with 30 pairs?. compare to say if one were to have 30 single currency EAs on each chart? a related question, if one is to run this multicurrentcy ea  on each tick or each bar, will the operation for a full loop be done before the next tick or bar arrives? The backtesting speed of this EA struck me as slow, given how fast other EAs are run.
 

Of course it's slow!  It is doing 30 times the calculations of the "Fast EAs", try running 30 Fast EAs simultaneously and see what happens.  I'll bet this EA is much much faster.  If the winning percentages in the test run of 75+% hold up, who cares about speed when you are winning 3 out of 4 trades? just buy faster machines.

With Multi-currency EAs. manual optimization of the code is a Necessity.Look at loops to move static assignments, use local variables in loops and functions to reduce calculation, make sure that there are not multiple calls of the same function, do as much work as possible in the OnInit function by moving one time calls and static calculations into global variables etc, etc, etc.

 To get around the symbol prefix suffix problem, consider using 2 variables for each symbol, pair for the 6 chr name and quoted for the full name with prefix and or suffix.  Either examine the name with a string function to set the two variables.

You may want to create an adaptive Parabolic Stop Loss that tracks the bars more closely, I think there are several adaptive PSAR indicators to use as a guide.

The work that Roberto has put into this EA should not be underestimated, it is very substantial.

 
CapeCoddah #:

Of course it's slow!  It is doing 30 times the calculations of the "Fast EAs", try running 30 Fast EAs simultaneously and see what happens.  I'll bet this EA is much much faster.  If the winning percentages in the test run of 75+% hold up, who cares about speed when you are winning 3 out of 4 trades? just buy faster machines.

With Multi-currency EAs. manual optimization of the code is a Necessity.Look at loops to move static assignments, use local variables in loops and functions to reduce calculation, make sure that there are not multiple calls of the same function, do as much work as possible in the OnInit function by moving one time calls and static calculations into global variables etc, etc, etc.

 To get around the symbol prefix suffix problem, consider using 2 variables for each symbol, pair for the 6 chr name and quoted for the full name with prefix and or suffix.  Either examine the name with a string function to set the two variables.

You may want to create an adaptive Parabolic Stop Loss that tracks the bars more closely, I think there are several adaptive PSAR indicators to use as a guide.

The work that Roberto has put into this EA should not be underestimated, it is very substantial.

Thank you for your support. I will create an article to add automatic detection and handling of brokers with special symbol names, prefixes and/or suffixes.

 

Roberto,

Bad News, I ran your EA on EURUSD H4 from 1/1/2023 to 11/1/2023 with $1,000 initial balance.  The EA bankrupted the account in less than 3 months.  With $10,000, it ran completely but lost  $8,250.  The graph shows consistent losses from start to end with no sharp peaks or valleys.

First Don't despair!  FX trading is tough and it is tougher still to design a multi-currency EA.  I know, I am in the midst of transforming one from MQ4 to MQ5.

It may be time to implement a variable pair capability to enable the specification of pairs to provide you with the ability to test on only one pair.  The easiest way is to have your pair string be an input item and use STRSPLIT to separate each pair in the string to enable loading of your pairs.  A better approach is to use your 30 pair display to allow the user to select the pairs for the run by clocking on them and changing color.  There are two recent GUI articles, GUI: Tips and Tricks...... 10/5/2023 and another set of Articles on Moveable GUIs.  I use the latter but I think the Tips and Tricks may be better and more complete.  You should also use the GUIs to display your data, which I think is excellent, instead of using the Comment function.

I am a firm believer in Pareto's Law: 80% of a characteristic comes from 20% of the elements.  This means that 80% of the overall profits come from 6 pairs and correspondingly 6 pairs contribute to 80% of the losses.

Enhanced Strategy Tester  statistics for individual pairs in a multi-currency test are mandatory to enable identification of problem areas and Pareto's Law.  Elements of the BackTest tab are needed on a pair level i.e Net Profit, Gross Profit Gross Loss etc. etc. etc.

I still think an adaptive process for the SAR would provide a improvement in your profits.  If you look at your Buy/Sell chart in your textabove, an adaptive function  that increases the acceleration speed of the SAR based on the Bar size increase would flex the SAR into giving you increased profits in the first 4 Buy/Sell illustrations on the chart.  This adaptive flex would provide two benefits:

it would provide an increase in profits of perhaps $5-$10 by closing the trade sooner.  More Importantly, it would allow the next trade to open $5-$10 earlier.  Thus, the impact of the flex could be $10-$20 overall for each trade.  However, it may also cause a lot of additional losing trades to be placed with a corresponding decrease in overall profits.

Concentrate on these targets and optimal time frames and your profitability will substantially increase.  I admit I haven't figured out a dynamic evaluation process yet.

 
CapeCoddah #:
I am a firm believer in Pareto's Law: 80% of a characteristic comes from 20% of the elements.  This means that 80% of the overall profits come from 6 pairs and correspondingly 6 pairs contribute to 80% of the losses.

Thank you for your input.

As I said in conclusions 4 and 5:

This FXSAR_MTF_MCEA Multi-Currency Expert Advisor is just an example to learn and develop ideas.

The test results on the Strategy Tester are still not good. Therefore, if a better strategy with more accurate signal calculations is implemented and adds some better timeframes, I believe the results will be better than the current strategy.

So, it's up to you to upgrade using what you say is an adaptive function to get better results.

Reason: