This is in continuation of previous article published on 4th February, where I exposed how the Linear Regression Slope indicator can be used to collect many informations in one single data outcome (indicator positive or negative) when used in m15 timeframe, with 96 time periods.

The second element

Before going to explain this step, I have to explain deeper the first one, showing a clear example of what happens in a daily chart and how I read it in the 15min timeframe.
In the following picture we see the EUR/AUD instrument in daily timeframe. Starting from the beginning of 2014, price was showing some attempts to keep rising and resume the previous uptrend, but as we see there was a strong reversal down with a full 2 days downward. This was due because of strong fundamental change, came near important resistance area.


Looking at this scenario in the 15m timeframe I have much more to say, see the chart:


When the new year was open, price immediatly came back down near 2013 close, showing a quick bounce reconquering the eMA65 and giving a further 50pips continuation to the upside (indeed strategy's purpose is to get maximum 40-45pips each trade). But the overall situation is not clear, price is flat, and the fast ema14 crosses 2 times the 65ema suggesting weak bullish momentum. Fundamental came, moving price down to breake year open, both emas and all recent supports in 1 single move. The perfect bearish breakout indeed, moving the Linear Regression Slope full below 0, and showing price inability to conquer previous levels: this is the case where the first approach back to the 65ema will be strong and clean, like it was as shown in the chart.

At this point comes the second element. I basically started wondering if was possible to have an earlier signal of this happening, and how to make my code detecting a change in price behavior or a good continuation in the trend. So let's see the same event in hourly timeframe:


What I need is my code to detect that price was not anymore going up on 30th December, even if previous daily was bullish and the regression in m15 was positive. I was in need of a kind of 'control' showing all this in the simplest way possible. After some attempts I came to this conclusion:


Adding a sMA8 in this timeframe, gives me enough of what I need. As seen in the above chart, once price for any reason loses the 8sma, it's time to switch direction or eventually to stop a direction and wait for clear change. In the 15min chart this is done by applying a 128sma (8 periods in h4 = 1920 minutes / 15 == 128) which I decided to round as 120sma. Look at the chart:


I guess it's clear enough how price keeps rising or falling when everything is line, while when there is uncertainty I have a clear suggestion that something's gonna happen. Adding this event in the code is extremely simple but I will show it later after exposing the third element.

The third element

Until now I basically introduced 2 simple rules to the old version of this strategy. Now I'm going to build a few implementation in the code: I want it to detect when price is closed to the eMA65 and the overall setup is suggesting long or short signal, so allowing me later to use it as trigger for executing (or closing) a position.

In the old version of code, this was done in the public void onTick, so when even one single tick was within a certain range from the eMA65, the code was opening the posiion. But this had some limitations because of the continuos losing trades happening when price was flat near main supports and resistances (as I said in first chapter, this is the worst limitation about MA - based strategies).

My purpose at this stage is to detect an event and have a visual representation, something telling me "Hey, here you have a good combination of factors for a short/long position". What better than an arrow appearing in the chart like this shown in next picture?


What I need is to detect the output of the three MAs, check if they are moving up or where, and to draw me an arrow in the chart when this is actually happening. At first I thought to work "onTick" but when I started running tests the code was drawing an arrow on every single tick near the eMA65 and believe me.... it's a huge number! So finally I moved everything "onBar". Here's a cut of the code:


In this way, on every bar the code detects if previous close was within 4 pips (LowLevel-UppLevel) range from the eMA65 (entryMA), and prints a green/red arrow depending on all the mentioned rules. I prefer to work in separated steps so to give in another place all rules to actually build the arrow, I'm still studying Java so I hope this is correct . Here's another small cut:


In few words, the arrow goes printed 20pips far from last tick. Again, the string ("arrow") is the same for both green and red, so an arrow goes deleted when there is another in opposite direction. Here we could implement the code by deleting the "arrow" if/once price goes out of the range, but I sincerely see no reasons for that, not yet...!

If you are interested here you find the 2 versions of the code:
And finally, in the following video we see a short view of what happened after ECB Chairman M. Draghi comments on 6th February, watching the reaction on EUR/AUD instrument. The choice is not random at all! We see how during the speech price went straight to the upside, breaking the whole descending scenario, then later at the beginning of new day price gave a great buy setup for 40-45 pips.

As I will explain in later steps, this particular strategy is best used to avoid market uncertainty and wait patiently for best formed setups. For the moment, here's the video:

Conclusions

What I do really like about developing this strategy is trying to fix it as much as possible in order to obtain some benefits in using it, and in the same time having the opportunity to go deeper in some Strategy-API aspects and sharing my results so other people could eventually benefit from them. At the moment this combination of factors having some drawings as outcome, could be (for example) used as trigger for opening buy/sell positions in a fast timeframe (1-5minutes).

Thank you for reading
Translate to English Show original