Multi-xpMA EA Version 1.0

MultixpMA V 1.0.0


Multi-xpMA is a creation based on the xpMA indicator designed by Codersguru. I had some initial ideas on how to use this indicator but needed to be able to use more than one. I approached a very generous and gifted coder that goes by the name of Ralph Ronquist. I wanted to design an EA that was the mother of all moving average EA’s. Ralph decided to take on the project and wouldn’t take any money for it and did it for his love of coding. Without him this would still be a concept and can’t thank him enough. He has moved on to other endeavors and left the community with more than a solid foundation to work with. With that said, on to the EA.

Basic abilities

The EA was designed to allow just about any moving average logic to be plugged in. It can be as simple as two moving averages crossing or as complex as six different types and periods of moving averages agreeing with the original xpMA “signal” and another six moving averages “crossing” and they can be from any separate timeframe you desire. The limit is not six by the way, that is just an example. The possibilities are almost infinite.

Settings
I will go through most of the EA settings and then discuss the moving averages xpma.csv file.

TrailingStopType =1,2,3
1 (default) to start trailing at 1*TrailingStop profit,
2 To start trail immediately
3 To limit by high/low of n:th prior candle

TrailingStop
For type 1 and 2, this would be your standard trail behind price by X
For type 3 this will be the number of candles back to use as your stoploss

BreakEvenAfterPips
Self explanatory

CloseMA
NOTE – Defining 0 for CloseMA will equal line one of xpma.csv, 1 would equal line 2 and so on.
This has a few different meanings based on what style of moving average system you are using; signals or crosses. Signals will be used as the first example. In your xpma.csv (more on this later) you have defined three moving averages at periods 10, 20, 30. To place an order, all signals must agree. One exit strategy is to exit on signal change defined by CloseMa. If you were to define CloseMa=0, then at the first opposite signal of the 10 period MA the order would be closed. If you were to define CloseMa=2 the order would be closed on the first opposite signal of the 30 period MA. This would be best used for allowing the MA’s to get you in but let the money management functions get you out.

In the case of a crossing setup the CloseMa would define which cross would close the trade. In this case the value will be which MA must be crossed to close the trade. CloseMa in this case can not =0 as the first MA can not cross itself. A setting of CloseMa=1 would close the trade when the 10 period crosses the 20, and CloseMa=2 would be the 10 period MA crossing the 30.

UseRSIfilter True/False
RSIPeriod Self explanatory
RSIPrice Self explanatory
RSIBUYthreshold A buy only allowed greater than this value
RSISELLthreshold A sell only allowed less than this value

UseCCIfilter True/False
CCIPeriod Self explanatory
CCIPrice Self explanatory
CCIBUYthreshold A buy only allowed greater than this value
CCISELLtreshold A sell only allowed less than this value

UseVolumeFilter True/False
VolumeRange A cumulative value of number of bars back to include
VolumeThreshold A trade only allowed when volume exceeds this parameter

OneEntryPerBar True/False Self explanatory
ReverseTradesOnly True/False When true the trade sequence will be buy-sell-buy-sell-buy-sell, when false consecutive trades in the same direction are allowed

StopLoss Self explanatory
TakeProfit Self explanatory
Slippage Self explanatory


MaxOpenTrade Self explanatory
MinPriceDistance Self explanatory

UseHourTrade True/False;
StartHour Hour to allow trading to begin
End Hour Hour to shut down the EA

Lots Number of lots
MM True/False, use money management or not
AccountIsMicro True/False
DecreaseFactor Decrease lots after loss by this amount
Risk % of capital to use

EnableAlert True/False
EmailAlert True/False



XPMA.CSV
This is the heart of multixpMAEA. It resides in your metatrader installdirectory \tester\files. It consists of a series of 10 numbers with the meanings as follows.
The first 8 numbers are straight from the xpMA indicator as defined by Codersguru.
These are taken directly from www.xpworks.com written by Codersguru and all credit goes to him.


TimeFrame: (default 0)
Set it to the time frame you want to work with. The default value is 0 which means it will works with the current time frame of the chart
MA_Period:
The period of the moving average
MA_Type:
The moving average type (Review table 1).
MA_Applied:
The Moving Average Applied price (Review table 2).
T3MA_VolumeFactor:
This setting is for the T3MA indicator only, The Volume Factor
JMA_Phase:
This setting is for the JMA indicator only, The Phase
Step_Period:
How many bars in the history the xpMA indicator will look back to determine the direction of the moving average
Shift:
0 is current bar, 1 previous bar, 2 previous bar to 1, etc.
Moving Average Type Constant name Integer value
Simple moving average MODE_SMA 0
Exponential moving average MODE_EMA 1
Smoothed moving average MODE_SMMA 2
Linear weighted moving average MODE_LWMA 3
Double Exponential Moving Average MODE_DEMA 4
Triple Exponential Moving Average MODE_TEMA 5
T3 Moving Average MODE_T3MA 6
Jurik Moving Average MODE_JMA 7
Hull Moving Average MODE_HMA 8
DECEMA Moving Average MODE_DECEMA 9
SALT indicator MODE_SALT 10


Applied Price type Constant name Integer value
Close price. PRICE_CLOSE 0
Open price. PRICE_OPEN 1
High price. PRICE_HIGH 2
Low price. PRICE_LOW 3
Median price, (high+low)/2. PRICE_MEDIAN 4
Typical price, (high+low+close)/3. PRICE_TYPICAL 5
Weighted close price, (high+low+close+close) PRICE_WEIGHTED 6

The last 2 values are as follows.

SignalType
type = 1 tells that this MA provides its agreement signal by means of
line direction being upwards or downwards, as indicated by the red and blue
line colors; This is what defines the system as a signal system
* type = 2 tells that this MA provides its agreement signal by means of its
value being above or below the value of the preceding type 2 MA; This is what defines the system as a cross system
* type = 0 (or anything else) tells that this MA always agrees.

Span
"span" is used for type 1 MA to make it stop agreeing after that many bars of the
same direction. span = 0 means "no span limit".

So what you end up with is an xpma.csv file that will look like so..


Timeframe Period MA Type MA Applied T3 Volume Jma Phase StepPeriod Shift Signaltype Span
0 50 8 0 0.8 0 1 0 1 0


Examples of xpma.csv

The following would be the signal setup in the beginning of this document. A 10, 20, 30 “signal” for buy or sell.
0 10 8 0 0.8 0 1 0 1 0
0 20 8 0 0.8 0 1 0 1 0
0 30 8 0 0.8 0 1 0 1 0

Set your CloseMa to close the order on the 10 period =0, the 20 period =1, or the 30 period =2.
If you would like a confirm on entry, simply change one or all of your shift values to 1

We will use the same example except use a “cross” system.

0 10 8 0 0.8 0 1 0 2 0
0 20 8 0 0.8 0 1 0 2 0
0 30 8 0 0.8 0 1 0 2 0


Simply change the 1 of signaltype to 2 and the values of the moving average are taken rather than the line directions.

It is possible to use both a cross and signal by combining both the above .csv settings. Use your imagination, make a rainbow.

multixpma-EA
multixpma-EA.rar
Hosted by eSnips

0 Response to "Multi-xpMA EA Version 1.0"

Post a Comment

powered by Blogger | WordPress by Newwpthemes | Converted by BloggerTheme