Express Yourself EA - Build your own strategy

8 February 2020, 06:19
Thomas Schmitz
0
351

Introduction

The Express Yourself EA is designed to build your very own strategies for automated trades. In this article I will describe the possibilities of the EA.

I came on the idea to build this Expert Advisor after I read the book "Entry and Exit Confessions of a Champion Trader" from Kevin J. Davey. In his book Davey provides 52 possible entry and exit signals for automated trading. Beside a "Plain English Code" he presents code for each signal that can be used on his favoured Trading Plattform. He also gives the reader the challenge to test one signal per week.

As most of the code provided in this book can be written as simple expressions I came on the idea to build an Expert Advisor that can translate most of these code in the book. Now I am able to test a new strategy that I have read from within minutes (most of the time).

I want to show this now on an example.

One entry signal in the book I described above is called "Breakout with a Twist". This strategy tries to find breakouts and uses the ADX indicator to let the breakout signal only take effect in a non-trending period.

The Plain English Code for this entry signal is similar to: "If the current ADX value is below 20 then buy at the highest high of last n bars or sell at the lowest low of last n bars".

This can be now translated into an expression that can be understood by the Express Yourself EA:

  • Long condition: adx<20 & ask>=highest(high,p1)
  • Short condition: adx<20 & bid<=lowest(low,p1)

This is a simple example but shows most of the possibilities. As you can see you can use variables that either represents an indicator (like adx) or a price value (like ask and bid), or something else. See the lists below for further informations about variables. Especially the indicator variables need to be understood before using them.

You also see that the expressions uses some functions (like highest and lowest). In this functions one optimization parameter (p1) is used. You can use up to six of these optimization parameter variables (p1, p2, ..., p6) in your expression. Each variable evaluates to one double input parameter value of the EA. This allows you to optimize your strategy like you would do with other EAs.

What you have not seen in the example is that you also could use arithmetic operations in your expression. E.g. adx*1.05<20 would expect that the 105% of the adx value is below 20. Allowed arithmetic operators are *, /, +, -.

You also can group your expressions into parentheses and combine them with logical operator AND (&) and/or OR (|). The example above also contains the AND operator as you can see.

Beside conditions to enter long and short trades you also can enter conditions to close those trades. I usually use those conditions like time==2259 & profit<=0 which closes my trades one minute before market close if they are in loss (in my timezone).

Input parameter to enter conditions to either open or close trades.

Timeframes

By default all indicator or series values are calculated by the timeframe that is configured in the "Signal detection timeframe" input parameter. If this parameter is set to 1 Hour the adx value of above example would be calculated on this timeframe. Also the signal detection would occur at each new bar on the 1 Hour timeframe.

You can also let indicator or series be calculated on other timeframes as the "Signal detection timeframe". The syntax for this is tf{<expr>}, where tf is one of the standard timeframe m1, m2, m3, ..., d1, w1, mn1. For example d1{adx<20} & ask>=h1{highest(high,10)} would evaluate only to true if ADX main line of daily bar is below 20 and ask price is above or equal of highest bar of 10 last 1 hour bars.

Note that if you choose "Every Tick" as signal detection timeframe then the current timeframe of the chart will be used as default timeframe for variable calculation.

Variables

The following tables contains an overview of all available variables that can be used in expressions.

What you should know before using variables: Some values of them can be accessed via an index, either a single index or a double index.

For example the open, close, high, low variables are single indexed variables. This means you can access the value of nth bar backwards via open[n] (e.g. open[0] for current bar or open[1] for previous bar).

An example for a double indexed variable is the ADX indicator variable. The ADX indicator has overall three values. Each of these values are stored in a different buffer. In case of the ADX indicator the first buffer (buffer 0) contains the MAIN_LINE values, the second buffer (buffer 1) contains the PLUSDI_LINE values and last buffer (buffer 2) contains MINUSDI_LINE values. The syntax to access these different values is adx[b,n] where b is the buffer number and n is the nth bar backwards (e.g. adx[0,1] evaluates to MAIN_LINE value of previous bar, adx[1,10] evaluates to PLUSDI_LINE value of 10 bars ago).

If you use an indexed variable without index (like seen in the introduction example) the buffer and bar index defaults to 0.

Note that you can change the variable names of each indicator in the EAs input parameters if you want. This is only valid for indicator variable names. The input parameter also contains a list of other variable names that are available. This is only to give an overview.

Indicators

Indicator Variable name Buffers
Accelerator Oscillator ac 0 - MAIN_BUFFER, 1 - COLORS
Accumulation/Distribution Indicator ad single buffered
Average Directional Movement Index adx 0 - MAIN_LINE, 1 - PLUSDI_LINE, 2 - MINUSDI_LINE
Alligator Indicator alli 0 - GATORJAW_LINE, 1 - GATORTEETH_LINE, 2 - GATORLIPS_LINE
Awesome Oscillator ao 0 - MAIN_BUFFER, 1 - COLORS
Average True Range atr single buffered
Bears Power bears single buffered
Bollinger Bands® bb 0 - BASE_LINE, 1 - UPPER_BAND, 2 - LOWER_BAND
Bulls Power bulls single buffered
Commodity Channel Index cci single buffered
DeMarker demark single buffered
Envelopes env 0 - UPPER_LINE, 1 - LOWER_LINE
Force Index force single buffered
Fractals fract 0 - UPPER_LINE, 1 - LOWER_LINE
Gator gator 0 - UPPER_HISTOGRAM, 1 - COLOR_UPPER_HISTOGRAM, 2 - LOWER_HISTOGRAM, 3 - COLOR_LOWER_HISTOGRAM
Ichimoku Kinko Hyo ichi 0 - TENKANSEN_LINE, 1 - KIJUNSEN_LINE, 2 - SENKOUSPANA_LINE, 3 - SENKOUSPANB_LINE, 4 - CHIKOUSPAN_LINE
Market Facilitation Index bwmfi 0 - MAIN_BUFFER, 1 - COLOR
Money Flow Index mfi single buffered
Moving Average fast, slow single buffered
Moving Average of Oscillator osma single buffered 
Moving Averages Convergence/Divergence macd  0 - MAIN_LINE, 1 - SIGNAL_LINE 
On Balance Volume Indicator obv  single buffered 
Relative Strength Index rsi  single buffered 
Relative Vigor Index rvi  single buffered

Prices/Quotes

Price/Quote Variable name Notes
Open price open single indexed
Close price close single indexed
High price high single indexed
Low price low single indexed
Ask price ask no index, evaluate always to current tick price (will be changed in next versions)
Bid price bid no index, evaluate always to current tick price (will be changed indexed in next versions)
Spread spread no index, evaluate always to current tick spread (will be changed to indexed in next versions)

Account Info

Info Variable name
Balance balance
Profit accountprofit
Equity equity
Margin margin
Free Margin marginfree 
Margin Level marginlevel 
Other
Variable name Description
profit E.g. close condition: profit<=-50|profit>=50 -> close position if profit is below 50 dollar or above 50 dollar (or rather account currency)
profitpips E.g. close condition: profitpip<=500 -> close position if it is 500 pips in loss
time E.g open condition: time>=930&time<=1530 -> open trades only between 9:30 and 15:30
counter Counts how often the expression before counter variable is used evaluates to true. E.g. if you want to that the EA trades only once the ask price of Ger30 is above 13600: ask>=13600 & counter==0
Conclusion

With the available variables that can be used you are able to try out almost every strategy that is based on indicator values or simple price movements. You are also able to concat different strategies for one asset by grouping your appropriate expressions into parentheses and concat them with the logical OR operator. Also if you don't yet have a real strategy but want to create virtual orders that opens at a specific price and/or within a specific timeframe this EA can be used to automate this.

I hope that also in demo mode this EA could be useful for some one. Feel free to contact me if you are missing a feature.

Share it with friends: