In the first mode (the job parameter is equal to 0), the program works as a classical EA, i.e. it does not trade independently but it helps the trader by providing information on a detected buy or sell signal (or giving an alert and/or an email, which can be set optionally).
In the second mode (job=1,2,3 or 4), the program opens and closes trades in accordance with the user-defined settings, in other words, it acts as a trading robot.
Trading Strategy Characteristics
Often, market trends can be more clearly identified on senior time frames (from one hour and higher) than on lower ones. The proposed strategy opens, on the average, not more than one trade a day for a selected financial instrument since a buy or sell signal with the suggested values of WavePeriod and AvgPeriod coefficients are formed once every few days when working on H1 time frame.
In the course of testing and analysis it was noticed that it is quite often that a series of closely timed buy (sell) signals is generated. If one signal, rather than a series of signals, is detected a day, the movement as a rule follows the signaled direction. For visualization in the course of trading, you can use the MAGISTR AIV indicator based on which this program was developed.
When a series of orders is formed (in the mode where the program can open more than one order), the order opened by the first signal starts losing, while the last order of the series, as a rule, quite quickly starts winning, becoming profitable. In view of the above, it is reasonable to open each subsequent order of the forming series with incremental lot size, which allows you to quite quickly get the positive total, closing orders of the series with profit. It should be noted that if trading against the global trend (clearly defined, strong trend on D1 time frame) is allowed, the series may contain around 10 orders. This must be taken into account if an incremental lot size strategy is used for each subsequent order based on the full or partial Martingale principle.
If during the day there was only one signal and an open order is profitable, it seems appropriate to move SL to breakeven (e.g. 25-30 points) when a certain level of unrealized profit, e.g. 50 points, defined by the trader in accordance with the market situation is reached. Such approach allows you to get big profit using the trend-following movement since the trade is closed by the trader himself, by moving SL from time to time and safeguarding the accumulated profit. Such an order managed manually is taken out of Expert Advisor's control by changing (it is recommended to increase the value by 1) the value of the magic number used by the Expert Advisor. It is likely that such approach is not appropriate for a formed series that contains current orders with unrealized loss. Such a series should be closed with the minimum profit as fast as possible when the breakeven level is reached.
Default values are shown in brackets.
- WavePeriod (10) - coefficient of the first MA;
- AvgPeriod (21) - coefficient of the second MA;
- SL (0) - when the Stop Loss value is reached, the order will be closed, 0 - order will be closed manually;
- TP (97) - when the Take Profit value is reached, the order will be closed, 0 - order will be closed manually;
- magic (1) - unique magic number of orders opened by the Expert Advisor;
- Lot (0.1) - initial lot;
- job (1) - operation mode:
- 0 - only gives recommendations (advice) on opening sell (buy) orders, acting as an Expert Advisor;
- 1 - opens buy and sell orders by a signal;
- 2 - opens buy orders only;
- 3 - opens sell orders only;
- 4 - opens a buy or sell order by a signal. There is only one open order; until it is closed, a new order will not be opened;
- anti (0) - signal will not be reversed, 1 - reversed signal (buy based on a sell signal, sell based on a buy signal);
- klot (0.1) - the value by which the next opening lot will be increased;
- SoundAlert (0) - visual notification (Alert), 0 - disabled, 1 - enabled;
- EmailAlert (0) - email notification, 0 - disabled, 1 - enabled;
- globaltakeprofit (105) - if the unrealized profit amount on all open orders becomes greater than or equal to this value, all orders opened by the program will be closed and the profit will be realized; the value of 0 means that this option is disabled;
- globalloss (0) - if the unrealized loss amount on all open orders becomes greater than or equal to this value, all orders opened by the program will be closed and the loss will be realized; the value of 0 means that this option is disabled;
- n (3000) - number of elements in arrays used for working with moving averages;
- sn (1) - enables/disables Push notifications using MetaQuotes ID. 1 - enabled, 0 - disabled.
- We trade only in the direction of the global trend (which can be identified on a senior time frame, e.g. D1). If there is no clearly defined trend, we allow the program to open both types of orders.
- If there is a strong trend on a senior time frame, an attempt to trade in both directions will result in cases where, once the trend somewhat loses its strength (small correction is always present), some series of orders will be opened against the trend and profit on them will be minimal, if any at all. The price slows down a little bit and somewhat pulls back to jump in the direction of the trend with renewed strength. In view of this, we run two program copies in two different windows with different magic numbers. The first copy trades only in the direction of the trend; job is equal to 2 or 3 depending on the trend type and the anti parameter is 0. The second copy trades against the trend; job is equal to 2 or 3 depending on the trend type, while anti is 1, i.e. a reverse signal will be used. Trading with the second copy is more risky, yet more profitable. If you are not sure of the trend strength, do not work with the second copy.
- Remember that the program should not be used based on the "started-and-forgotten" principle. The program allows you to stick to the tactics without your involvement, while working on hourly time frame. However the global strategy - no trend, uptrend or downtrend - should be identified by you on senior time frames. Remember that trends on D1 do not reverse in a single step. I believe that a trader can take a look at a chart on D1 once or twice a day to determine the global strategy, while the tactics based on that strategy is worked out by the program.
My Trading Method:
- I select a few pairs and check the chart on D1 for a strong, clearly defined trend or a strong flat for any of them. Then, I trade these pairs. If the trend is not clear for these pairs, I check other pairs.
- For visualization, I use the MAGISTR AIV indicator as it offers a very clear picture of when a signal may be formed.
- Once the order gained 60 points of profit (hereinafter - 4-digit prices), I move the order to breakeven and increase the magic number by 1. Following this, the order goes out of the program's control. I close the order by Take Profit at 150 points or use the second option - if there is unrealized profit of 150 points, I protect 100 points of profit by moving to breakeven, if 250, I move the breakeven by 200, etc.
- If I cannot do real-time monitoring, the program trades independently. Once every 1-3 days I determine the global trend direction and set the program to trade based on it.