Australian (ASX) Stock Market Forum

Amibroker FAQ

No probs, hth :)

There is an AFL function for an inside bar, might make the code a bit tidier.

http://www.amibroker.com/guide/afl/afl_view.php?id=74

(OT: enjoying your posts on your futures trading CanOz, too busy to post much myself but enjoying reading what you're up to :) )

Thanks for that Captain...unfortunately i'm so out of practice from what was bad coding i can't even get this right....

All i want to do is add the code to add another inside day....so two inside days....:banghead:

Here is the original, could you set me right please?:eek:

Code:
 Cond1 = Close > Ref( Close, -1 );
Cond2 = High < Ref( High, -1 ) AND Low > Ref( Low, -1 );
Cond3 = Close < Ref( Close, -1 );

Edit: I'm looking for balance within balance, so as long as the last two days are within the range of the bar 3 days ago then I'm interested...
 
On the futures trading, so much to learn....

These three bar patterns are what i use to identify some opportunities. Use the three bar pattern and then look for even smaller consolidation patterns inside the current bar to help determine direction and timing...

CanOz
 
Thanks for that Captain...unfortunately i'm so out of practice from what was bad coding i can't even get this right....

All i want to do is add the code to add another inside day....so two inside days....:banghead:

Here is the original, could you set me right please?:eek:

Code:
 Cond1 = Close > Ref( Close, -1 );
Cond2 = High < Ref( High, -1 ) AND Low > Ref( Low, -1 );
Cond3 = Close < Ref( Close, -1 );

Edit: I'm looking for balance within balance, so as long as the last two days are within the range of the bar 3 days ago then I'm interested...

Sorry CanOz, I haven't heard of the pattern before so you will need to spell out exactly what you're after bar by bar. The setups I see after a Google search of the pattern are a higher close followed by an inside bar then another higher close but you mention 2 inside bars? The code in the link I posted has the higher close (2 bars ago), inside bar (previous bar) then higher close (for a long setup).
 
I haven't coded AFL in a long time now. There probably a neater way but this seems to work.
To keep adding more inside bars just repeat the line and increase the reference value.

Code:
//Most recent bar is inside the range of the previous
Cond1 =
High < Ref( High, -1 ) AND
Low > Ref( Low, -1 );

//Second last bar is inside the previous bar
Cond2 =
Ref( High, -1 ) < Ref( High, -2 ) AND
Ref( Low, -1 ) > Ref( Low, -2 );

Filter = Cond1 AND Cond2;
 
It's pre-coded in AB.

SYNTAX inside()

RETURNS ARRAY

FUNCTION Gives a "1" or "true" when an inside day occurs.Gives "0" otherwise. An inside day occurs when today's high is less than yesterday's high and today's low is greater than yesterday's low.
 
It's pre-coded in AB.

SYNTAX inside()

RETURNS ARRAY

FUNCTION Gives a "1" or "true" when an inside day occurs.Gives "0" otherwise. An inside day occurs when today's high is less than yesterday's high and today's low is greater than yesterday's low.

You might want to check that.
 
Thanks guys, its sort of working the same as the one Captain gave me originally...
 
Yeah, that's it, balance within balance.

That's what the code I posted should give you. Your response earlier makes it sound like you still aren't getting this result.

What results are you getting? Or did I misread you and the problem's sorted already?
 
That's what the code I posted should give you. Your response earlier makes it sound like you still aren't getting this result.

What results are you getting? Or did I misread you and the problem's sorted already?

Well, i'm still getting just the single inside bar....got me stuffed. Anyway its fine and it would be good to find these balance within balance setups as well as two bars inside the original bar as well. They're all example of volatility contraction, but the balance within balance was the one i was looking for.

Scan them Amibroker then look for intraday opportunities...

CanOz
 
Thanks for that Captain...unfortunately i'm so out of practice from what was bad coding i can't even get this right....

All i want to do is add the code to add another inside day....so two inside days....:banghead:

Here is the original, could you set me right please?:eek:

Code:
 Cond1 = Close > Ref( Close, -1 );
Cond2 = High < Ref( High, -1 ) AND Low > Ref( Low, -1 );
Cond3 = Close < Ref( Close, -1 );

Edit: I'm looking for balance within balance, so as long as the last two days are within the range of the bar 3 days ago then I'm interested...

This should solve the problem!

Code:
Cond1 = Close > Ref( Close, -1 );
Cond2 = High < Ref( High, -1 ) AND Low > Ref( Low, -1 );
Cond3 = High < Ref( High, -2 ) AND Low > Ref( Low, -2 );
Cond4 = Ref(Cond1, -2);
Filter = Cond1*Cond2*Cond3*Cond4;

If Condition 4 is not required then:-

Code:
Cond1 = Close > Ref( Close, -1 );
Cond2 = High < Ref( High, -1 ) AND Low > Ref( Low, -1 );
Cond3 = High < Ref( High, -2 ) AND Low > Ref( Low, -2 );
Filter = Cond1*Cond2*Cond3;
 
Thanks RNR...

I just realized also that the code buys on the bar that i'm looking to be involved with, so i just want the "buy" any inside day....That way a scan will pull up all inside days, then they can be watched intra-day for patterns....

CanOz
 
Tested and works!


a = Inside();
aa = a==1;
b = Ref(a,-1)==1;
d = Ref(a,-2)==1;
Filter = a AND b AND d;
AddColumn(C*V,"IVT");

or this to visualize it with a yellow candle -

a = Inside();
aa = a==1;
b = Ref(a,-1)==1;
d = Ref(a,-2)==1;
Filter = a AND b AND d;
AddColumn(C*V,"IVT");
SetBarFillColor( IIf( (Filter), colorYellow, colorBlue ) );
Plot( C, "Price", IIf( C > O, colorGreen, colorRed ), styleCandle );
 
Tested and works!


a = Inside();
aa = a==1;
b = Ref(a,-1)==1;
d = Ref(a,-2)==1;
Filter = a AND b AND d;
AddColumn(C*V,"IVT");

or this to visualize it with a yellow candle -

a = Inside();
aa = a==1;
b = Ref(a,-1)==1;
d = Ref(a,-2)==1;
Filter = a AND b AND d;
AddColumn(C*V,"IVT");
SetBarFillColor( IIf( (Filter), colorYellow, colorBlue ) );
Plot( C, "Price", IIf( C > O, colorGreen, colorRed ), styleCandle );

This one does the same and is even shorter. :)

Code:
Filter = Sum( Inside(), 3 ) == 3;
AddColumn(C*V,"IVT");

or plus visualization

Code:
Filter = Sum( Inside(), 3 ) == 3;
AddColumn(C*V,"IVT");

SetBarFillColor( IIf( (Filter), colorYellow, colorBlue ) );
Plot( C, "Price", IIf( C > O, colorGreen, colorRed ), styleCandle );
 
Very nice! It's a tiny symmetrical triangle consisting of 3 bars.

yeah, they're quite common...still can't get your indicator to paint the bars properly...

It struck me while watching a webinar this morning that this is basically what i'm looking for. You can check out the Webinar below.

 
Last edited by a moderator:
yeah, they're quite common...still can't get your indicator to paint the bars properly...

It struck me while watching a webinar this morning that this is basically what i'm looking for. You can check out the Webinar below.

Haven't looked at the video (too long).
Just show a screen capture of the pattern or different versions of the pattern or simply describe what is missing.

Edit: I'm looking for balance within balance, so as long as the last two days are within the range of the bar 3 days ago then I'm interested...

So the current bar is allowed to be outside of previous most recent bar and both being inside the one of 3 days ago? Or current bar inside previous most recent bar and previous bar inside the bar before previous bar?

And .... last two days -> current bar and previous bar and 3 days ago -> Ref(..., -2) ?
Or last two days -> previous bar and bar before previous bar and 3 days ago -> Ref(..., -3)?

To me is sounds like this
Code:
Cond1 = High < Ref( High, -2 ) AND Low > Ref( Low, -2 ); 
Cond2 = Ref(High, -1) < Ref( High, -2 ) AND Ref(Low, -1) > Ref( Low, -2 );

And what's up with the close condition?
 
Top