Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Trend Continuation Factor for eSignal (EFS)
The Trend Continuation Factor is an indicator built to draw trend state. It is a typical momentum indicator calculated with the rate over change price movement, compound over a summation period.
You will need to save the attached easyArray.efsLib file in the FunctionLibrary folder of the eSignal directory.
All credits to Alexis C. Montenegro
Files
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | /********************************************************* Alexis C. Montenegro © October 2005 Use and/or modify this code freely. If you redistribute it please include this and/or any other comment blocks and a description of any changes you make. **********************************************************/ var fpArray = new Array(); function preMain(){ setPriceStudy( false ); setStudyTitle( "Trend Continuation Factor" ); setCursorLabelName( "TCF+" , 0); setCursorLabelName( "TCF-" , 1); setDefaultBarFgColor(Color.blue, 0); setDefaultBarFgColor(Color.red, 1); setPlotType(PLOTTYPE_LINE,0); setPlotType(PLOTTYPE_LINE,1); setDefaultBarThickness(1,0); setDefaultBarThickness(1,1); var x=0; fpArray[x] = new FunctionParameter( "Length" , FunctionParameter.NUMBER); with (fpArray[x++]){ setLowerLimit(2); setDefault(20); } 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( "Params" , FunctionParameter.BOOLEAN); with (fpArray[x++]){ setName( "Show Parameters" ); setDefault( false ); } } var bInit = false ; var xTCF = null ; var xTCFPos = null ; var xTCFNeg = null ; function main(Length,Source,Symbol,Interval,Params){ if (bInit == false ){ if (Symbol == null ) Symbol = getSymbol(); if (Interval == null ) Interval = getInterval(); var vSymbol = Symbol+ "," +Interval; xTCF = efsInternal( "calcTCF" ,Length,eval(Source)(sym(vSymbol))); xTCFPos = getSeries(xTCF,0); xTCFNeg = getSeries(xTCF,1); addBand( 0, PS_SOLID, 1, Color.black, "0" ); setShowTitleParameters(eval(Params)); bInit = true ; } return new Array (xTCFPos,xTCFNeg); } var myLib = addLibrary( "easyArray.efsLib" ); //comment out this line if not using the ezArray() function var pVar = 0; var nVar = 0; var pCF = 0; var nCF = 0; /* add a / at the beginning of this line if using conventional logic var apVar = null; var anVar = null; var apCF = null; var anCF = null; //*/ function calcTCF(length,source){ /* ARRAY CREATED AND MAINTAINED USING CONVENTIONAL LOGIC */ /* add a / at the beginning of this line if using conventional logic if(apVar==null) apVar = new Array (length); if(anVar==null) anVar = new Array (length); if(apCF==null) apCF = new Array (length); if(anCF==null) anCF = new Array (length); if(getBarState()==BARSTATE_NEWBAR){ apVar.pop(); anVar.pop(); apCF.pop(); anCF.pop(); apVar.unshift(pVar); anVar.unshift(nVar); apCF.unshift(pCF); anCF.unshift(nCF); } if(apVar[length-1]==null || anVar[length-1]==null || apCF[length-1]==null || anCF[length-1]==null) return; // END CONVENTIONAL ARRAY LOGIC */ /* ARRAY CREATED AND MAINTAINED USING ezArray() FUNCTION */ //* remove a / at the beginning of this line if using conventional logic var apVar = myLib.ezArray(pVar,length, "PosVar" ); var anVar = myLib.ezArray(nVar,length, "NegVar" ); var apCF = myLib.ezArray(pCF,length, "PosCF" ); var anCF = myLib.ezArray(nCF,length, "NegCF" ); if (apVar[length-1]== null || anVar[length-1]== null || apCF[length-1]== null || anCF[length-1]== null ) return ; // END ezArray() LOGIC */ var Source_0 = source.getValue(0); var Source_1 = source.getValue(-1); if (Source_0== null || Source_1== null ) return ; if (Source_0>Source_1){ pVar = Source_0-Source_1; nVar = 0; } else { pVar = 0; nVar = Source_1-Source_0; } if (pVar == 0){ pCF = 0; nCF = nVar+anCF[1]; } else { pCF = pVar+apCF[1]; nCF = 0; } // the following lines update the most recent element of the array // and are required by both the conventional and ezArray() logic apVar[0] = pVar; anVar[0] = nVar; apCF[0] = pCF; anCF[0] = nCF; // end array update var sumpVar = 0 var sumnVar = 0; var sumpCF = 0; var sumnCF = 0 for ( var i=0; i<length; i++){ sumpVar += apVar[i]; sumnVar += anVar[i]; sumpCF += apCF[i]; sumnCF += anCF[i]; } var pTCF = sumpVar-sumnCF; var nTCF = sumnVar-sumpCF; return new Array (pTCF, nTCF); } |
0 comments
Leave Comment
Please login here to leave a comment.
Back