RevEngRSI.efs
File Name: RevEngRSI.efs
Description:
Reverse Engineering RSI, by Giorgos Siligardos
Formula Parameters:
- WildPer : 14
- Value : 50
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
RevEngRSI.efs
EFS Code:
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2009. All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only and may be modified and saved under a new file name. eSignal is not responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. Description: Reverse Engineering RSI, by Giorgos Siligardos Version: 1.0 05/04/2009 Formula Parameters: Default: WildPer 14 Value 50 Notes: The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com. **********************************/ var fpArray = new Array(); var bInit = false; function preMain() { setPriceStudy(true); setStudyTitle("Reverse Engineering RSI"); setCursorLabelName("RSI",0); setDefaultBarFgColor(Color.red,0); var x = 0; fpArray[x] = new FunctionParameter("Value", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(50); } fpArray[x] = new FunctionParameter("WildPer", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(14); } } var xRevEngRSI = null; function main(Value, WildPer) { var nBarState = getBarState(); var nRevEngRSI = 0; if (nBarState == BARSTATE_ALLBARS) { if(Value == null) Value = 50; if(WildPer == null) WildPer = 14; } if (bInit == false) { xRevEngRSI = efsInternal("Calc_RevEngRSI", Value, WildPer); bInit = true; } nRevEngRSI = xRevEngRSI.getValue(0); if (nRevEngRSI == null) return; return nRevEngRSI; } var bSecondInit = false; var xAUC = null; var xADC = null; var xClose = null; function Calc_RevEngRSI(Value, WildPer) { var nRes = 0; var ExpPer = 2 * WildPer - 1; var K = 2 / (ExpPer + 1); var nADC = 0; var nAUC = 0; var nVal = 0; if (bSecondInit == false) { xClose = close(); xAUC = efsInternal("Calc_AUC", K, xClose); xADC = efsInternal("Calc_ADC", K, xClose); } nAUC = xAUC.getValue(0); nADC = xADC.getValue(0); if (nAUC == null || nADC == null) return; nVal = (WildPer - 1) * (nADC * Value / (100 - Value) - nAUC); if(nVal >= 0) nRes = xClose.getValue(0) + nVal; else nRes = xClose.getValue(0) + nVal * (100 - Value) / Value; return nRes; } function Calc_AUC(K, xClose) { var nRes = 0; var nRef = ref(-1); if (xClose.getValue(-1) == null) return; if(xClose.getValue(0) > xClose.getValue(-1)){ nRes = K * (xClose.getValue(0) - xClose.getValue(-1)) + (1 - K) * nRef; } else { nRes = (1 - K) * nRef; } return nRes; } function Calc_ADC(K, xClose) { var nRes = 0; var nRef = ref(-1); if (xClose.getValue(-1) == null) return; if(xClose.getValue(0) > xClose.getValue(-1)){ nRes = (1 - K) * nRef; } else { nRes = K * (xClose.getValue(-1) - xClose.getValue(0)) + (1 - K) * nRef; } return nRes; }