The "Pattern-123" Expert Advisor for MT4: Description and Settings

The "Pattern-123" Expert Advisor for MT4: Description and Settings

19 September 2019, 15:22
Pavel Zamoshnikov
2
3 241

Good day, dear traders!

I want to introduce you my new Expert Advisor that implements a trading system based on the “Pattern-123” graphic price model.


The "Pattern-123" model has long been known and popular with traders - this is a reversal pattern that signals a possible end and reversal of a trend.

Back in 2016, I wrote an indicator that recognizes Patterns-123 on the chart. The development turned out to be very successful. Convenient visual display of patterns, the absence of lag (the main drawback of most indicators) and redrawings made the indicator quite popular among traders.

Pettern-123 indicator

And immediately after the publication of the indicator, a mass of requests rained down with a request to automate the trading according to Pattern-123.

Although I am an opponent of fully automatic advisers (I believe that a robot cannot trade better than humans), however, I myself needed a robot assistant who could track the signal and open trades in my absence.

Advisor development was not easy and dragged on for a couple of years - a test demo account with a robot was launched only in January 2019

Nine months of testing the adviser showed that Forex tools are not the best choice:

EA testing

As you can see, from all the tested instruments, the EA shows good results on the gold only. Although in the future I plan to conduct testing on indexes, CFDs and crypts.

At the moment, the robot is trading on a live account, under control, in a semi-automatic mode.

Description of the Pattern-123 and how the EA works

The price model "Pattern-123" is one of the simplest and most reliable patterns of graphical analysis, which indicates a market reversal. Perhaps this is the most important information for traders - to know where one trend ends and the opposite begins.

The Pattern-123 is based on three points (consider the example of the UP Pattern-123) :

  1. The first point (point #1) is the low of the downtrend;
  2. The second point (point #2) is formed at the time of a rollback from a downtrend. At this moment, we still don't know what will happen, a turn up or a rollback;
  3. The third point (point #3) appears at the moment when the price turns up again, without breaking through the level of point #1.

Pattern-123 description

When Pattern-123 is formed, the EA sets a pending stop-order for the breakdown of point #2.

If the price breaks the level of point #2 - the pattern execution- a pending order turns into a market transaction.
If the price does not reach point #2, but goes beyond point #1 - this is pattern cancellation- the EA will delete the order.

StopLoss can be set beyond the level of point # 1 or # 3 or set with a fixed value (parameter “ Method of calculating the Stop Loss (from point 1/3 or fixed) ”)

TakeProfit is set at the Fibo level or set with a fixed value (“ Take Profit for 1st order (Fixed, Fibo enum or Fibo manually) ” parameter) - this is TakeProfit of the 1st order (there may be other, so-called reversal orders - they have their own TP , but about them later).
Expert Advisor Pattern-123

To determine points #1,2,3, the Indicator and the Advisor use a Zigzag of my own development, which is as close as possible to the standard zigzag, but, unlike it, is not redrawn.

Stop'n'Reverse pending orders to compensate for losses

To increase profitability, the EA provides the ability to set opposite pending orders at the level of triggering the stop loss of the current transaction (Stop'n'Reverse orders).
Moreover, the EA can increase the lot of SnR-orders by the martingale coefficient (parameter “ Coeff. Of Martingale ”). When a market transaction is opened, a counter pending SnR-order with an increased lot is set at the StopLoss level of the market transaction.

The StopLoss of the SnR-orders placed at the opening level of the previous transaction.

The TakeProfit level of the SnR-orders is placed a certain number of points higher than the breakeven level (set by the parameter “ TP for next SnR-orders - distance from BreakEven level ”).

SnR orders

When the stop loss of the market Buy-transaction (for example) is triggered, the reverse Sell SnR-order is opened (turns into a market Sell-transaction), and a new Buy SnR-order with an increased lot is placed at the place of the closed losing Buy-transaction.

SnR orders_2

When the transaction is closed in profit, then coefficient of increase is reset to 1.

The number of possible reversal SnR-orders is set by the parameter “Number of allowed SnR-orders in the set (including 1st order)”. If this parameter is less than or equal to 1, SnR-orders are not used.

Attention!
The use of reversal SnR-orders with an increased lot is a trade with increased risk.
Follow the principles of Money Management.

It is strongly recommended that you use reversal orders on very volatile instruments only (the gold, for example).

All orders: the 1st order (at the signal of the indicator) and subsequent reversal SnR-orders - make up one set.

The Advisor distinguishes between the Buy-set (1st order is BuyStop in the set) and the Sell-set (1st order is SellStop) by Magic numbers and processes Buy- and Sell-sets separately.

At launch, the Advisor searches for its orders by symbol and by two Magic-numbers and includes them in the work. The EA reports all his actions on the Experts tab.

Additional features

  • The Advisor gives you the opportunity to set the allowed period of time for trading. However, signals outside the trading time are taken into account by the EA anyway. And if at the beginning of the trading period these signals were not executed or canceled, then the adviser will place a pending order for the breakdown of point #2, formed before the start of trading.

    This feature of the Advisor allows you to use it even for the breakdown of the morning flat. Set the start time of the trading period at the beginning of the European session, and the Advisor will set pending Buy/Sell-orders at this time, of course, if Pattern-123 is formed during the morning flat period.

  • The EA provides the ability to trail a profitable position. Trailing only works for the 1st order (parameter "Trailing Stop - coeff.of TakeProfit").

  • The EA will automatically recognize 5 and 4 digit quotes. It is necessary to set the parameters in a 4-digit format, and the adviser will recount itself.

How I trade with the Pattern-123 Expert Advisor (+ real trading example):

Although the EA can work as an automatic robot, but I don't use it in a fully automatic mode - only as an Advisor-assistant, to place orders on signals at a given time.

I start my every trading day with the markup of significant support-resistance levels on the H1-H4 timeframes, from which the price was pushed away on in the past. If at the current moment the price is approaching one of the levels, then I start the Pattern-123 advisor to search for signals.
Trading time - European and American sessions (configured in the Advisor).

I try to always accompany transactions. If I see that the trend is reversed, then I can reduce losses by reducing the stop loss manually.

Here is an example of today's transaction:

Seeing such a rebound from the level of 1500, I launched the EA to search for Pattern-123 upwards with the goal of reaching the next resistance level at H1, which coincided with the Fibo level 262%.

XAUUSD_20190918

You can see the result in the following picture:

result_20190918

If the transaction made a profit today, then I no longer trade on this day (configured in the Advisor)

At the end of the post you will find two sets:

- The “EA_123_Pattern_v1.0_XAUUSD_M5_manual_GMT3_0.01.set” I use for my manual trading.
Please do not put this set on automatic trading - it will be unprofitable.

- If you do not have the opportunity to trade manually, then I can offer you the “EA_123_Pattern_v1.0_XAUUSD_M5_auto_GMT3_0.01.set” for fully automatic trading.
This is a very conservative set - without the use of reversal orders.

Testing was carried out for 2 years 9 months on the M5 timeframe
Optimization: 2017 + Forward test: from 2018.01.01 to 2019.09.18

Advantages:

  • Average annual profit - more than 100%
  • A very small deposit can be used - from $ 100 per 0.01 lot. At the same time, the maximum drawdown is less than $ 50 during the entire testing time.
  • Does not require your presence at the computer (but I’m sure that your manual support will increase your profit)

Disadvantages: lack of profitability for 9 months (from 2017.05 to 2018.02)

testing_result

Setting trading time for GMT+3 in both sets


Full description of the Advisor parameters:

Parameter Name The corresponding variable name in the Advisor
Description
EA Info
EA_Info The name of the set-file with the settings. It includes the Advisor version, the symbol of the instrument, timeframe, Optimizer name and set creation date. It is filled by the Optimizer.
Magic Number (reserve the next number too)
Magic The magic number. The Expert Advisor determines its orders by the symbol of the instrument and the Magic numbers. The EA uses two Magic: one number is set by this parameter (for Buy-sets) and one more (for Sell-sets). If you put several instances of the EA on one instrument, but on different timeframes, then you should increase / decrease this number by at least 2
If have a profit today - no more trading today NoTradeIfProfit
If profit is made today, the EA don't trade today.
The option is useful for intraday trading. May be:
“Disable” - disabled (open deals on all signals);
“We don't trade today if there is a profit today” - the EA don't trade today if there is profit today. Past profit/loss is not taken into account;
“We don't trade today if there is a profit and a maximum Balance” - the EA don't trade today if there is a profit and the balance is maximum (for example, if there was a loss yesterday, we will trade on all signals until the balance reaches a maximum)
Disable open the 1st order after this date FinalGridDate After this date, new orders are not placed. At the same time, the EA processes existing market and pending orders as usual. The parameter is necessary for the correct completion of testing, without loss from transactions forced to be closed by the tester. Set this date about 1-2 days earlier than the end date of testing so that the EA can correctly close existing orders
--- Trading settings ---


Fixed Lot of the 1st order
Lot
Fixed lot for the first order in the set
Risk,% of Free Margin (from 0 to 100%),
if = 0 - use Fixed Lot
Risk Lot size calculation as a percentage of available funds (Free Margin). It also depends on the value of stop loss.
If Risk = 0 - uses a fixed lot from the previous variable
----- SL options -----


Method of calculating the Stop Loss (from point 1/3 or fixed)
StopLossCalc
Method for calculating the stop loss level. Stop can be placed under point 1 or point 3. If StopLossCalc = “Fixed value” - a fixed stop value from the next variable is used.
If you selected the stoploss at point 3, then when placing a pending order, the EA will place the stop at point 1 at  first, because point 3 may still shift. When the pending order is triggered and turns into a market order – the point 3 is fixed – then the EA moves the stop level under the point 3.
Fixed Stop Loss (4 sign) Stoploss Fixed Stop Loss in 4-digit pips. Used when StopLossCalc = “Fixed value”. If at the same time StopLoss = 0 - no stop loss is placed
Maximum StopLoss (4 sign, = 0 -disabled) /
Minimum StopLoss (4 sign, = 0 -disabled)
MaxStopLoss /
Minstoploss
A signal filter by the maximum and minimum value of stop loss (in 4-digit pips). Used when the stop loss size is NOT fixed - i.e. determined by the distance between point 1 and point 2 (or between point 3 and point 2 - depending on the “Method of calculating the Stop Loss” parameter). If this distance is greater than "Maximum StopLoss" or less than "Minimum StopLoss", the signal is skipped.
If parameter = 0 - the filter is not used. If the stop loss is fixed (StopLossCalc = “Fixed value”) - the filter is also not used
----- TP and Trail options -----


Take Profit for 1st order (Fixed, Fibo enum or Fibo manually)
ProfitFiboEnum
Take profit level of the 1st order. It can be set in % Fibo of the distance between points 1 and 2, or a fixed value in pips.
In most cases, just select the Fibo number from the drop-down list, but you can set it manually.
If ProfitFiboEnum = “Fibo manually” - the Fibo number is set manually in the "Take Profit if Fibo manually (must be more than 100%)" variable.
If ProfitFiboEnum = “Fixed value” - a fixed TakeProfit value from the "Take Profit if Fixed value (pips, 4 sign)" variable is used.
Take Profit if Fixed value (pips, 4 sign) TakeProfit Fixed Take Profit in 4-digit pips. Used when ProfitFiboEnum = “Fixed value”. If at the same time TakeProfit = 0 - no TakeProfit level
Take Profit if Fibo manually (must be more than 100%) ProfitFiboManual This field is for setting the Fibo number manually (in %). This is used when ProfitFiboEnum = “Fibo manually”.
Please note that the Fibo number, specifying Take Profit manually, must be more than 100%. Otherwise it is impossible to correctly calculate the TakeProfit level. In this case, the Adviser will use the fixed value from the "Take Profit if Fixed value (pips, 4 sign)" field.
TrailingStop - coeff.of TakeProfit: from 0.1 to 0.9,
if = 0 -disabled
TrailStopRatio Trailing stop. It is placed for the 1st order only. The size of the trailing stop is calculated as the ratio of the take profit size (from 0.1 to 0.9, if = 0 - disabled)
If the price goes a distance greater than TrailingStop from the opening level, then the EA transfers the stop loss level to breakeven at first, and then moves it after the price.
----- Reversal settings -----


Number of allowed SnR-orders in the set (including 1st order)
SnRnumber
The maximum number of orders in the set, including the 1st order. Minimum value = 1
Because a reversal order is placed at the stop loss level of the current market transaction, then when there is no stop loss (StopLossCalc = “Fixed value” and StopLoss = 0), the installation of reversal orders is disabled.
Coeff. of Martingale (if <= 1 - disabled) Martingale Martingale coefficient, by which the lot for subsequent orders in the set is multiplied. If less than or equal to 1, then the lot of all orders in the set is equal to the lot of the 1st order
TP for next SnR-orders - distance from BreakEven level (4 sign) NextTPfromBE Take Profit of subsequent reversal orders in the set.
First, the total break-even level of all previous orders in the set, which closed at the stop loss, is calculated. To this level is added the number of pips from this variable (in 4-digit pips)
----- Time settings -----
Hour and Minutes to start of trading / Hour and Minutes to end of trading
HourBegin, MinutesBegin
HourEnd, MinutesEnd
Start and End time of the trading period. Parameters for the 1st order only. Signals outside this trading period are skipped. If all parameters = 0 - trading is conducted around the clock.
Useful for trading on small time frames, setting the trading period of the European and American sessions.
Although the 1st order is not set outside the trading time, the signal of the indicator remains valid until it is canceled, and at the beginning of the trading time, the adviser will set the 1st order if the signal has not been processed or canceled.
Start trading / End trading color clTradeBegin, clTradeEnd Color of vertical lines indicating the beginning and end of trading time (not displayed during round-the-clock trading)
----- Indicator settings -----
Depth of ZigZag
ExtDepth
Number of bars to search for Zigzag peaks (analogue of the "Depth" parameter of the standard Zigzag)
Drawing enable DrawingEnable Visualization of the advisor's work - it draws a zigzag and levels similar to the Pattern 123 indicator
ZigZag Color / ZigZag Width ColorZZ, WidthZZ Zigzag line parameters: color / width
Color to BUY / Color to SELL UPColor, DNColor Buy / Sell colors
Points size PointSize Size of dots-1,2,3




Once again link to the page with the "EA Pattern-123" advisor: https://www.mql5.com/en/market/product/41710


Share it with friends: