예제 #1
0
        //for code based construction
        public FOM(BarHistory source, Int32 period)
            : base()
        {
            Parameters[0].Value = source;
            Parameters[1].Value = period;

            Populate();
        }
예제 #2
0
        //for code based construction
        public RelVol(BarHistory bars, Int32 period)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = period;

            Populate();
        }
예제 #3
0
 //for code based construction
 public ATRTrail(BarHistory source, Int32 period, Double factor)
     : base()
 {
     Parameters[0].Value = source;
     Parameters[1].Value = period;
     Parameters[2].Value = factor;
     Populate();
 }
예제 #4
0
        //for code based construction
        public MoneyFlowOscillator(BarHistory source, Int32 period)
            : base()
        {
            Parameters[0].Value = source;
            Parameters[1].Value = period;

            Populate();
        }
예제 #5
0
 public SCTR(TimeSeries source, int multiplier, int smoothingPeriod, BarHistory bars) : base()
 {
     Parameters[0].Value = source;
     Parameters[1].Value = multiplier;
     Parameters[2].Value = smoothingPeriod;
     Parameters[3].Value = bars;
     Populate();
 }
예제 #6
0
        //for code based construction
        public HACO(BarHistory source, Int32 period, Int32 timeout)
            : base()
        {
            Parameters[0].Value = source;
            Parameters[1].Value = period;
            Parameters[2].Value = timeout;

            Populate();
        }
        //populate
        public override void Populate()
        {
            BarHistory ds           = Parameters[0].AsBarHistory;
            Int32      period       = Parameters[1].AsInt;
            Int32      periodSmooth = Parameters[1].AsInt;

            DateTimes = ds.DateTimes;

            if (period <= 0 || periodSmooth <= 0 || ds.Count == 0)
            {
                return;
            }

            //Assign first bar that contains indicator data
            var FirstValidValue = Math.Max(periodSmooth, period);

            if (FirstValidValue > ds.Count)
            {
                FirstValidValue = ds.Count;
            }

            if (ds.Count < 2)
            {
                return;
            }

            var _avg = (ds.Open + ds.High + ds.Low + ds.Close) / 4d;

            //TODO fill with 0 in the loop
            var _haOpen = new TimeSeries(DateTimes);
            var _haC    = new TimeSeries(DateTimes);

            _haOpen[0] = _avg[0];
            _haC[0]    = _avg[0];

            for (int bar = 1; bar < ds.Count; bar++)
            {
                _haOpen[bar] = (_avg[bar - 1] + _haOpen[bar - 1]) / 2d;
                _haC[bar]    = (_avg[bar] + _haOpen[bar]
                                + Math.Max(ds.High[bar], _haOpen[bar])
                                + Math.Min(ds.Low[bar], _haOpen[bar])) / 4d;
            }

            var TMA1 = new TEMA_TASC(_haC, periodSmooth);
            var TMA2 = new TEMA_TASC(TMA1, periodSmooth);
            var Diff = TMA1 - TMA2;
            var ZLHA = TMA1 + Diff;

            var temaZLHA = new TEMA_TASC(ZLHA, periodSmooth);
            var _sd      = new StdDev(temaZLHA, period);
            var _wma     = new WMA(temaZLHA, period);

            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                Values[bar] = 100 * (temaZLHA[bar] + 2 * _sd[bar] - _wma[bar]) / (4 * _sd[bar]);
            }
        }
        //for code based construction
        public BollingerPctBSmoothed(BarHistory source, Int32 periodPctB, Int32 periodSmooth)
            : base()
        {
            Parameters[0].Value = source;
            Parameters[1].Value = periodPctB;
            Parameters[2].Value = periodSmooth;

            Populate();
        }
예제 #9
0
        //for code based construction
        public SVEHaTypCross(BarHistory bars, Int32 haPeriod, Int32 typPeriod)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = haPeriod;
            Parameters[2].Value = typPeriod;

            Populate();
        }
예제 #10
0
 //for code based construction
 public HiLoLimit(BarHistory source, int period, double level, double minrange)
     : base()
 {
     Parameters[0].Value = source;
     Parameters[1].Value = period;
     Parameters[2].Value = level;
     Parameters[3].Value = minrange;
     Populate();
 }
예제 #11
0
        //for code based construction
        public SVAPO(BarHistory bars, Int32 period, Double cutoff)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = period;
            Parameters[2].Value = cutoff;

            Populate();
        }
예제 #12
0
        //for code based construction
        public RWIHigh(BarHistory bars, Int32 minPeriod, Int32 maxPeriod)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = minPeriod;
            Parameters[2].Value = maxPeriod;

            Populate();
        }
예제 #13
0
        //for code based construction
        public SVERBStochK(BarHistory bars, Int32 stochPeriod, Int32 smoothPeriod)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = stochPeriod;
            Parameters[2].Value = smoothPeriod;

            Populate();
        }
예제 #14
0
        //for code based construction
        public MidasLower(BarHistory source, Int32 startBar, int barsToSwingLow)
            : base()
        {
            Parameters[0].Value = source;
            Parameters[1].Value = startBar;
            Parameters[2].Value = barsToSwingLow;

            Populate();
        }
예제 #15
0
        //for code based construction
        public SVEZLRBPercB(BarHistory bars, Int32 smooth, Int32 sdPeriod)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = smooth;
            Parameters[2].Value = sdPeriod;

            Populate();
        }
예제 #16
0
        public override void Populate()
        {
            BarHistory ds        = Parameters[0].AsBarHistory;
            Int32      minperiod = Parameters[1].AsInt;
            Int32      maxperiod = Parameters[2].AsInt;

            DateTimes = ds.DateTimes;
            var period = Math.Max(minperiod, maxperiod);

            if (period <= 0 || DateTimes.Count == 0)
            {
                return;
            }

            //Avoid exception errors
            if (minperiod < 2 || minperiod > ds.Count + 1)
            {
                minperiod = ds.Count + 1;
            }
            if (maxperiod < minperiod || maxperiod > ds.Count + 1)
            {
                maxperiod = ds.Count + 1;
            }

            //Assign first bar that contains indicator data
            var FirstValidValue = maxperiod;

            if (FirstValidValue > ds.Count)
            {
                FirstValidValue = ds.Count;
            }

            //Initialize start of series with zeroes
            //for (int bar = 0; bar < FirstValidValue; bar++)
            //    Values[bar] = 0;

            //Rest of series
            for (int bar = FirstValidValue; bar < ds.Count; bar++)
            {
                double SumTR = 0;
                for (int per = 1; per < minperiod; per++)
                {
                    SumTR += TR.Calculate(bar - per + 1, ds);
                }
                double Value = 0;
                for (int per = minperiod; per <= maxperiod; per++)
                {
                    SumTR += TR.Calculate(bar - per + 1, ds);
                    if (SumTR > 0)
                    {
                        Value = Math.Max(Value, (ds.High[bar] - ds.Low[bar - per + 1]) * Math.Sqrt(per) / SumTR);
                    }
                }
                Values[bar] = Value;
            }
        }
예제 #17
0
        //for code based construction
        public VFI(BarHistory bars, BarHistory x, BarHistory y, Int32 period)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = x;
            Parameters[2].Value = y;
            Parameters[3].Value = period;

            Populate();
        }
예제 #18
0
        //for code based construction
        public MHLMA(BarHistory source, Int32 periodHigh, Int32 periodMA, WhichMA choice)
            : base()
        {
            Parameters[0].Value = source;
            Parameters[1].Value = periodHigh;
            Parameters[2].Value = periodMA;
            Parameters[3].Value = choice;

            Populate();
        }
예제 #19
0
 //for code based construction
 public SVSI(BarHistory bars, Int32 svsiPeriod, Int32 wmaPeriod)
     : base()
 {
     Parameters[0].Value = bars;
     Parameters[1].Value = svsiPeriod;
     Parameters[2].Value = wmaPeriod;
     OverboughtLevel     = 80;
     OversoldLevel       = 20;
     Populate();
 }
예제 #20
0
        //for code based construction
        public VMACDH(BarHistory bars, Int32 shortPeriod, Int32 longPeriod, Int32 signalPeriod)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = shortPeriod;
            Parameters[2].Value = longPeriod;
            Parameters[3].Value = signalPeriod;

            Populate();
        }
예제 #21
0
        //for code based construction
        public STMACD(BarHistory bars, Int32 period, Int32 emaPeriod1, Int32 emaPeriod2)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = period;
            Parameters[2].Value = emaPeriod1;
            Parameters[3].Value = emaPeriod2;

            Populate();
        }
예제 #22
0
 //for code based construction
 public Stress(BarHistory bars, BarHistory index, Int32 period)
     : base()
 {
     Parameters[0].Value = bars;
     Parameters[1].Value = index;
     Parameters[2].Value = period;
     OverboughtLevel     = 10;
     OversoldLevel       = 90;
     Populate();
 }
예제 #23
0
        //for code based construction
        public HACOLT(BarHistory source, Int32 period, Double factor, Int32 timeout, Int32 average)
            : base()
        {
            Parameters[0].Value = source;
            Parameters[1].Value = period;
            Parameters[2].Value = factor;
            Parameters[3].Value = timeout;
            Parameters[4].Value = average;

            Populate();
        }
예제 #24
0
        //for code based construction
        public SVESmoothedVolatilityBandUpper(BarHistory bars, int bandAverage, int volSumPeriod, double devFactor, double lowBandAdj)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = bandAverage;
            Parameters[2].Value = volSumPeriod;
            Parameters[3].Value = devFactor;
            Parameters[4].Value = lowBandAdj;

            Populate();
        }
예제 #25
0
        //for code based construction
        public SVEHLZZperc(BarHistory bars, double change, int period, double factor, SVEHLZZperc_Type type)
            : base()
        {
            Parameters[0].Value = bars;
            Parameters[1].Value = change;
            Parameters[2].Value = period;
            Parameters[3].Value = factor;
            Parameters[4].Value = type;

            Populate();
        }
예제 #26
0
        //===========================================================================================================
        // Monthly  Chart
        //-----------------------------------------------------------------------------------------------------------
        protected void monthlyChart(BarHistory bars)
        {
            // Simple Moving Averages
            PlotTimeSeriesLine(SMA.Series(bars.Close, 12), "SMA12", "Price", Color.Red, 1);
            PlotTimeSeriesLine(SMA.Series(bars.Close, 60), "SMA60", "Price", Color.Black, 1);

            //PricePane.LogScale = true;
            //VolumePane.LogScale = true;

            //show52WeeksHigh(12);
        }
예제 #27
0
        //populate
        public override void Populate()
        {
            BarHistory source   = Parameters[0].AsBarHistory;
            Int32      period   = Parameters[1].AsInt;
            Double     level    = Parameters[2].AsDouble;
            Double     minrange = Parameters[3].AsDouble;

            DateTimes = source.DateTimes;

            if (period > DateTimes.Count)
            {
                period = DateTimes.Count;
            }
            if (DateTimes.Count < period || period <= 0)
            {
                return;
            }

            var HiLoRange = Highest.Series(source.High, period) - Lowest.Series(source.Low, period);

            for (int n = 0; n < period; n++)
            {
                Values[n] = 0;
            }

            for (int bar = period; bar < source.Count; bar++)
            {
                double result = 0.0;

                double ls = Lowest.Series(source.Low, period)[bar];

                if (minrange == 0.0)
                {
                    result = ls + (HiLoRange[bar] * (level / 100));
                }
                else
                {
                    double l      = ls;
                    double range  = HiLoRange[bar];
                    double mid    = l + range / 2;
                    double mrange = l * minrange / 100.0;

                    if (range < mrange)
                    {
                        range = mrange;
                    }

                    result = mid + (level / 100.0 - 0.5) * range;
                }

                Values[bar] = result;
            }
        }
예제 #28
0
        //===========================================================================================================
        // Show Woo
        //-----------------------------------------------------------------------------------------------------------
        protected void showWoo(BarHistory bars, string wooFile)
        {
            Dictionary <int, string> markers = new Dictionary <int, string>();
            string prevWoo = "";

            string[] lines = System.IO.File.ReadAllLines(wooFile);
            foreach (string line in lines)
            {
                // 3/14/17,WOO
                // 4/14/17,
                // 7/6/17,Correction
                string[] columns = line.Split(',');
                if (columns.Length < 2)
                {
                    continue;
                }
                var dateStr = columns[0].Trim();
                var woo     = columns[1].Trim();
                if (woo == "")
                {
                    continue;
                }
                // If woo is not changing, then don't do anything
                if (woo == prevWoo)
                {
                    continue;
                }
                // There is woo change, so try to get bar and save in the map
                DateTime d      = DateTime.Parse(dateStr);
                int      wooBar = bars.IndexOf(d, true);
                if (wooBar < 0)
                {
                    continue;
                }
                markers[wooBar] = woo;
                prevWoo         = woo;
            }

            foreach (KeyValuePair <int, string> entry in markers)
            {
                string woo = entry.Value;
                int    idx = entry.Key;
                if (woo == "WOO")
                {
                    DrawBarAnnotation("▲", entry.Key, false, Color.FromArgb(160, 0, 255, 0), 14, true);
                }
                else
                {
                    DrawBarAnnotation("▲", entry.Key, false, Color.FromArgb(160, 255, 0, 0), 14, true);
                }
            }
            DrawHeaderText("▲ - WOO");
        }
예제 #29
0
 //===========================================================================================================
 // Show 52 weeks high
 //-----------------------------------------------------------------------------------------------------------
 protected void show52WeeksHigh(BarHistory bars, int numBarsIn52Weeks)
 {
     // 52-week high
     for (int bar = numBarsIn52Weeks; bar < bars.Count; bar++)
     {
         if (bars.High[bar] > Highest.Series(bars.High, numBarsIn52Weeks)[bar - 1])
         {
             // New 52-week high detected.  Paint the chart blue
             SetBackgroundColor(bars, bar, Color.FromArgb(15, Color.Blue));
         }
     }
 }
예제 #30
0
        protected void addTradeAnnotation(BarHistory bars, int bar, string text, int lines, int sideClearance)
        {
            int emptySlot = -1;
            int startBar  = bar - sideClearance;
            int endBar    = bar + sideClearance;

            if (startBar < 0)
            {
                startBar = 0;
            }
            if (endBar > bars.Count - 1)
            {
                endBar = bars.Count - 1;
            }
            HashSet <int> slotsOccupied = new HashSet <int>();

            for (int i = startBar; i <= endBar; i++)
            {
                if (!slotReservedMap.ContainsKey(i))
                {
                    continue;
                }
                List <Slot> slotReserved = slotReservedMap[i];
                foreach (Slot slot in slotReserved)
                {
                    slotsOccupied.Add(slot.n);
                }
            }
            for (int i = 0; i < 100; i++)
            {
                if (!slotsOccupied.Contains(i))
                {
                    emptySlot = i;
                    break;
                }
            }
            if (emptySlot != -1)
            {
                Slot        newSlot = new Slot(emptySlot, text);
                List <Slot> slotReserved;
                if (slotReservedMap.ContainsKey(bar))
                {
                    slotReserved = slotReservedMap[bar];
                }
                else
                {
                    slotReserved = new List <Slot>();
                }
                slotReserved.Add(newSlot);
                slotReservedMap[bar] = slotReserved;
            }
        }