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

Re: [amibroker] Correlation Index/RSI - AFL Indicators



PureBytes Links

Trading Reference Links

Peter Is there any other method that you can use to share the code in these indicators?  As you see below they are scrambled quite well.  I know they are encoded but why is it necessary to encode them?  They are only text files. Steve At 12:03 AM 6/6/01 +0100, you wrote: Attached are two AFL Indicators that I've been experimenting with that some of you may find of interest.  They are intended for those of us who are dabbling with AFL code and exploring its possibilities. My aim was to explore the 'Correlation' function and what I could use it for. This code, draws an indicator that compares stock data with an index (or other data).   It attempts to identify if the stock price trends have any similarity with, or opposite movement to, that index (or other data). So the closer the indicator is to +100% the closer the synchronicity of the data - ie similar tendency/trend.  Conversely, the closer to -100% the indicator the more dissimilar the data - ie the two data sources tend to move in opposite directions to each other.  I have found it useful in spotting divergences. Of course, this is not a new idea and there must be many texts already written on this kind of indicator.  There is also its clear relationship with the Relative Strength Indicator in its comparison with an index. An explanation of each line of code follows for novices, I hope its helpful and apologise in advance if it's too simplistic :-) ==================================================== periods = 50 ; /*  'Periods' are the number of days/ticks/bars chosen.  The 'periods' variable has been used so that it can easily be adjusted without having to change other lines of code further down.  The number can be changed to suit the user - lower is more sensitive, higher is smoother. 'Periods' holds this value for later use.  */ index = foreign( "UKX2", "close" ) ; /*  The 'Index' variable will hold the close value of the index (UKX2 in UK - change these letters to whatever your index ticker code is for your country).  The 'foreign' function searches for the close value of the index and it is placed in 'index' for later use.  */ graph0 = 100 * correlation( close, index, periods ) ; /*  'graph0' is also a variable that will hold the result of the formula after the equals sign.  Additionally, whatever is held in 'graph0' will be plotted on the graph.  The Correlation function compares the selected stocks 'close' price with the 'index' close value over the number of 'periods' originally chosen by the user.  This calculation will produce a value between -1 and +1 and is multiplied by 100 to turn it into a percentage for the graph.  */ title = name() + " Correlation Index (" + writeval( periods, 1.0 ) + ")" + writeval( graph0 ) + "%" ; /*  The 'title' variable will hold, and display on the graph, the name/ticker of the selected stock, PLUS the text placed in quotes, PLUS the value of 'periods' placed in parentheses, PLUS the current value of the 'graph0' variable, PLUS a percentage sign - because the correlation value was multiplied by 100. ==================================================== Peter [ Section: 1/1 File: Correlation_Index.afl UUencoded by: Turnpike 6.00 Beta 4 ] begin 644 Correlation_Index.afl M+RH@($-/4E)%3$%424].($E.1$58(&)Y(%!E=&5R($-A6YC"P@ M<&5R:6]D"`H(B`K('=R:71E=F%L*"!P97)I;V1S+"`Q+C`@*2`K("(I(B`-"BL@ :=W)I=&5V86PH(&=R87!H,"`I("L@(B4B(#L` ` end sum -r/size 44263/1254 section (from "begin" to "end") sum -r/size 30151/881 entire input file [ Section: 1/1 File: Correlation_RSI.afl UUencoded by: Turnpike 6.00 Beta 4 ] begin 644 Correlation_RSI.afl M+RH@($-/4E)%3$%424].(%)322!B>2!0971E2!S>6YC