DALE$! RSI BANDS ! Author: Francois Bertrand, TASC April 2008 ! Coded by Richard Denning 02/11/08 ! ABBREVIATIONS: C is [close]. C1 is valresult(C,1). ! INPUTS: period is 14. upTgt is 70. dnTgt is 30. clamp is 0. ! 1=use clamping; <>1=do not use clamping !! RSI WILDER (standard RSI code for three different length RSI indicators): ! To convert Wilder Averaging to Exponential Averaging: ! ExponentialPeriods = 2 * WilderPeriod - 1. U is C - C1. D is C1 - C. W1 is period. L1 is 2 * W1 - 1. avgU is ExpAvg(iff(U>0,U,0),L1). avgD is ExpAvg(iff(D>=0,D,0),L1). rsi is 100-(100/(1+(AvgU/AvgD))). ! RSI BAND CODE STARTS HERE: avgU1 is valresult(AvgU,1). avgD1 is valresult(AvgD,1). upFact is 100 / (100 - upTgt) - 1. dnFact is 100 / (100 - dnTgt) - 1. ! UPPER AND LOWER VALUES WITHOUT CLAMPING: upRSIr is C1 + (upFact * avgD1*(period-1) - avgU1*(period-1)). dnRSIr is C1 - (avgU1*(period-1)/dnFact - avgD1*(period-1)). ! OPTIONAL CLAMPING MODE: upRSIc is max(min(upRSIr, C1*1.1),max(dnRSIr, C1*0.9)). dnRSIc is min(max(dnRSIr, C1*0.9),min(upRSIr, C1*1.1)). ! PLOT AS SINGLE LINE INDICATOR IN CHART PANEL-UPPER RSI BAND upRSI is iff(clamp=1,upRSIc,upRSIr). ! PLOT AS SINGLE LINE INDICATOR IN CHART PANEL-LOWER RSI BAND dnRSI is iff(clamp=1,dnRSIc,dnRSIr). Rule Library˙˙ CCodeView§˙˙˙˙00:00