BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: 3-bar breakouts
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

3-bar breakouts

 Post Reply Post Reply Page  123>
Author
Message / View First Unread Post
peter1 View Drop Down
Regular
Regular


Joined: 27 Aug 2008
Location: Sydney
Posts: 56
Post Options Post Options   Quote peter1 Quote  Post ReplyReply Direct Link To This Post Topic: 3-bar breakouts
    Posted: 12 Nov 2008 at 1:30pm

I have been trying to learn a little Bullscript by creating a simple buy/sell indicator.
The buy marker displays when price crosses the highest price of the previous 3 bars and the sell marker displays when price crosses below the lowest price of the previous 3 bars.
This seems to be working properly and now I would like to declutter the chart by making the redundant signals invisible. There doesn't seem to be a handy function for this in Bullscript. I believe Amibroker has a function called "exrem" that can be used for this purpose.
Would anyone like to share how they do this or give me some ideas please.

---------------------
My next task is to create a ribbon based on this indicator. The plan is to display this ribbon using a higher timeframe than the timeframe of the chart. eg I want to look for the buy signals on a weekly chart when the last signal in the monthly ribbon was a buy. I know how to mange the timeframe in the ribbons using the advanced menu tab.

There is a similar issue with the ribbon in that the displayed colors default to white when a signal has not occured (inside bars). This creates a tricolored ribbon instead of a bicoloured ribbon and looks unclear. 

Would someone like to suggest any ideas to fix this please.

 

 



Edited by peter1 - 12 Nov 2008 at 1:32pm
Back to Top
rcameron View Drop Down
Moderator Group
Moderator Group


Joined: 04 Aug 2008
Posts: 21
Post Options Post Options   Quote rcameron Quote  Post ReplyReply Direct Link To This Post Posted: 21 Nov 2008 at 6:48pm
If you don't want to show the markers just double click on the markers on the chart and under Style de-select the marker icon. It can be turned on again by selecting the indicator in the header of the chart and selecting the marker icon again. This will hide all markers but I think you want to selectively only show the most recent markers, sorry can't help on this one. What about changing the size of the marker under 'Style' to de-clutter?
 
When coding the ribbon set a colour to reflect the satisfaction of the criteria, say [color=green] when the breakout occurs and then add [color=red] at the end of the code to define the default colour. I think my example below should help.
 

[color=green; name=Bullish]

[fillstyle=solid]

value1-value2>=0;

[color=red; name=Bearish]

[fillstyle=solid]

value1-value2<0;

[color=red]

Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 25 Nov 2008 at 2:03pm
Hi Peter,
 
If you just want to display the lastest signal/marker? you can use Lastvalue(Barnumber) function to return the current barnumber and get your script to only check for your criteria on the most recent bar or a few bars from the recent bar, so previous signals will disappear as the chart updates while any new one will be displayed.
 
 
Here's a Trend Ribbon which only colours long or short.  You can adapt it to your signal.
 

{ Momentum Trend Ribbon }

[target=Ribbon]

MBO:=Ma(C,25,S) - Ma(C,200,S);

{ Trend detection based on new Highs & Lows of Momentum Oscillator }

Condition1:=hhv(MBO,89) > ref(hhv(MBO,89),-1) or llv(MBO,89) > ref(llv(MBO,89),-1);

Condition2:=llv(MBO,89) < ref(llv(MBO,89),-1) or hhv(MBO,89) < ref(hhv(MBO,89),-1);

Signal:= If(Condition1 = True, 1,If(Condition2 = True, -1, prev));

[color=rgb(98,217,98)] Signal=1

[color=rgb(226,118,118)] Signal=-1

    


Edited by maximo - 25 Nov 2008 at 3:57pm
Back to Top
peter1 View Drop Down
Regular
Regular


Joined: 27 Aug 2008
Location: Sydney
Posts: 56
Post Options Post Options   Quote peter1 Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2008 at 3:57pm
Thanks for replying.
My first query was how to make the redundant signals invisible. You can see the redundant signals in the chart. [ I think I might have posted an image!]
 
 
 
Back to Top
peter1 View Drop Down
Regular
Regular


Joined: 27 Aug 2008
Location: Sydney
Posts: 56
Post Options Post Options   Quote peter1 Quote  Post ReplyReply Direct Link To This Post Posted: 26 Nov 2008 at 4:35pm
Maximo (you legend), your suggestions worked a treat.
Here is the ribbon with the indicator.
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 27 Nov 2008 at 12:38am

Aha! now remove the redundant signals.   It was on my to do list for a while.. 

Increase breakout period for fewer trades & generally larger trends. 

[Description="Breakout Signals"]

[Target=Price]

n := input("Breakout period",3,0);

SignalLong := if(High > hist(HHV(H,n),1),1,0);

SignalShort := if(Low < hist(LLV(L,n),1),1,0);

SigLong := if(SignalLong,1,if(SignalShort,0,prev));

SigShort := if(SignalShort,1,if(SignalLong,0,prev));

[linestyle=marker; marker=long; name=""]

If(SigLong and SigLong <> hist(SigLong,1),1,0);

[linestyle=marker; marker=short; name=""]

If(SigShort and SigShort <> hist(SigShort,1),1,0);



Edited by maximo - 27 Nov 2008 at 12:49am
Back to Top
peter1 View Drop Down
Regular
Regular


Joined: 27 Aug 2008
Location: Sydney
Posts: 56
Post Options Post Options   Quote peter1 Quote  Post ReplyReply Direct Link To This Post Posted: 27 Nov 2008 at 11:36am
Maximo - well done. Clap
 
Here are the results of your code (unaltered).
Back to Top
peter1 View Drop Down
Regular
Regular


Joined: 27 Aug 2008
Location: Sydney
Posts: 56
Post Options Post Options   Quote peter1 Quote  Post ReplyReply Direct Link To This Post Posted: 27 Nov 2008 at 11:49am
"Increase breakout period for fewer trades & generally larger trends."
 
A good observation and a valid suggestion. This technique works best in a trending instrument. You should see the signals on the crude oil chart. Forex works well also.
Stocks require additional filters, index trend filter, stock trend filter, volatility filters etc.
 
Next difficulty and it deals with the chart timeframes.
I can get set this ribbon to weekly and change the chart to daily. No problem.  The idea is to take the daily setups that are in sync with the weekly signals.
 
I am unable to set the ribbon to monthly and view the weekly chart with the monthly ribbon. The ribbon changes to weekly and ignores the convert to monthly command. Is this me or a Bullcharts problem? 
Back to Top
peter1 View Drop Down
Regular
Regular


Joined: 27 Aug 2008
Location: Sydney
Posts: 56
Post Options Post Options   Quote peter1 Quote  Post ReplyReply Direct Link To This Post Posted: 27 Nov 2008 at 12:02pm
For those interested, here are the signals on the crude oil weekly chart.
Back to Top
peter1 View Drop Down
Regular
Regular


Joined: 27 Aug 2008
Location: Sydney
Posts: 56
Post Options Post Options   Quote peter1 Quote  Post ReplyReply Direct Link To This Post Posted: 27 Nov 2008 at 12:13pm
It just occured to me that the inability to see the monthly ribbon on a weekly chart may be due to a conflict with the dates. A monthly timeframe can start /end within a weekly period and this might cause a conflict within Bullcharts.
Back to Top
 Post Reply Post Reply Page  123>

Forum Jump Forum Permissions View Drop Down

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