示例#1
0
        public double set(double curVal, int barNum)
        {
            double min, delta = max.set(curVal, barNum) - (min = this.min.set(curVal, barNum));

            if (barNum != lastBar)
            {
                lastBar = barNum;
                if (bars < period)
                {
                    if (++bars > 1)
                    {
                        c1 = Math.Pow(1 / (bars - 1), 2);
                        c2 = Math.Log(2 * (bars - 1));
                    }
                }
            }

            if (bars < 2 || (delta <= double.Epsilon && -delta <= double.Epsilon))
            {
                return(1);
            }

            double length = 0, yPrev = (curVal - min) / delta;

            for (int i = 1; i < bars; ++i)
            {
                double y = (value[(barNum - i) % period] - min) / delta;
                length += Math.Sqrt(Math.Pow(y - yPrev, 2) + c1);
                yPrev   = y;
            }

            return(1.0 + (Math.Log(length) + constants.log_2) / c2);
        }
示例#2
0
 public FractalDimension(int period)
 {
     this.period = Math.Max(1, period);
     min         = new MIN(this.period);
     max         = new MAX(this.period);
     value       = min.value;
 }
		public double set(double curVal, int barNum)
		{
			double min, delta = max.set(curVal, barNum) - (min = this.min.set(curVal, barNum));
			
			if ( barNum != lastBar ) {
				lastBar = barNum;
				if ( bars < period ) {
					if ( ++bars > 1 ) {
						c1 = Math.Pow(1 / (bars - 1), 2);
						c2 = Math.Log(2 * (bars - 1));
					}
				}
			}
			
			if ( bars < 2 || (delta <= double.Epsilon && -delta <= double.Epsilon) )
				return 1;
			
			double length = 0, yPrev = (curVal - min) / delta;
			for ( int i = 1; i < bars; ++i ) {
				double y = (value[(barNum - i) % period] - min) / delta;
				length += Math.Sqrt(Math.Pow(y - yPrev, 2) + c1);
				yPrev = y;
			}
			
			return 1.0 + (Math.Log(length) + constants.log_2) / c2;
		}
		public FractalDimension(int period)
		{
			this.period = Math.Max(1, period);
			min = new MIN(this.period);
			max = new MAX(this.period);
			value = min.value;
		}
示例#5
0
        }											// Intrabar are fast and never iterate.
		
		protected override void OnStartUp()
		{
			min = new JHL.Utility.MIN(period);
		}
示例#6
0
        }                                                                                       // Intrabar are fast and never iterate.

        protected override void OnStartUp()
        {
            min = new JHL.Utility.MIN(period);
        }