Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 8/11/2005(UTC) Posts: 104
|
Hi,
Thank you for your reply
Below is the Amibroker code for the "Shift" I wish I want to achive to the Standard Channel
The code Plots the "Shifted" Channels OK
I hope you get the oode OK
I had to alter the "Param" numbers of the Shift
Link below:in case the code is corrupted on the internet
http://www.traderji.co...on-trend-channels.htm l
Best regards,
Derek
================================
// Linear Regression Line with 2 Standard Deviation Channels Plotted Above and Below
// Written by Patrick Hargus, with critical hints from Marcin Gorzynski, Amibroker.com Technical Support
// Designed for use with AB 4.63 beta and above, using drag and drop feature.
// Permits plotting a linear regression line of any price field available on the chart for a period determined by the user.
// 2 Channels, based on a standard deviation each determined by the user, are plotted above and below the linear regression line.
// A look back feature is also provided for examining how the indicator would have appeared on a chart X periods in the past.
// BarIndex() is the same as Cum(1)-1 but is much faster than Cum(1)
*code*
Plot( C, "Close", colorBlue, styleBar | styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
P = ParamField("Price field",-1);
Daysback = Param("Period for Liner Regression Line",21,1,240,1);
shift = Param("Look back period",0.30,0,0,240,1);
// =============================== Math Formula ================================
x = Cum(1);
lastx = LastValue( x ) - shift;
aa = LastValue( Ref(LinRegIntercept( p, Daysback), -shift) );
bb = LastValue( Ref(LinRegSlope( p, Daysback ), -shift) );
y = Aa + bb * ( x - (Lastx - DaysBack +1 ) );
// ==================Plot the Linear Regression Line ===============================
LRColor = ParamColor("LR Color", colorCycle );
LRStyle = ParamStyle("LR Style");
LRLine = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y, Null );
Plot( LRLine , "LinReg", LRCOLOR, LRSTYLE ); // styleDots );
// ========================== Plot 1st SD Channel ==============================
//SDP = Param("Standard Deviation", 1.5, 0, 6, 0.1);//1.5 default
//SDP = Param("Standard Deviation" ,0.30, 0, 6, 0.1);//1.5 default
SDP = Param("Standard Deviation" ,0.30, 0, 6, 0.1);//1.5 default
SD = SDP/2;
width = LastValue( Ref(SD*StDev(p, Daysback),-shift) ); // THIS IS WHERE THE WIDTH OF THE CHANELS IS SET
SDU = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width , Null ) ;
SDL = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width , Null ) ;
SDColor = ParamColor("SD Color", colorCycle );
SDStyle = ParamStyle("SD Style");
Plot( SDU , "Upper Lin Reg", SDColor,SDStyle );
Plot( SDL , "Lower Lin Reg", SDColor,SDStyle );
// ============================ End Indicator Code ========
*/code* Edited by user Friday, September 23, 2016 3:10:37 PM(UTC)
| Reason: Info Note: BarIndex() is the same as Cum(1)-1 but is much faster than Cum(1)
|