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. As strategy contains large number of calculation it was pointed out that for successful further strategy development automation of strategy is needed. In this publication I will cover possible algorithm for automated calculations of some part of variables required for strategy. This will include max, median and min values for all required periods (10 year, 2 year and 9 months) automated calculation.
It should be noted that strategy is under development and is not suitable for real trades.

2. Basic principles of calculations

In order to have everything in one platform I plan to use visual jforex for all required calculations. As in my previous publications
all required data was fetched from relevant charts here I will concentrate also on fetching data from charts but not manually. Everything will be done by logic implemented in visual jforex. The main principle of algorithm creation is that it should be simple to calculate values for different pairs - the aim is that it should be possible just to change pair in one place and have all 9 variables for new pair in place.

3. Calculation algorithm description

Calculation algorithm mainly consist of 3 branches. Each branch is used for certain period variables calculation. The layout of algorithm could be seen in picture below.

Each part of algorithm is responsible for certain period variables calculation. First part calculates 9 months period variables (in visual jforex these variables has assigned names - high9m, med9m and low9m). Second part is responsible for 2 year period variables calculation (in visual jforex these variables has assigned names - high2y, med2y and low2y). And in third part variables for 10 year period are calculated (in visual jforex these variables has assigned names - high10y, med10y and low10y).

For explanation how this logic works it is necessary to go through one part only as other parts have same logic only different variables in blocks are used. Now third part of algorithm will be explained in more details.


In order to define highest and lowest value for 10 year period we need to look at 120 monthly candles. For this purpose we fetch oldest candle with use of "Get Historical Candle" block with shift 120. We assign candle high value for variable high10y and candle low value for variable low10y by means of 2 "Assign" blocks.
After that we should go through 120 monthly candles and look if there is candle with high higher than any other candle and with low lower than any other candle. For this purpose we use "Get Historical Candles" block with number of candles for analysis 120. These array of data is analyzed with help of "Loop Viewer" block. This block fetches every monthly candle and after that "Multiple Action" splits analysis in two branches. One branch looks if present candle high is higher than highest value so far and another looks if current candle low is lower than lowest value so far. If it is the case new value for high10y or low10y is assigned.
After analysis of all candles is finished second output of "Loop Viewer" is activated and in "Calculation Expression" block median value of 10 year period is calculated just by finding arithmetical average of highest and lowest values.
That's it. Quite simple logic for highest, median and lowest values calculation for 10 years period.

Other periods values calculation logic is same only in 2 years period case weekly candles are used and in 9 months period case daily candles are used. And of course number of candles is set accordingly in order to cover relevant time period.

4. Calculation examples

So now we can test how this logic works. Lets fetch variables for few currency pairs which were not covered in previous
publications. Firstly as default variable I will enter GBP/JPY and secondly EUR/JPY. Fetched variables will be presented in screen shots below.
GBP/JPY variables calculated with logic build in visual jforex.
EUR/JPY variables calculated with logic build in visual jforex.

It could be seen that required variables for input in strategy calculations are depicted in right corner of the screen. So now it will be easy to make further calculations and there will be no need to go through charts with candles and manually calculated required variables.

5. Further steps

Presented logic calculates only part of required variables. And also certain logic of trade parameters calculation is not included in algorithm yet. But what was done is very good basement for further development of automation. Creating of logic consumed some time and developing of it will also be demanding in time but I think that after finishing it will be very easy to tune strategy just changing some parameters as aim is to develop such automation that it could be easy to use. Summarizing basement for strategy automation is done and further developments will be covered in coming publications.
Translate to English Show original