Elhers
TrendLine Indicator has an error.
TrendLine Indicator has an error.
/******************************************************************* Description : This Indicator plots VIDYA StdDev2 indicator Provided By : Developed by TS Support, LLC for eSignal. (c) Copyright 2002 ********************************************************************/ function preMain() { setPriceStudy(true); setStudyTitle("VIDYA (StdDev) - 2 Lines"); setCursorLabelName("VIDYA1", 0); setCursorLabelName("VIDYA2", 1); setDefaultBarFgColor(Color.blue, 0); setDefaultBarFgColor(Color.red, 1); } var StdDevVidya1_1 = null; var StdDevVidya2_1 = null; var StdDev = null; function main(Alpha1, Alpha2, sPrice, Length) { var BarState = getBarState(); if (Alpha1 == null) Alpha1 = 0.2; if (Alpha2 == null) Alpha2 = 0.04; if (sPrice == null) sPrice = "Close"; if (Length == null) Length = 20; var Price = getValue(sPrice, 0, -(Length + 1)); var i = 0; if ((StdDevVidya1_1 == null)||(StdDev == null)||(StdDevVidya2_1 == null)) { StdDevVidya1_1 = Price[0]; StdDevVidya2_1 = Price[0]; StdDev = new Array(Length); for (i = 0; i < Length; i++) { StdDev[i] = 0.0; } return; } if (BarState == BARSTATE_NEWBAR) { for (i = Length - 1; i > 0; i--) { StdDev[i] = StdDev[i - 1]; } } var Avg = 0.0; for (i = 0; i < Length; i++) { Avg += Price[i]; } Avg /= Length; var SumSqr = 0.0; for (i = 0; i < Length; i++) { SumSqr += (Price[i] - Avg) * (Price[i] - Avg); } StdDev[0] = Math.sqrt(SumSqr / Length); Avg = 0.0; for (i = 0; i < Length; i++) { Avg += StdDev[i]; } Avg /= Length; var StdDevVidya1 = (Alpha1 * (StdDev[0] / Avg) * Price[0]) + ((1 - (Alpha1 * (StdDev[0] / Avg))) * StdDevVidya1_1); var StdDevVidya2 = (Alpha2 * (StdDev[0] / Avg) * Price[0]) + ((1 - (Alpha2 * (StdDev[0] / Avg))) * StdDevVidya2_1); if (BarState == BARSTATE_NEWBAR) { StdDevVidya1_1 = StdDevVidya1; StdDevVidya2_1 = StdDevVidya2; } return new Array(StdDevVidya1, StdDevVidya2); }
/******************************************************************* Description : This Indicator plots the Negative Volume Index Provided By : TS Support, LLC for eSignal ********************************************************************/ function preMain(){ setStudyTitle("Negative Volume Index"); setCursorLabelName("NVI",0); setDefaultBarFgColor(Color.red,0); setCursorLabelName("EMA",1); setDefaultBarFgColor(Color.blue,1); } var NVI = 0; var EMA_1 = 0; function main(EMA_Len){ if(EMA_Len == null) EMA_Len = 255; var K = 2 / (EMA_Len + 1); var ROC = 0; ROC = (close() - close(-1)) / close(-1); if(volume() < volume(-1) && getBarState() == BARSTATE_NEWBAR) NVI += ROC; EMA = K * NVI + (1 - K) * EMA_1; if (getBarState() == BARSTATE_NEWBAR) EMA_1 = EMA; return new Array(NVI,EMA); } /////////////////////////////////////////////////////////////////////// /******************************************************************* Description : This Indicator plots the Positive Volume Index Provided By : TS Support, LLC for eSignal ********************************************************************/ function preMain(){ setStudyTitle("Positive Volume Index"); setCursorLabelName("PVI",0); setDefaultBarFgColor(Color.red,0); setCursorLabelName("EMA",1); setDefaultBarFgColor(Color.blue,1); } var PVI = 0; var EMA_1 = 0; function main(EMA_Len){ if(EMA_Len == null) EMA_Len = 255; var K = 2 / (EMA_Len + 1); var ROC = 0; ROC = (close() - close(-1)) / close(-1); if(volume() > volume(-1) && getBarState() == BARSTATE_NEWBAR) PVI += ROC; EMA = K * PVI + (1 - K) * EMA_1; if (getBarState() == BARSTATE_NEWBAR) EMA_1 = EMA; return new Array(PVI,EMA); }
/******************************************************************* Description : This Indicator plots the Trend Detection Indexs Provided By : TS Support, LLC for eSignal ********************************************************************/ function preMain(){ setStudyTitle("Trend Detection Index"); setCursorLabelName("TDI",0); setDefaultBarFgColor(Color.blue,0); addBand(0, PS_SOLID, 1, Color.lightgrey); } mom = null; function main(Period){ if(Period == null) Period = 12; if(mom == null) mom = new MOMStudy(Period, "Close"); var MomSum = 0, MomSumAbs = 0; MomAbsSum = 0, MomAbsSum2 = 0; for(i = -Period + 1; i++; i <= 0) MomSum += mom.getValue(MOMStudy.MOM,i); MomSumAbs = Math.abs(MomSum); for(i = -Period + 1; i++; i <= 0) MomAbsSum += Math.abs(mom.getValue(MOMStudy.MOM,i)); for(i = -Period * 2 + 1; i++; i <= 0) MomAbsSum2 += Math.abs(mom.getValue(MOMStudy.MOM,i)); TDI = MomSumAbs - (MomAbsSum2 - MomAbsSum); return TDI; }
...
for(i = -Period + 1; i++; i <= 0)
MomSum += mom.getValue(MOMStudy.MOM,i);
MomSumAbs = Math.abs(MomSum);
for(i = -Period + 1; i++; i <= 0)
MomAbsSum += Math.abs(mom.getValue(MOMStudy.MOM,i));
...
for(i = -Period +1; i <= 0; i++)
...
for(i = -Period; i++;) MomSum += mom.getValue(MOMStudy.MOM,i);
for(i = -Period + 1; i<=0; i++;) MomSum += mom.getValue(MOMStudy.MOM,i);
/************************************************ Description : This Indicator plots the Trend Detection Indexs Provided By : TS Support, LLC for eSignal ************************************************/ function preMain(){ setStudyTitle("Trend Detection Index"); setCursorLabelName("TDI",0); setDefaultBarFgColor(Color.blue,0); addBand(0, PS_SOLID, 1, Color.lightgrey); } mom = null; function main(Period){ if(Period == null) Period = 12; if(mom == null) mom = new MOMStudy(Period, "Close"); var MomSum = 0, MomSumAbs = 0; MomAbsSum = 0, MomAbsSum2 = 0; for(i = -Period; i++;) MomSum += mom.getValue(MOMStudy.MOM,i); MomSumAbs = Math.abs(MomSum); for(i = -Period; i++;) MomAbsSum += Math.abs(mom.getValue(MOMStudy.MOM,i)); for(i = -Period * 2; i++;) MomAbsSum2 += Math.abs(mom.getValue(MOMStudy.MOM,i)); TDI = MomSumAbs - (MomAbsSum2 - MomAbsSum); return TDI; }
/******************************************************************* Description : This Indicator plots the Chaikin Oscillator Provided By : TS Support, LLC for eSignal ********************************************************************/ function preMain(){ setStudyTitle("Chaikin Oscillator"); setCursorLabelName("ChaikinOsc",0); setDefaultBarFgColor(Color.blue,0); addBand(0, PS_SOLID, 1, Color.lightgrey); } var AccumDist_1 = 0; var FEMA_1 = 0; var SEMA_1 = 0; function main(Slow,Fast){ if(Slow == null) Slow = 20; if(Fast == null) Fast = 10; var K1 = 2 / (Fast + 1); var K2 = 2 / (Slow + 1); var AccumDist = 0; if( ( high() - low() ) * volume() > 0) AccumDist = AccumDist_1 + ((close() - open()) / (high() - low()) * volume()); FEMA = K1 * AccumDist + (1 - K1) * FEMA_1; SEMA = K2 * AccumDist + (1 - K2) * SEMA_1; if (getBarState() == BARSTATE_NEWBAR){ AccumDist_1 = AccumDist; FEMA_1 = FEMA; SEMA_1 = SEMA; } return SEMA - FEMA; }
/******************************************************************* Description : This Indicator plots T3 Averages Provided By : Developed by TS Support, LLC for eSignal. (c) Copyright 2002 ********************************************************************/ function preMain() { setPriceStudy(true); setCursorLabelName("T3Avg"); } var e1_1 = 0.0; var e2_1 = 0.0; var e3_1 = 0.0; var e4_1 = 0.0; var e5_1 = 0.0; var e6_1 = 0.0; function main(Price, Periods) { if (Price == null) Price = "Close"; if (Periods == null) Periods = 5; var vPrice = getValue(Price, 0); var b = 0.7; var b2 = b * b; var b3 = b * b * b; var c1 = -b3; var c2 = 3 * b2 + 3 * b3; var c3 = -6 * b2 - 3 * b - 3 * b3; var c4 = 1 + 3 * b + b3 + 3 * b2; var f1 = 2 / (Periods + 1); var f2 = 1 - f1; var e1 = f1 * vPrice + f2 * e1_1; var e2 = f1 * e1 + f2 * e2_1; var e3 = f1 * e2 + f2 * e3_1; var e4 = f1 * e3 + f2 * e4_1; var e5 = f1 * e4 + f2 * e5_1; var e6 = f1 * e5 + f2 * e6_1; if (getBarState() == BARSTATE_NEWBAR) { e1_1 = e1; e2_1 = e2; e3_1 = e3; e4_1 = e4; e5_1 = e5; e6_1 = e6; } var T3Average = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3; return T3Average; }
Comment