PureBytes Links
Trading Reference Links
|
Hi all,
I've been really struggling with this, any ideas greatly appreciated.
The code below displays a linear regression line and scrolls it with the window however, I haven't been able to get it to work when used as exploration on previous dates. The aa, bb & y values don't change.
I presume it has got something to do with LastValue() function but I haven't been able to sort it out.
Cheers :-)
//Initialise variables
x = Cum(1); //Bar
Daysback = 10; //Period for Liner Regression Line
P = C; //Price field
if(Status("action") ==4) { //If in "exploration" mode
shift = LastValue(x) - x + 1; //Shift reg channel back
}else{ //Not in "exploration" mode
shift = LastValue(x) - Status("lastvisiblebar"); //Shift reg channel 1 bar back from last visible bar
}
lastx = LastValue(x) - shift;
//Linear Regression Line
aa = LastValue(Ref(LinRegIntercept(p, Daysback), -shift));
bb = LastValue(Ref(LinRegSlope(p, Daysback), -shift));
y = Aa + bb * (x - (Lastx - DaysBack + 1));
LRLine = IIf( x > (lastx - Daysback) AND x <= Lastx, y, Null );
Plot( LRLine , "LinReg", colorRed);
//Exploration
Filter = 1;
AddColumn(x, "x");
AddColumn(Lastx, "Lastx");
AddColumn(shift, "shift");
AddColumn(aa, "aa");
AddColumn(bb, "bb");
AddColumn(y, "y");
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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/
|