Tham khảo tài liệu 'ehlers, john - cybernetics analysis for stock and futures_4', tài chính - ngân hàng, đầu tư chứng khoán phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 70 CYBERNETIC ANALYSIS FOR STOCKS AND FUTURES setCursorLabelName StocRSI 0 setCursorLabelName Trig 1 setDefaultBarFgColor 0 setDefaultBarFgColor 1 initialize arrays for x 0 x 70 X aRSIArrayfx aValue3Array x Main processing function function main RSILength StocLength WMALength var X var nDiff var nDivBy var nValuel var nValue2 initialize parameters if necessary if RSILength null RSILength 8 if StocLength null StocLength 8 if WMALength null WMALength 8 study is initializing if getBarState BARSTATE_ALLBARS return null initialize the basic RSI calculation if blnitialized false nAvgUpClose nAvgDnClose for x 0 x RSILength X FIGURE Continued Stochasticization and Fisherization of Indicators 71 nDiff close -X - close - x 1 if nDiff 0 nAvgUpClose nDiff else nAvgDnClose nDiff nAvgUpClose RSILength nAvgDnClose RSILength nRS nAvgUpClose nAvgDnClose nRSI - nRS blnitialized true continue the RSI calculation on subsequent bars else if getBarStateO BARSTATE-NEWBAR nAvgUpClose ntAvgUpClose nAvgDnClose ntAvgDnClose if tisNaNt nRSI 0 0 nTrig nValue4 nDiff closet 0 - closet -1 if nDiff 0 ntAvgUpClose nAvgUpClose RSILength-1 nDiff I RSILength ntAvgDnClose nAvgDnClose RSILength-1 0 RSILength continued FIGURE Continued 72 CYBERNETIC ANALYSIS FOR STOCKS AND FUTURES else ntAvgUpClose nAvgUpClose RSILength-1 0 RSILength ntAvgDnClose nAvgDnClose RSILength-1 nDiff RSILength nRS ntAvgUpClose ntAvgDnClose nRSI - 1 nRS aRSIArray 0 nRSI calculate the StocRSI using the RSI Array we. have created. nValuel nRSI - Lowest StocLength nValue2 Highest StocLength - Lowest StocLength nValue3 0 if nValue2 0 nValue3 nValuel I nValue2 aValue3Array 0 nValue3 compute weighted moving average nValue4 0 nDivBy 0 for x 0 x WMALength X nValue4 aValue3Array x WMALength-x nDivBy WMALength-x nValue4 nValue4 nDivBy nValue4 nValue4 - return the calculated