Exemple #1
0
        public PivotLevels(Bars bars, PivotType type, string description)
            : base(bars, description)
        {
            DataSeries Pivot    = new DataSeries(bars, "Daily Pivot Level");
            DataSeries DayHigh  = new DataSeries(bars, "Previous Day's High Level");
            DataSeries DayClose = new DataSeries(bars, "Previous Day's Close Level");
            DataSeries DayLow   = new DataSeries(bars, "Previous Day's Low Level");
            DataSeries R1       = new DataSeries(bars, "Resistance Pivot Level 1");
            DataSeries S1       = new DataSeries(bars, "Support Pivot Level 1");
            DataSeries R2       = new DataSeries(bars, "Resistance Pivot Level 2");
            DataSeries S2       = new DataSeries(bars, "Support Pivot Level 2");
            DataSeries R3       = new DataSeries(bars, "Resistance Pivot Level 3");
            DataSeries S3       = new DataSeries(bars, "Support Pivot Level 3");
            DataSeries result   = new DataSeries(bars, "Result");

            base.FirstValidValue = 1;

            if (!bars.IsIntraday)   // Daily data
            {
                //base.FirstValidValue = bars.FirstActualBar;

                Pivot    = AveragePriceC.Series(bars);
                DayHigh  = bars.High;
                DayClose = bars.Close;
                DayLow   = bars.Low;

                CalcPivotLevel(type, Pivot, DayHigh, DayLow, ref R1, ref S1, ref R2, ref S2, ref R3, ref S3, ref result);
            }
            else    // Special logic for intraday data
            {
                try
                {
                    Bars eodBars = BarScaleConverter.ToDaily(bars);
                    Pivot    = AveragePriceC.Series(eodBars);
                    DayHigh  = eodBars.High;
                    DayClose = eodBars.Close;
                    DayLow   = eodBars.Low;

                    R1 = BarScaleConverter.Synchronize(R1, eodBars);
                    S1 = BarScaleConverter.Synchronize(S1, eodBars);
                    R2 = BarScaleConverter.Synchronize(R2, eodBars);
                    S2 = BarScaleConverter.Synchronize(S2, eodBars);
                    R3 = BarScaleConverter.Synchronize(R3, eodBars);
                    S3 = BarScaleConverter.Synchronize(S3, eodBars);

                    CalcPivotLevel(type, Pivot, DayHigh, DayLow, ref R1, ref S1, ref R2, ref S2, ref R3, ref S3, ref result);
                    result = BarScaleConverter.Synchronize(result, bars);
                }
                catch (Exception)
                {
                    throw;
                }
            }

            for (int bar = FirstValidValue; bar < bars.Count; bar++)
            {
                base[bar] = result[bar];
            }
        }
        public ExternalSymbol(Bars source, string dataSet, string extSym, DataSeries ds, string description)
            : base(ds, description)
        {
            base.FirstValidValue = 0;

            Bars b = new Bars(extSym, ds.DataScale.Scale, ds.DataScale.BarInterval);

            try
            {
                b = MainModuleInstance.LoadExternalSymbol(dataSet, extSym);
                b = BarScaleConverter.Synchronize(b, source);
                for (int bar = FirstValidValue; bar < b.Count; bar++)
                {
                    if (ds.Description == "Open")
                    {
                        base[bar] = b.Open[bar];
                    }
                    else
                    if (ds.Description == "High")
                    {
                        base[bar] = b.High[bar];
                    }
                    else
                    if (ds.Description == "Low")
                    {
                        base[bar] = b.Low[bar];
                    }
                    else
                    {
                        base[bar] = b.Close[bar];
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }