BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullCharts discussion
  New Posts New Posts RSS Feed: Linear Regression Moving Average
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Linear Regression Moving Average

 Post Reply Post Reply Page  <12
Author
Message / View First Unread Post
blackdog View Drop Down
Regular
Regular
Avatar

Joined: 14 Nov 2006
Location: Vatican City State
Posts: 43
Post Options Post Options   Quote blackdog Quote  Post ReplyReply Direct Link To This Post Posted: 19 Dec 2006 at 7:07pm
Maximo, a couple of comments on your detailed script:

I have a modified version of my script which I think fixes the gap problem. It is not as detailed as Maximo's script, I only am showing the changing of the colour on the indicator. It is somewhat similar to maximo's script in that it sets the indicator to one colour then overwrites parts of it with the second colour.

linecolor:=

if (ma3<hist(ma3,1),0,  {for ma3 downdard}

if (ma3>hist(ma3,1),1,  {for ma3 upward}

prev));     {for ma3 sideways}

[drawundefined=gap]   {This attribute is essential to prevent straight  lines being drawn when indicator is "undefined"}

[color=red]

ma3;  {default colour for indicator when it is not green}

[color=green]

if (linecolor=1,ma3,undefined);   {this leaves a gap on first bar upward but leaves last bar on graph filled}

if (hist(linecolor,-1)=1,ma3,undefined);   {this fills first gap upwards but leaves a gap on last bar of graph}

{ Between them these two lines of script cover all the required green area. Dont combine them into one compound if statement as it then fails to work on the last bar plotted}

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: 21 Dec 2006 at 6:22pm

Thanks blackdog!

Used your script and managed to remove the gap :)

[target=price]

ma3:= ma(C,30,E);

linecolor:= if(ma3<hist(ma3,1),0,if(ma3>hist(ma3,1),1,prev));

{no lines drawn when indicator is "undefined"}

[drawundefined=gap]

[color=red]

if (linecolor=0,hist(ma3,1),ma3);

[color=green]

if (linecolor=1,ma3,undefined)

 

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: 21 Dec 2006 at 6:31pm

Shows there's more than 1 way to skin a cat. Didn't know about [drawundefined=gap] and cant find it in the bullscript help.

Cheers!

Back to Top
blackdog View Drop Down
Regular
Regular
Avatar

Joined: 14 Nov 2006
Location: Vatican City State
Posts: 43
Post Options Post Options   Quote blackdog Quote  Post ReplyReply Direct Link To This Post Posted: 22 Dec 2006 at 1:36pm
[drawundefined=gap] is not in bullscript help. I found it used in darvos box script and a little experimentation showed what it does... As you say, more than one way to skin a cat... hehe...
 
merry Christmas...
Back to Top
Rounders View Drop Down
Newbie
Newbie


Joined: 27 Jul 2008
Location: Portugal
Posts: 1
Post Options Post Options   Quote Rounders Quote  Post ReplyReply Direct Link To This Post Posted: 27 Jul 2008 at 10:24am
Originally posted by maximo

Yep, the best one can do at the  moment is a work around.  A new attribute would make it possible.  eg. [linestyle=linecolor] just like [linestyle=pricecolor] and [linestyle=bar] makes dual colouring of them possible.  Here's my attempt :)

[target=Price; category=Moving Average; Author=Max]

StartDate:=InputDate("Start date", date(2004,1,2));

HoldingDays:=BarsSince(OnOrSkipped(StartDate));

period := input("Time periods",28,1);

bar := ma(2*ma(C,int(period/2),W) - ma(C,period,W),

int(sqrt(period)), W);

{Flag the StartDate}

begin:=If(bar>=PREV(undefined),PREV(undefined),bar*Holdingdays);

[color=lime; name=up; width=1; linestyle=solid]

if(begin=0,if(bar>=hist(bar,1),bar,bar),undefined);

[color=dark orchid; name=down; linestyle=solid]

if(begin=0,if(bar<hist(bar,1),bar,undefined),undefined);

[color=rgb(230,230,230); name=down2; linestyle=solid]

bar2 := (hist(bar,1)+bar)/2;

if(begin=0,if(bar<hist(bar,1),bar2,undefined),undefined);

[linestyle=pricecolor]

[color=dark green] if(begin=0,bar>=hist(bar,1),undefined);

[color=crimson] if(begin=0,bar<hist(bar,1),undefined)

 

 

Hello I question that formula its for CMC Markets??

I can put that formula five me error why???

Tell something have fantastics trades

 

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: 29 Jul 2008 at 11:35pm

No Rounders it's for BullCharts software.

CMC already has them built in.

Backtest before trading. 

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