Australian (ASX) Stock Market Forum

Amibroker - Coding a consolidation pattern followed by a bullish bar

Joined
Jul 8, 2014
Posts
36
Reactions
0
Hello,

I want Amibroker to Buy if there has been:

- a consolidation (flatline/ small bars moving between a small price range) , and
- this is followed by a breakout bar ( ie a medium/ large bullish bar) that looks significant compared to the consolidation bars.

I have coded this. But I am struggling to get it to work. Is what I'm asking too restrictive?

Has anyone done this before..... preferably in beginner (array) language?

Code:

highval= Ref (HHV (H, 15), -1);
lowval = Ref (LLV (L, 15), -1);
percentchange = ((highval - lowval)/ lowval)*100;

Cond1 = percentchange < 2; // consolidation moves in a range of less than 2%
Cond2 = H> (1.05*L); // Big candle
Cond3 = C>O and C>L; // Green bar
Cond4 = C>highval; // Close of big bar is greater than highest high in consolidation period

Buy = Cond1 AND Cond2 AND Cond3 AND Cond4;
Sell = 0;

Applystop (stopTypeTrailing, stopModePercent,10,0,True,0);

Thanks in advance,

Regards

Tradezy
 
Joined
Jun 13, 2007
Posts
838
Reactions
115
Hi Tradezy --

I recommend that you plot each of the conditions separately to see if they are identifying conditions you intend.

Plot (Cond1, "Cond1", colorgreen,styleline|styleownscale,-1,2);
Plot (Cond2, "Cond2", colorblue,styleline|styleownscale,-1,3);
Plot (Cond3, "Cond3", colorred,styleline|styleownscale,-1,4);
Plot (Cond4, "Cond4", colorbrown,styleline|styleownscale,-1,5);

The overlapping scales will keep the plots from covering each other up.

Best regards,
Howard
 
Joined
Jul 8, 2014
Posts
36
Reactions
0
Hi Tradezy --

I recommend that you plot each of the conditions separately to see if they are identifying conditions you intend.

Plot (Cond1, "Cond1", colorgreen,styleline|styleownscale,-1,2);
Plot (Cond2, "Cond2", colorblue,styleline|styleownscale,-1,3);
Plot (Cond3, "Cond3", colorred,styleline|styleownscale,-1,4);
Plot (Cond4, "Cond4", colorbrown,styleline|styleownscale,-1,5);

The overlapping scales will keep the plots from covering each other up.

Best regards,
Howard
Hi Howard,

What a clever idea! I have added your formula above onto mine. It now shows a chart with peak when then conditions are met.

This has made it much easier to identify when the Conditions have been met. Thank you, I will be using this concept again.

I can now visually see examples when it should had bought, but it has not..... so I will have to spend some more time studying my formula.

It seems simple enough....I must just have something conflicting in there. I just can't work out what....:banghead:

Thanks again,

Tradezy
 
Joined
Jul 8, 2014
Posts
36
Reactions
0
Hi,


Has anyone else coded this in Amibroker? (Refer to my formula below).

Is anyone using a similar trading concept?

I am still getting limited opportunities despite backtesting for 10 years.

Regards,

Tradezy
 

rnr

Joined
Jul 1, 2007
Posts
576
Reactions
352
Hi,


Has anyone else coded this in Amibroker? (Refer to my formula below).

Is anyone using a similar trading concept?

I am still getting limited opportunities despite backtesting for 10 years.

Regards,

Tradezy
Hi Tradezy

Out of interest I created an indicator to show the lowest value of "percentchange" as per your code, for the period July 1996 to the current date, on the chart of ALL (Aristocrat Leisure on the ASX) and the result was just under 6.30%.

Based on that info I then changed the indicator to calculate the % of time "percentchange" was under 7% with the result being 2.51%.

Conclusion from the above is that a "percentchange"<2 is extremely constrictive on your system as perhaps are other variable limiters.

Cheers
rnr
 
Joined
Jul 8, 2014
Posts
36
Reactions
0
Hi Tradezy

Out of interest I created an indicator to show the lowest value of "percentchange" as per your code, for the period July 1996 to the current date, on the chart of ALL (Aristocrat Leisure on the ASX) and the result was just under 6.30%.

Based on that info I then changed the indicator to calculate the % of time "percentchange" was under 7% with the result being 2.51%.

Conclusion from the above is that a "percentchange"<2 is extremely constrictive on your system as perhaps are other variable limiters.

Cheers
rnr
Hi rnr,

Thanks for your reply. I will try with a larger range.

Can I ask what indicator are you using?

With thanks

Tradezy
 
Joined
Jul 3, 2013
Posts
78
Reactions
0
I think the problem might be in the length of your consolidation pattern. 15 bars seems quite long and therefore might be the reason for so few results. Try optimising the BarLength and see if you get better/more results. I like the way you are thinking though. Good luck and keep us posted.
 

rnr

Joined
Jul 1, 2007
Posts
576
Reactions
352
Can I ask what indicator are you using?
Hi tradezy

Code:
// Formula 1

highval = Ref (HHV (H, 15), -1);
lowval = Ref (LLV (L, 15), -1);
percentchange = ((highval - lowval)/lowval)*100;
lowest(percentchange); // Lowest % change on this chart

Code:
// Formula 2 

highval = Ref (HHV (H, 15), -1);
lowval = Ref (LLV (L, 15), -1);
percentchange = ((highval - lowval)/lowval)*100;
Cond1 = percentchange < 10; // consolidation moves in a range of less than 10%
Cum(Cond1)/Cum(1)*100; // % of time (bars) Cond1 is true on this chart
The consolidation period of 15 bars may, as mentioned by payday, need to be reviewed.

You may well find that there is some relationship between the length of the consolidation pattern and the "percentchange".

Cheers
rnr
 
Joined
Jul 8, 2014
Posts
36
Reactions
0
Hi rnr & payday,

rnr - I tried with a larger range and still had no luck. Have just seen your formula's. Thanks for that. I'll review them. Thank you.

payday - Thanks for your feedback aswell, I'll give Optimization a go.

Based on my lack of success to date I an not feeling optimistic, but if there is any joy I'll let you know.

Thanks again,

Tradezy
 
Joined
Oct 17, 2012
Posts
574
Reactions
989
Another option might be to include use of ATR in your code. For example looking for the MA of the ATR decreasing by some percentage, say 50%. Might help identify periods of tightening price action (or breakouts from tight trading ranges).
 

Similar threads

Top