Adjustable MA

hello, im backtesting this ea on mt5 with my settings, here are results on real tick data of last 4 months
but it lost last year on same settings
 

Attachments

  • dor discord.png
    dor discord.png
    29.6 KB · Views: 10
  • for dis.png
    for dis.png
    47.8 KB · Views: 11
  • ℹ️
Reactions: Enivid
Discuss Adjustable MA expert advisor. Adjustable MA is a highly flexible moving average cross EA. You can ask any questions about this expert advisor here.

This Adjustable EA is not opening trade in my demo account. It's working very well on tester. I use Deriv zero spread account, please help!
 
The Adjustable MA expert advisor has been updated to version 1.07:
  • Added an option to restrict trading to a certain period of the day. (@Maverick)
  • Added an option to restrict trading to a single direction. (@DrSlater06)
  • Optimized trailing stop to make it work more reliably.
  • Changed how trades are opened and closed to allow for several attempts in case of a failure.
 
Would it be possible to include Time Frame, Start Hour, Start Minute, End Hour & End Minute so the settings can be fully optimised
The current Start and End inputs cannot be optimised
Having separate Hour and Minute inputs speeds up optimisation ... IMO

To save running two of the same EA's could there be AM and PM Start and End times
 
  • ℹ️
Reactions: Enivid
You left your mark, Enivid, but is it something you could assist with ?

If my test results are anything to go by, it would also help to NOT trade on Tuesdays and Thursdays

What I am suggesting ...
 

Attachments

  • Inputs.jpg
    Inputs.jpg
    51.6 KB · Views: 2
Noticed your interest, Enivid ... Are you able to implement my ideas ?

Have also noticed whilst testing that my asset does not like to trade Tuesdays or Thursdays

What I propose ...

Inputs.jpg

Pretty sure what I propose would increase the Profit Factor once optimised
Post automatically merged:

FYI ...

"AllowTrailingOutsideTradingTimes" is better English 🙂
 
Noticed your interest, Enivid ... Are you able to implement my ideas ?

Have also noticed whilst testing that my asset does not like to trade Tuesdays or Thursdays
//-----

perhaps you could add a checkday() function or include the additional condition in the checktime() function......h


MQL5:
bool CheckTime()
{
    if ((TimeCurrent() >= StringToTime(StartTime)) && (TimeCurrent() <= StringToTime(EndTime) + 59) ) // Using +59 seconds to make the minute time inclusive.
    {
        return true;
    }
    return false;
}
 
 
bool CheckDay()
{
    if (  ((DayOfWeek() == 1) && Monday)  ||   ((DayOfWeek() == 2) && Tuesday)  ||   ((DayOfWeek() == 3) && Wednesday)  ||   ((DayOfWeek() == 4) && Thursday)  ||   ((DayOfWeek() == 5) && Friday) )
    {
        return true;
    }
    return false;
}
 
 
//  never can remember how to spell wendsday
 
Yeah, but that won't happen soon.

One of my biggest regrets in life, if not THE biggest, is not learning how to write code

They will be teaching my granddaughter in primary school how to write code ... Tut

Looks like I will have to resort to MQL5 ... I hate how MQL5 is run ... cannot view a coder's feedback until after you are committed to them ... SIGH

At least I will be able to include my MM 🙂
 
One of my biggest regrets in life, if not THE biggest, is not learning how to write code
//-------

that's a easy regret to remedy......

try the checkday() function i wrote for you......h

//-----

Code:
input bool DoTrailingOutsideTradingTime = true;

input bool Monday    = false;
input bool Tuesday   = false;
input bool Wednesday = false;
input bool Thursday  = false;
input bool Friday    = false;



    if(CheckDay()) 
    {
    CheckCross();
    }
 
How would I set the EA to run until the next MA cross before taking profits ?

What does "TrailingStop" do, and at what point does the trailing stop start, and how far behind does it trail ?

Inputs_Original.jpg
 
How would I set the EA to run until the next MA cross before taking profits ?
If you set TakeProfit to 0, it will only close a trade on the next cross. If you want it to add take-profit only after a cross, this EA cannot do it.

What does "TrailingStop" do
It sets the trailing stop distance. The stop-loss will be moved closer to the current price as the current price moves in the trade's favor.
and at what point does the trailing stop start
It starts immediately after the trade is opened.
and how far behind does it trail ?
The distance you set via that parameter.
 
Thank you, Enivid, for your clear instructions 🙂 In the past, I have been faced with 2 or 3 inputs for a trailing stop
If you set TakeProfit to 0, it will only close a trade on the next cross
When, presumably, it will open a trade in the opposite direction ?
 
Last edited:
Thank you, @Enivid, for your clear instructions 🙂 In the past, I have been faced with 2 or 3 inputs for a trailing stop
This EA has a very simple trailing stop function, so just one parameter to define the SL distance and no way to delay its triggering until some amount of profit is reached.
When, presumably, it will open a trade in the opposite direction ?
Yes, that's right.
 
I got this in my log (one of many) following the optimisation of my modified "Adjustable_MA"

Core 3 genetic pass (1, 319) tested with error "OnInit returned non-zero code 1"

Google explains it as

The error "Core 3 genetic pass (1, 319) tested with error OnInit returned non-zero code 1" in the MetaTrader 5 strategy tester indicates that the Expert Advisor (EA) failed to initialize during a genetic algorithm optimization. Specifically, the OnInit() function within the EA returned a non-zero code, signaling an initialization error. The "Core 3 genetic pass (1, 319)" part refers to the specific genetic algorithm iteration and the parameters being tested.

Some of the other numbers (2,275) (2,278) (2,439) (3,355) (3,416) (3,385) (3,359) (3,416) …

To be 100% sure the fault was not in my new code, I ran an original copy of "Adjustable_MA", optimising Period_1 and Period_2 and got the attached log

Please advise
 

Attachments

I got this in my log (one of many) following the optimisation of my modified "Adjustable_MA"

Core 3 genetic pass (1, 319) tested with error "OnInit returned non-zero code 1"

Google explains it as

The error "Core 3 genetic pass (1, 319) tested with error OnInit returned non-zero code 1" in the MetaTrader 5 strategy tester indicates that the Expert Advisor (EA) failed to initialize during a genetic algorithm optimization. Specifically, the OnInit() function within the EA returned a non-zero code, signaling an initialization error. The "Core 3 genetic pass (1, 319)" part refers to the specific genetic algorithm iteration and the parameters being tested.

Some of the other numbers (2,275) (2,278) (2,439) (3,355) (3,416) (3,385) (3,359) (3,416) …

To be 100% sure the fault was not in my new code, I ran an original copy of "Adjustable_MA", optimising Period_1 and Period_2 and got the attached log

Please advise
The EA fails to initialize when the period of the period of the fast MA equals the period of the slow MA. During the optimization, if you set overlapping ranges for the periods, this will happen. It shouldn't be a problem.
 
The EA fails to initialize when the period of the period of the fast MA equals the period of the slow MA. During the optimization, if you set overlapping ranges for the periods, this will happen. It shouldn't be a problem.
Thanks ... I will run the strategy tester without optimising the MA periods and see what happens

Guessing 20 & 22 should be pretty good anyway for most assets and TF's