Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Trend Detection Index for eSignal (EFS)
The trend detection index (TDI) is used to detect when a trend has begun and when it has come to an end. The TDI can be used as a stand-alone indicator or combined with others; it will perform well in detecting the beginning of trends.
Indicator / Formula
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /*********************************************************** Description : This Indicator plots the Trend Detection Index Provided By : TS Support, LLC for eSignal Modified by : Alexis C. Montenegro 08/04/2006 - converted to efs2 syntax - added multiple time frame/symbol capability - added moving average ***********************************************************/ var fpArray = new Array(); function preMain(){ setStudyTitle( "Trend Detection Index" ); setCursorLabelName( "TDI" ,0); setCursorLabelName( "MAofTDI" ,1); setDefaultBarFgColor(Color.blue, 0); setDefaultBarFgColor(Color.red, 1); setDefaultBarThickness(1,0); setDefaultBarThickness(1,1); var x=0; fpArray[x] = new FunctionParameter( "Length" , FunctionParameter.NUMBER); with (fpArray[x++]){ setLowerLimit(1); setDefault(12); } fpArray[x] = new FunctionParameter( "Source" , FunctionParameter.STRING); with (fpArray[x++]){ addOption( "open" ); addOption( "high" ); addOption( "low" ); addOption( "close" ); addOption( "hl2" ); addOption( "hlc3" ); addOption( "ohlc4" ); setDefault( "close" ); } fpArray[x] = new FunctionParameter( "Symbol" , FunctionParameter.STRING); with (fpArray[x++]){ setDefault(); } fpArray[x] = new FunctionParameter( "Interval" , FunctionParameter.STRING); with (fpArray[x++]){ setDefault(); } fpArray[x] = new FunctionParameter( "MAType" , FunctionParameter.STRING); with (fpArray[x++]){ addOption( "sma" ); addOption( "ema" ); addOption( "wma" ); setDefault( "sma" ); } fpArray[x] = new FunctionParameter( "MALength" , FunctionParameter.NUMBER); with (fpArray[x++]){ setLowerLimit(1); setDefault(3); } fpArray[x] = new FunctionParameter( "LineColor1" , FunctionParameter.COLOR); with (fpArray[x++]){ setName( "Color1" ); setDefault(Color.blue); } fpArray[x] = new FunctionParameter( "LineColor2" , FunctionParameter.COLOR); with (fpArray[x++]){ setName( "Color2" ); setDefault(Color.red); } fpArray[x] = new FunctionParameter( "Params" , FunctionParameter.BOOLEAN); with (fpArray[x++]){ setName( "Show Parameters" ); setDefault( false ); } } var bInit = false ; var xTDI = null ; var xMATDI = null ; function main(Length,Source,Symbol,Interval,MAType,MALength,LineColor1,LineColor2,Params){ if (bInit== false ){ if (Symbol == null ) Symbol = getSymbol(); if (Interval == null ) Interval = getInterval(); var vSymbol = Symbol+ "," +Interval; xTDI = getSeries(efsInternal( "calcTDI" , Length,eval(Source)(vSymbol))); xMATDI = getSeries(eval(MAType)(MALength,xTDI)); setDefaultBarFgColor(LineColor1,0); setDefaultBarFgColor(LineColor2,1); addBand(0,PS_SOLID,1,Color.lightgrey, "0" ); setShowTitleParameters(eval(Params)); bInit = true ; } return new Array (xTDI, xMATDI); } xMOM = null ; function calcTDI(period, source){ if (xMOM == null ) xMOM = mom(period,source); var MomSum = 0; var MomSumAbs = 0; var MomAbsSum = 0; var MomAbsSum2 = 0; for ( var i=0; i<period-1; i++){ MomSum += xMOM.getValue(-i); } MomSumAbs = Math.abs(MomSum); for ( var i=0; i<period-1; i++){ MomAbsSum += Math.abs(xMOM.getValue(-i)); } for ( var i=0; i<period*2-1; i++){ MomAbsSum2 += Math.abs(xMOM.getValue(-i)); } var ret = MomSumAbs - (MomAbsSum2 - MomAbsSum); return ret; } |
0 comments
Leave Comment
Please login here to leave a comment.
Back