[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: How to enhance Linear Regression Channel Code to plot two previous days



PureBytes Links

Trading Reference Links

Hi Ara, I think you missed posting the code in your message - you
stopped at "The ending point:"

thanks for your help.

--- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@xxx> wrote:
>
> You need two pieces of information to find the linear regression:
> 1. Last point of interest : LinearReg( ARRAY, periods )
> 2. First point of interest:  LinRegIntercept( ARRAY, periods )
> 
> To find LR for 2 days ago use Ref(Close,-2) for Array.
> 
> Then use LineArray function to draw the line between the two points.
> 
> To get the channel, use the standard error code in the code below.
> To extend the channel to today, use the proper parameter on the
linearray 
> function
> 
> I have not tested this, so the channel may draw to the current day
without 
> extending.. I am not sure
> 
> The ending point:
> ----- Original Message ----- 
> From: "tradinghumble" <sharp2be@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Monday, July 28, 2008 9:42 PM
> Subject: [amibroker] How to enhance Linear Regression Channel Code
to plot 
> two previous days
> 
> 
> > Hello, I've seen this nice piece of code that plots linear regression
> > code and was wondering if anyone could help me with a hint on how to
> > plot the channel two days ago and extend it into today. I've already
> > fried my brain, can't get it... thanks in advance.
> >
> > SetBarsRequired(100000,0);
> > bar = BarIndex();
> > islastbar = bar == BarCount -10;
> > isfirstbar = bar == BarCount - 100;
> > firstbar = LastValue( ValueWhen( isfirstbar, bar ) );
> > lastbar = LastValue( ValueWhen( islastbar, bar ) );
> > al = LastValue( ValueWhen( islastbar, LinRegSlope( C, Lastbar -
> > firstbar + 1 ) ) );
> > bl = LastValue( ValueWhen( islastbar, LinRegIntercept( C, Lastbar -
> > firstbar + 1 ) ) );
> > Lr = al * ( BarIndex() - firstbar ) + bl;
> > Lr = IIf( bar = firstbar AND bar <= lastbar , Lr, Null );
> > se = StdErr(C,Lastbar - firstbar);
> > se = LastValue( ValueWhen( islastbar, StdErr( C, Lastbar - firstbar +
> > 1 ) ) );
> > upper = Lr + se;
> > Lower = Lr - se;
> >
> > Plot(Lr, "lr", colorYellow, styleThick );
> > Plot(upper, "upper", colorGreen, styleThick );
> > Plot(Lower, "lower", colorRed, styleThick );
> > SetBarFillColor( IIf( C  O, colorBrightGreen, colorRed ) );
> > Plot(C, "C", colorWhite, styleCandle );
> > Title = "bar= " + bar + " firstbar= " + firstbar + " lastbar= " +
> > lastbar+ " se= "+ se;
> >
> >
> >
> > ------------------------------------
> >
> > Please note that this group is for discussion between users only.
> >
> > To get support from AmiBroker please send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> > Yahoo! Groups Links
> >
> >
> >
>



------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/