BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: Market Structure
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Market Structure

 Post Reply Post Reply Page  12>
Author
Message / View First Unread Post
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Topic: Market Structure
    Posted: 11 Aug 2014 at 11:26am

I had a request to show code for the text I was using on the chart in previous "Who is in charge of the market" post showing how to code the text for Higher Highs etc  That chart is based around a market Structure definition  I use.  You will probably use different definitions.

Here is an example of how I might code the text for market structure indicator.  For the example I am taking a previous Fractal indicator by Maximo from this forum  as a base case, and showing below how I might further adapt that code  to show more clearly a market structure on a chart.  I will post three charts:

 1 Original Fractal chart

2 A chart showing the replace points with +'ve and -'ve Market structure text.

3 A Colour coded  market structure.

Then the final code will be posted.

The code further below has  green comments showing each of the steps I added  to Maximo’s  (who did the hard part) original code.






BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 2014 at 11:27am
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 2014 at 11:29am
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 2014 at 11:44am
BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 11 Aug 2014 at 11:45am

{Cmacdon note: Step I- Work out what is the market structure definition your are happy to work with.

For this example, I am just taking an original short Fractal Code By Maximo Refer to Forum Post "Adding Fractals to Bull charts" (see that code for original code, and then below I add various additional code to show a text description of market structure plus some fill colouring. Further comments in Green below show each additional coding step to produce chart 3 on the post}

[Description="Cmacdon further code added to the original Fractal of 3 bars, Max"]

[target=price; Visible=True]

{ Fractal High }

{[linestyle=points; color=blue; width=5] } {Remove Original Points Line Style in first chart. see Second chart for replacement text coded below}

Upfractal:=If(H>ref(H,1) and H>ref(H,-1), H*1.001,undefined); {Add Names for Up Fractals to the original code as we will refer to those lines of code further below with additional coding}

{ Fractal Low }

[color=indian red]

Downfractal:=If(L<ref(L,1) and L<ref(L,-1), L*0.999,undefined);{Add Names for Up Fractals to the original code as we will refer to those lines of code further below with additional coding}


{Add Text to replace the original Points Linestyle}

{Text for interpreting market structure showing positive Blue structure Higher Highs(HH)and higher lows (ll), and negative structure, Lower Lows (LL), and lower highs (lh).}

[name=HH; linestyle=Text;fontsize=8; textalign=Above,Centre; color=Blue;]
if(Upfractal>Valuewhen(2,Upfractal,upfractal), + "HH ", +"");
Upfractal*1.001;

[name=lh; linestyle=Text;fontsize=8; textalign=Above,Centre; color=Red;]
if(Upfractal>Valuewhen(2,Upfractal,upfractal), + "", +"lh");
Upfractal*1.001;

[name=LL; linestyle=Text;fontsize=8; textalign=BELOW,Center; color=Red;]
if(Downfractal<Valuewhen(2,Downfractal,Downfractal), + "LL ", +"");
Downfractal*0.999;

[name=hl; linestyle=Text;fontsize=8; textalign=BELOW,Center; color=Blue;]
if(Downfractal<Valuewhen(2,Downfractal,Downfractal), + "", +"hl");
Downfractal*0.999;

{----------This draws Lines I called Creek and Ice (Wyckoff terms)for want of names-------}

HoldLevelPeriod :=
Input("Hold Level Period",100,1);

FrU:=ValueWhen(1,UpFractal,UpFractal);
FrUb:=If(H < FrU and barssince(UpFractal)<HoldLevelPeriod, FrU, undefined);

[name=Creek; linestyle=Horz Step; color=blue; width=1]
FrUb;

FrD:=ValueWhen(1,DownFractal,DownFractal);
FrDb:=If(L > FrD and barssince(DownFractal)<HoldLevelPeriod,FrD,undefined);

[Name=Ice; linestyle=Horz Step; color=red; width=1]
FrDb;

{-----------------------------Colour Market Structure--------------------------------------}

Switch:=if(barssince(valuewhen(1,upfractal))<barssince(valuewhen(1,downfractal)),Frub,Frdb);

{ Fill }
[name=Market Structure Fill; linestyle=fillstep;]

[color=Red] If((L>valuewhen(1,FRUb)),H,Switch);

[color=Cyan] C;


{Only additional thing I do is colour code my price bars per my market Structure definitions which is not per the above example}

BC User since June 2007
Back to Top
Niftyg View Drop Down
Newbie
Newbie
Avatar

Joined: 23 Mar 2011
Location: Gold Coast
Posts: 11
Post Options Post Options   Quote Niftyg Quote  Post ReplyReply Direct Link To This Post Posted: 12 Aug 2014 at 1:13pm
Hi Charles,
 
Thanks for your great posts on the forum and assisting us with coding.
 
I have tried to scan on close closing higher than your creek line.  For example I have tried "Close is greater than Market Structure (100) Creek any bar in the last 10 bars" but no stocks come up in the scan when they should.
 
Just wondering if you have any ideas on how you could scan to find a close above a horizontal line?
 
Regards
 
Nifty
 
 
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 12 Aug 2014 at 6:01pm
Nifty

I added a few lines to color bars and, set up a Jumping the Creek and Breaking though Ice markers which you can use on the scanner.

I do not personally use the scanner as I have 4 to 8 stocks in each of various industry sector folders that meet the criteria for stocks I am willing to trade, and that is usually based around the amount of volume of trading per day. Doing that you also get to know the personality of the price action on those few selected stocks, as you scroll through the sector folders in no time each day.

What I found if you use a scanner on say ASX 200 it can often come up with a large number of stocks where if you really analyse some stocks on an intraday chart you will notice there may not be a great level of volume or trading activity even on some stocks at the lower end of the in the ASX200.

Note in the second chart below, I often manually change the Jumping the Creek and Breaking Ice Marker colors and positions to better reflect the price action movement rather than adopt the default long and buy marker format and colors in the first chart.

Charles



BC User since June 2007
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 12 Aug 2014 at 8:28pm
Sorry

I forgot to attached the updated code


{Cmacdon note: Step I- Work out what is the market structure definition your are happy to work with.

For this example, I am just taking an original short Fractal Code By Maximo Refer to Forum Post "Adding Fractals to Bull charts" (see that code for original code, and then below I add various additional code to show a text description of market structure plus some fill colouring. Further comments in Green below show each additional coding step to produce chart 3 on the post}

[Description="Cmacdon further code added to the original Fractal of 3 bars, Max"]

[target=price; Visible=True]

{ Fractal High }

{[linestyle=points; color=blue; width=5] } {Remove Original Points Line Style in first chart. see Second chart for replacement text coded below}

Upfractal:=If(H>ref(H,1) and H>ref(H,-1), H*1.001,undefined); {Add Names for Up Fractals to the original code as we will refer to those lines of code further below with additional coding}

{ Fractal Low }

[color=indian red]

Downfractal:=If(L<ref(L,1) and L<ref(L,-1), L*0.999,undefined);{Add Names for Up Fractals to the original code as we will refer to those lines of code further below with additional coding}


{Add Text to replace the original Points Linestyle}

{Text for interpreting market structure showing positive Blue structure Higher Highs(HH)and higher lows (ll), and negative structure, Lower Lows (LL), and lower highs (lh).}

[name=HH; linestyle=Text;fontsize=8; textalign=Above,Centre; color=Blue;]
if(Upfractal>Valuewhen(2,Upfractal,upfractal), + "HH ", +"");
Upfractal*1.001;

[name=lh; linestyle=Text;fontsize=8; textalign=Above,Centre; color=Red;]
if(Upfractal>Valuewhen(2,Upfractal,upfractal), + "", +"lh");
Upfractal*1.001;

[name=LL; linestyle=Text;fontsize=8; textalign=BELOW,Center; color=Red;]
if(Downfractal<Valuewhen(2,Downfractal,Downfractal), + "LL ", +"");
Downfractal*0.999;

[name=hl; linestyle=Text;fontsize=8; textalign=BELOW,Center; color=Blue;]
if(Downfractal<Valuewhen(2,Downfractal,Downfractal), + "", +"hl");
Downfractal*0.999;

{----------This draws Lines I called Creek and Ice (Wyckoff terms)for want of names-------}

HoldLevelPeriod :=
Input("Hold Level Period",100,1);

FrU:=ValueWhen(1,UpFractal,UpFractal);
FrUb:=If(H < FrU and barssince(UpFractal)<HoldLevelPeriod, FrU, undefined);

[name=Creek; linestyle=Horz Step; color=blue; width=1]
FrUb;

FrD:=ValueWhen(1,DownFractal,DownFractal);
FrDb:=If(L > FrD and barssince(DownFractal)<HoldLevelPeriod,FrD,undefined);

[Name=Ice; linestyle=Horz Step; color=red; width=1]
FrDb;

{-----------------------------Colour Market Structure--------------------------------------}

Switch:=if(barssince(valuewhen(1,upfractal))<barssince(valuewhen(1,downfractal)),Frub,Frdb);

{ Fill }
[name=Market Structure Fill; linestyle=fillstep;]

[color=Red] If((L>valuewhen(1,FRUb)),H,Switch);

[color=Cyan] C;


{Only additional thing I do is colour code my price bars per my market Structure definitions which is not per the above example}

[linestyle=pricecolor]

[color=Green] If( c>=valuewhen(1,FRU) OR switch =FRD and c>valuewhen(1,FRD),1,undefined);

[color=Red] If( c<=valuewhen(1,FRD) OR Switch = FRU and c<valuewhen(1,FRU) ,1,undefined);

[color=Black] ;


[Visible=True]
{   I had request for ability to scan so I added my Markers I use for assessing markets from a Wyckoff type interpretation. For Wyckoff Terms Jumping the Creek and Falling Through Ice which are breakout of Trading range support and resistance.

I go in and change the markers for Buying to above the bar and selling below the bar and also change arrow direction and colours to Blue above the Wyckoff Creek and Black falling through Ice concepts. The markers are quite good within a trend but be careful at very top or very bottom as obviously the price action at that point is not going further up or down for a while, although you might get a marker at that point}

jck:=Cross(C,Valuewhen(2,FRU));
[name=JCk; linestyle=marker; marker=Long;align=Above; ]
jck;

bki:=Cross(Valuewhen(2,FRD),C);
[name=BkIce; linestyle=marker; marker=short; align=Below;]
bki;


Edited by cmacdon - 12 Aug 2014 at 8:30pm
BC User since June 2007
Back to Top
Niftyg View Drop Down
Newbie
Newbie
Avatar

Joined: 23 Mar 2011
Location: Gold Coast
Posts: 11
Post Options Post Options   Quote Niftyg Quote  Post ReplyReply Direct Link To This Post Posted: 13 Aug 2014 at 9:42pm
Hi Charles,
 
Thanks for replying and adding in the markers. I know you don't use the scanner but just thought I would let you know that the markers don't seem to work. Not on my scanner anyway.
 
Regards
 
Nifty
Back to Top
cmacdon View Drop Down
BullCharts Guru
BullCharts Guru


Joined: 09 Sep 2012
Location: Brisbane
Posts: 236
Post Options Post Options   Quote cmacdon Quote  Post ReplyReply Direct Link To This Post Posted: 13 Aug 2014 at 10:57pm
Niftg

The markers were scanable for both Jck and BKi yesterday before I posted the code.

What I just did was download the code from the forum and onto my computer and ran the scanner again to see nothing had changed in the upload process, and the scan did not produce any symbols meeting the scan criteria.

What I then did was update the daily data download and the scanner worked and picked up a number of symbols when sety to the marker sybol is true any day in last 3 days for the test. I think it is a quirk in BC as you sometimes have to update a snapshot to get a daily scanner to work so may be same thing happening.

So try updating your daily data and then run the scan again as it works a few minutes ago for both markers on my computer after the daily data download.

Charles

BC User since June 2007
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz