Experts: MA Cross Studies

 

MA Cross Studies:

Simple program using the moving average as bias and providing many trade and money management options.


Moving Average Studies

This EA was created to study the effects of various trade and money management strategies applied to a simple system, using only a Moving Average for bias. With this program you can implement a Moving Average trading system that switches between buying and selling automatically. You may also implement a scaling in strategy with options to average up, average down, or both. You can also disable switching directions based on the Moving Average, and simply use it as the bias for opening new positions in a single direction.

There are options for setting the stop loss and take profit, or disabling them if you wish. The position size is dynamically adjusted as the account balance grows or shrinks, with the user setting determining how much of the balance to use per position. If free equity falls below the user defined percentage, then the bot will stop placing new orders, or may be configured to close all open positions. With these configuration options it is possible to execute many different strategies using the same program. This EA does not use a Magic Number because it is intended to manage all of the trades on the given symbol.

This EA is intentionally designed so that it should not even attempt to hedge. If you do place trades in the opposite direction of the bot's, things will not turn out well at all. Manual intervention during unexpected turns in the market, or for tweaking portfolio exposure is very much expected. While this EA was written to rapidly explore trade management options and optimization through backtesting, it is quite handy to use it with your preferred settings while trading.

As always, there are no promises of profits while using this program and it is trivial to configure it to throw all of your money out as booked losses. The choice to run this on a live account is yours to make, and I honestly hope you forward test your assumptions and trading conditions through a demo account first. Let me know if you find bugs in the code and I'll fix them.

Author: Matthew Colter  

MA Cross Studies
MA Cross Studies
  • www.mql5.com
This EA was created to study the effects of various trade and money management strategies applied to a simple system, using only a Moving Average for bias. With this program you can implement a Moving Average trading system that switches between buying and selling automatically. You may also implement a scaling in strategy with options to...
 

Dear Matthew,


Thank you for your sharing. I try to use your EA to understand the mq4 language.

I have a question, or maybe a report. It seems that your EA take a position immediately after activated before MA cross happen.

What can we do to fix this problem?

FYI, I use it in my demo account.

Thank you in advance.


Regards,

Anton

 
Anton Sunyata:

Dear Matthew,


Thank you for your sharing. I try to use your EA to understand the mq4 language.

I have a question, or maybe a report. It seems that your EA take a position immediately after activated before MA cross happen.

What can we do to fix this problem?

FYI, I use it in my demo account.

Thank you in advance.


Regards,

Anton

Yes, it will trade in the direction of the trend if you have allowed it to trade in that direction. It does not wait for the crossover to happen to open a trade. There is a setting to close trades on crossover, which would cause a trade to open in the opposite direction if you have allowed it to trade in both directions.

 

Hi Matthew,


I applied some numbers in this EA and looks like it works great. Unfortunately I am totally confused with the explanation of the slow and fast moving averages, and now I have no idea what numbers I put for slow and fast. Could you help me?

 
Martin Zhekov:

Hi Matthew,


I applied some numbers in this EA and looks like it works great. Unfortunately I am totally confused with the explanation of the slow and fast moving averages, and now I have no idea what numbers I put for slow and fast. Could you help me?

MA Period Current sets the "fast" moving average. MA Period Previous Add sets the "slow" moving average. Setting MA Period Current to 10 and MA Period Previous Add to 3 would give you a "fast" MA with a period of 10 and a "slow" MA with a period of 13 (current + previous). Backtest the EA with the MA timeframe settings and the chart timeframe all set to the same value. When the backtest is done it will display the moving average lines so you can see them.

 

"This EA does not use a Magic Number because it is intended to manage all of the trades on the given symbol"

Hi Matthew, thanks for sharing your work.

Is it possible to add a magic number to enable multi EA use on a symbol or is it too difficult? If it could manage a magic number then it would not interfere with manual/other EA trades and make it easier to distinguish between results in the Account History.

Ran your MA Cross a year ago when it had no shedule, now i'm 12 months wiser I thought I'd give it another look. Thanks again for your efforts.

 

The code cannot be compile it contains multiple errors:

1. Schedule declaration without type... undeclared identifier... etc. 

 
Yes exactly, when you try to compile the code it gives 13 errors, Please can you correct these errors. Thanks for the great work.
Files:
Error.jpg  177 kb
 
yawa5 #:
Yes exactly, when you try to compile the code it gives 13 errors, Please can you correct these errors. Thanks for the great work.
exactly. facing same challenge in 2022. I downloaded the "Schedule.mqh" file and copy pasted it into the "include" folder. Still compilation gives either 13 errors or 102 errors depending on whether I change the name of the file to begin with caps "s" or lowercase "s"
Reason: