J_TPO_Velocity.efs EFSLibrary - Discussion Board
File Name: J_TPO_Velocity.efs
Description:
J TPO Velocity
Formula Parameters:
Length : 14
Point : 0.01
Notes:
J_TPO is in its original form, an oscillator between -1 and +1,
a nonparametric statistic quantifying how well the prices are ordered
in consecutive ups (+1) or downs (-1) or intermediate cases in between.
Download File:
J_TPO_Velocity.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: J TPO Velocity Version: 1.0 10/29/2009 Formula Parameters: Default: Length 14 Point 0.01 Notes: J_TPO is in its original form, an oscillator between -1 and +1, a nonparametric statistic quantifying how well the prices are ordered in consecutive ups (+1) or downs (-1) or intermediate cases in between. **********************************/ var fpArray = new Array(); var bInit = false; function preMain(){ setPriceStudy(false); setShowCursorLabel(true); setShowTitleParameters(false); setStudyTitle("J TPO Velocity"); setCursorLabelName("JTPOVelocity", 0); setPlotType(PLOTTYPE_LINE, 0); setDefaultBarFgColor(Color.blue, 0); var x = 0; fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(14); } fpArray[x] = new FunctionParameter("Point", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(0); setDefault(0.01); } } var xJTPOV = null; function main(Length, Point) { var nBarState = getBarState(); var nJTPOV = 0; if (nBarState == BARSTATE_ALLBARS) { if(Length == null) Length = 14; if(Point == null) Point = 0.01; } if (bInit == false) { addBand(0, PS_SOLID, 1, Color.black, "Zero"); xJTPOV = efsInternal("Calc_xJTPOV", Length, Point); bInit = true; } nJTPOV = xJTPOV.getValue(0); if (nJTPOV == null) return; return nJTPOV; } var bSecondInit = false; var xRange = null; var xTPO = null; function Calc_xJTPOV(Length, Point) { var nRes = 0; var nRange = 0; var nTPO = 0; if (bSecondInit == false) { xRange = efsInternal("Calc_Range", Length, Point); xTPO = efsInternal("Calc_TPO", Length); bSecondInit = true; } nRange = xRange.getValue(0); nTPO = xTPO.getValue(0); if (nRange == null || nTPO == null) return; nRes = nTPO * nRange / Length; return nRes; } var bThirdInit = false; var xHighest = null; var xLowest = null; function Calc_Range(Length, Point) { var nRes = 0; var nHighest = 0; var nLowest = 0; if (bThirdInit == false) { xHighest = upperDonchian(Length, high()); xLowest = lowerDonchian(Length, low()); bThirdInit = true; } nHighest = xHighest.getValue(0); nLowest = xLowest.getValue(0); if (nHighest == null || nLowest == null) return; nRes = (nHighest - nLowest) / Point; return nRes; } var bFourInit = false; var xClose = null; function Calc_TPO(Length) { var nRes = 0; var normalization = 0; var Lenp1half = 0; var accum = 0; var tmp = 0; var maxval = 0; var j = 0; var maxloc = 0; var m = 0; var n = 0; var arr1 = new Array(); var arr2 = new Array(); var arr3 = new Array(); var flag = false; if (bFourInit == false) { xClose = close(); bFourInit = true; } if (xClose.getValue(-Length) == null) return; accum = 0; for(m = 1; m <= Length; m++) { arr2[m]=m; arr3[m]=m; arr1[m]= xClose.getValue(-(Length - m)); } for(m = 1; m <= (Length - 1); m++) { maxval = arr1[m]; maxloc = m; for(j = m+1; j <= Length; j++) { if (arr1[j] < maxval) { maxval=arr1[j]; maxloc=j; } } tmp = arr1[m]; arr1[m] = arr1[maxloc]; arr1[maxloc] = tmp; tmp = arr2[m]; arr2[m] = arr2[maxloc]; arr2[maxloc] = tmp; } m=1; while(m < Length) { j = m + 1; flag = true; accum = arr3[m]; while(flag) { if (arr1[m] != arr1[j]) { if ((j - m) > 1) { accum = accum / (j - m); for(n = m; n <= (j-1); n++) { arr3[n] = accum; } } flag = false; } else { accum += arr3[j]; j++; } } m=j; } normalization = 12.0 / (Length * (Length - 1) * (Length + 1)); Lenp1half = (Length + 1) * 0.5; for(accum = 0, m = 1; m <= Length; m++) { accum += (arr3[m] - Lenp1half) * (arr2[m] - Lenp1half); } nRes = normalization * accum; return nRes; }