Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Pairs Ratio Plot for Amibroker (AFL)
Pair ratio plot with regression channel enter pair ticker in parameter box.
Similar Indicators / Formulas
Indicator / Formula
_SECTION_BEGIN("Pair ratio"); Ticker= ParamStr("Short ticker", "type in ticker");//short stock //////////////////////////////////////////// tickersc=Foreign( ticker, "C");//Short stock //////////////////////////////////////////// ratio=C/tickersc; P=ratio; Plot(p ," /"+ ticker,5,5); /////////////////////////////////////////////////////// _SECTION_END(); _SECTION_BEGIN("Linear_Regression_Line_w__Std_Deviation_Channels"); // Linear Regression Line with 2 Standard Deviation Channels Plotted Above and Below // Written by Patrick Hargus, with critical hints from Marcin Gorzynski, Amibroker 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. P = ParamField("Price field",-1); Daysback = Param("Period for Liner Regression Line",21,1,360,1); shift = Param("Look back period",0,0,360,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); 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 ); // ========================== Plot 2d SD Channel =============================================================== SDP2 = Param("2d Standard Deviation", 2.0, 0, 6, 0.1); SD2 = SDP2/2; width2 = LastValue( Ref(SD2*StDev(p, Daysback),-shift) ); // THIS IS WHERE THE WIDTH OF THE CHANELS IS SET SDU2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y+width2 , Null ) ; SDL2 = IIf( x > (lastx - Daysback) AND BarIndex() < Lastx, y-width2 , Null ) ; SDColor2 = ParamColor("2 SD Color", colorCycle ); SDStyle2 = ParamStyle("2 SD Style"); Plot( SDU2 , "Upper Lin Reg", SDColor2,SDStyle2 ); Plot( SDL2 , "Lower Lin Reg", SDColor2,SDStyle2 ); // ============================ End Indicator Code ============================================================== _SECTION_END();
2 comments
Leave Comment
Please login here to leave a comment.
Back
Very useful,if you want to shift from one stock to another in the same sector. Thanks a lot
cnb
This I believe should be helpful in ETF pairs trading. But, I,m having a hard time knowing what it is telling me. Could someone tell me what to look for (to go Long/Short etc. Thanks
Dick H.
email areehoi@yahoo.com