1. Overview

In my previous publications of 3 period max/median/min strategy basic principles of strategy were covered and some trades based on outcome of mentioned strategy calculations were entered. In my last publication I described automation of strategy for calculation of all required variables for evaluation of entering of trades and take profit and stop loss levels.
All previous publications were dedicated for strategy use in long term trading cases but after I received proposals to load strategy to strategy contest I decided to adopt same principles for short term trading. Mentioned adoption is topic of this publication.
It should be noted that strategy is under development and is not suitable for real trades.

2. Required changes

In previous publication 3 different time periods were used - 10 years, 2 years and 9 months. In order to enter trades more frequently shorter periods for analysis should be chosen. Thus I replaced mentioned periods with another periods - 10 days, 2 days and 9 hours. All calculation logic remained the same and no changes in already developed algorithm were needed except of parameter which were related with numbers of candles in specific period and such periods itself. Additionally all variables names were changed in order to better represent their meanings, e.g. high10y was changed to high10d.

3. Adoption of algorithm

As described above changes to algorithm were minimal but they were needed to be done. Firstly all variables names were changed by right clicking of mouse button on variable concerned and just filling in the appeared table new name of variable instead of old one. In picture below it could be seen that all variables have names assigned according to variable meaning, e.g. high2d represents highest rate value within 2 days interval, low9h represents lowest rate value within 9 hours interval.


After these changes I expected that all new variables will automatically appear in algorithm blocks. It happened but with one exception - in the block "Calculation Expression" - as in these blocks old variables names remained. Thus I went through all such blocks manually and changed in it old variables with new ones by dragging new variables from left corner of the screen to their respective places in mentioned blocks.

Another change which was needed was changing number of candles in all respective intervals. As in 9 hours interval 5 min. candles is used for 9 hour period variables calculation we should take 108 of last 5 min. candles such number was entered to "Get Historical Candle" and "Get Historical Candles" blocks. By the same considerations numbers used in mentioned blocks for 2 days and 10 days periods were changed to 48 (30 min. candles to be used) and 60 (4 hours candles to be used) respectively.
Change for 9 hours period is depicted in picture below.

After all these changes were done also numbers were changed in minmed strength and maxmed strength variables calculations in order for these variables do not exceed maximum value of 1.

One more thing which was done for further convenience was putting all blocks responsible for variables calculations in few groups. This was done by holding CTRL key and left mouse button and selecting with mouse blocks to be grouped. After this was done navigation in algorithm became more easy and as calculations were checked and no further changes in such calculations were planned grouping of mentioned blocks also decreased possible errors due to erroneous changing of some parameters inside these blocks.


After all these preparations were made usage of these parameters for opening and closing positions could be started. In the following sections possible algorithm will be described.

4. Preparation of algorithm for managing of trades

For the first step I decided to use parameters from 2 periods only. I selected 2 days and 9 months periods and mentioned periods variables for programming of trades management decisions.
In mentioned algorithm 2 branches for decisions on opening trades will be used and one branch for decisions on closing trades will be used. Decisions on opening trades will be checked every 5 min. as every 5 min. strategy recalculates variables (shortest period candle). After each 5 min. default variable candle is formed workflow goes to "multiple action" block.



First output of "Multiple Action" block goes to "If" block where check is made if current rate is higher or lower than 9 hours median. If it is higher one more check is made is it higher than 15 pips, if it is lower check is made is it lower more than 15 pips. This is done by 2 blocks means - "Calculation" and "If". If it is the case further check is made if minmed9h or maxmed9h is higher than 0.3. This check is dedicated to avoid opening of positions when rate is falling or going up very quickly. And last check is if minmed or maxmed strength is higher than 0.55. This check serves for filtering of short term spikes. If all above described conditions are met either long or short trade is opened.

Another branch which is responsible for decisions on opening of positions goes from second output of mentioned "Multiple Action" block.

Here additional check is done if number of open positions is equal to 0 as this strategy was prepared with intention to load it to strategy contest thus only 1 open position is allowed. Later check is made if we have recorded new 9 hours period lows or highs and if it is a case further check is made are these lows or highs also 2 days period lows or highs and if not trade in opposite direction is opened. This part of trade opening management is dedicated to try go in opposite direction with intention that 9 hours period low will not became also 2 days period low but rate will rebound.

Last branch of trades management is responsible for decisions on closing of trades. This branch operates by "on Tick" method, i.e. check if predefined conditions for trade closing are fulfilled are done when every tick arrives to the system.


After tick arrives and is filtered to default instrument check if there is open position is made as if its not no further checking is needed as there is no positions to be closed. After this with help of "Position Viewer" block current position is fetched and after cheking is position long or short workflow is split into 2 parts. In case position is long check is made if current rate is higher than 9 hours median by 10 pips or more, in case it is short check is made is current rate lower by 10 pips or more than 9 hours median. Additionally it is checked if position profit is not lower than -10 pips and if it is a case position is closed.

Thus proposed algorithm open long trades when rate gets lower than 9 hours median by 15 or more pips ore new 9 hours period low is recorded and close position then rate goes above median by 10 pips or more. Symmetrically short trades are opened if rate gets higher than 9 hours median by 15 pips or more or new 9 hours period highs is recorded and closes such trade when rate goes under median by 10 pips or more.

5. Further steps

I think it is very first step for a strategy. Only few of possible variables is used but I want to see how strategy will perform with this limited number of variables and where will be areas for strategy development. Described strategy is loaded to strategy contest so we will see how it will perform. Algorithm is public thus whole picture of strategy could be seen from strategy contest.
Translate to English Show original