public BasicDMIRule(DataBars db,double minusperiod,double plusperiod) { minusDmi = new Indicators.MinusDI(db, minusperiod, "minusDmi"); plusDmi = new Indicators.PlusDI(db, plusperiod, "plusDmi"); adx = new Indicators.ADX(db, minusperiod, "adx"); emaadx = Indicators.EMA.Series(adx, 5, "emaadx"); }
/// <summary> /// Calculation of Average True Range indicators /// </summary> /// <param name="ds">data to calculate HT_PHASOR</param> /// <param name="period">the period</param> /// <param name="name"></param> public HT_PHASOR(DataBars ds, string name) : base(ds, name) { int begin = 0, length = 0; Core.RetCode retCode = Core.RetCode.UnknownErr; double[] output = new double[ds.Count]; double[] quadrature = new double[ds.Count]; retCode = Core.HtPhasor(0, ds.Count - 1, ds.High.Values, out begin, out length, output, quadrature); if (retCode != Core.RetCode.Success) return; //Assign first bar that contains indicator data DataSeries quadratureSeries= new DataSeries(ds, name + "-quadrature"); if (length <= 0) FirstValidValue = begin + output.Length + 1; else FirstValidValue = begin; quadratureSeries.FirstValidValue = FirstValidValue; this.Name = name; for (int i = begin, j = 0; j < length; i++, j++) { quadratureSeries.Values[i] = quadrature[j]; this[i] = output[j]; } this.Cache.Add(quadratureSeries.Name, quadratureSeries); }
/// <summary> /// Calculation of Aroon indicators /// </summary> /// <param name="db">data to calculate Aroon</param> /// <param name="period">period to calculate</param> /// <param name="name"></param> public Aroon(DataBars db, double period, string name) : base(db, name) { int begin = 0, length = 0; Core.RetCode retCode = Core.RetCode.UnknownErr; double[] outputDown = new double[db.Count]; double[] outputUp = new double[db.Count]; retCode = Core.Aroon(0, db.Count - 1, db.High.Values, db.Low.Values, (int)period, out begin, out length, outputDown, outputUp); if (retCode != Core.RetCode.Success) return; //Assign first bar that contains indicator data if (length <= 0) FirstValidValue = begin + outputDown.Length + 1; else FirstValidValue = begin; this.Name = name; DataSeries upValue = new DataSeries(db, name + "-aroon up"); upValue.FirstValidValue = FirstValidValue; for (int i = begin, j = 0; j < length; i++, j++) { this[i] = outputDown[j]; upValue.Values[i] = outputUp[j]; } this.Cache.Add(upValue.Name,upValue); }
public KELTNER(DataBars ds, double EmaPeriod, double AtrMult, double AtrPeriod, string name) : base(ds, name) { this.Name = name; int begin = 0; DataSeries ema = EMA.Series(ds.Close, EmaPeriod, "ema"); DataSeries atr = ATR.Series(ds, AtrPeriod, "atr"); //DataSeries upperSeries = new DataSeries(ds, name + "-upper"); DataSeries upperSeries = ema + AtrMult * atr; upperSeries.Name = name + "-upper"; // DataSeries lowerSeries = new DataSeries(ds, name + "-lower"); DataSeries lowerSeries = ema - AtrMult * atr; lowerSeries.Name = name + "-lower"; FirstValidValue = Math.Max(ema.FirstValidValue, upperSeries.FirstValidValue); this.Name = name; upperSeries.FirstValidValue = FirstValidValue; lowerSeries.FirstValidValue = FirstValidValue; for (int i = begin, j = 0; j < ema.Count; i++, j++) { this[i] = ema[j]; } //Cache series this.Cache.Add(upperSeries.Name,upperSeries); this.Cache.Add(lowerSeries.Name,lowerSeries); }
public static DataBars GetData(databases.baseDS.priceDataDataTable dataTbl, int startIdx) { DataBars bars = new DataBars(); for (int idx = startIdx; idx < dataTbl.Count; idx++) { bars.Add((double)dataTbl[idx].openPrice, (double)dataTbl[idx].highPrice, (double)dataTbl[idx].lowPrice, (double)dataTbl[idx].closePrice, (double)dataTbl[idx].volume, dataTbl[idx].onDate.ToOADate()); } return bars; }
public static Fibonnanci Series(DataBars ds, double period, string name) { //Build description string description = "(" + name + "," + period.ToString() + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (Fibonnanci)obj; Fibonnanci indicator = new Fibonnanci(ds, period, description); ds.Cache.Add(description, indicator); return indicator; }
public static KELTNER Series(DataBars ds, double EmaPeriod, double AtrMult, double AtrPeriod, string name) { //Build description string description = "(" + name + "," + EmaPeriod.ToString() + "," + AtrMult.ToString() + "," + AtrPeriod.ToString() + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (KELTNER)obj; KELTNER indicator = new KELTNER(ds, EmaPeriod, AtrMult, AtrPeriod, description); ds.Cache.Add(description,indicator); return indicator; }
/// <summary> /// Static method to create Doji DataSeries /// </summary> /// <param name="ds"></param> /// <param name="period"></param> /// <param name="name"></param> /// <returns></returns> public static CDLDoji Series(DataBars ds, string name) { //Build description string description = "(" + name + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (CDLDoji)obj; //Create Doji, cache it, return it CDLDoji doji = new CDLDoji(ds, description); ds.Cache.Add(description, doji); return doji; }
/// <summary> /// Static method to create AD DataSeries /// </summary> /// <param name="ds"></param> /// <param name="period"></param> /// <param name="name"></param> /// <returns></returns> public static AD Series(DataBars ds, string name) { //Build description string description = "(" + name + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (AD)obj; //Create AD, cache it, return it AD ad = new AD(ds, description); ds.Cache.Add(description, ad); return ad; }
/// <summary> /// Static method to create HT_PHASOR DataSeries /// </summary> /// <param name="ds"></param> /// <param name="period"></param> /// <param name="name"></param> /// <returns></returns> public static HT_PHASOR Series(DataBars ds, string name) { //Build description string description = "(" + name + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (HT_PHASOR)obj; //Create indicator, cache it, return it HT_PHASOR indicator = new HT_PHASOR(ds, description); ds.Cache.Add(description, indicator); return indicator; }
public HybridTestRules(DataBars db, double atrperiod, double shortperiod, double longperiod) { rules = new Rule[3]; rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod); rules[1] = new BasicATRRule(db, atrperiod, "atr"); rules[2] = new BasicMACDRule(db.Close, 12, 26, 9); adxTrend = new ADXMarketTrend(db, 14); //Kiem tra volume volumeRule = new PriceTwoSMARule(db.Volume, 10, 30); data = db; Volume_Filter = 50000; }
/// <summary> /// Static method to create SAR DataSeries /// </summary> /// <param name="ds"></param> /// <param name="period"></param> /// <param name="name"></param> /// <returns></returns> public static SAR Series(DataBars ds, double optInAcceleration, double optLnMaximum, string name) { //Build description string description = "(" + name + "," + optInAcceleration.ToString() + "," + optLnMaximum.ToString() + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (SAR)obj; //Create indicator, cache it, return it SAR indicator = new SAR(ds, optInAcceleration,optLnMaximum, description); ds.Cache.Add(description, indicator); return indicator; }
/// <summary> /// Static method to create Arron DataSeries /// </summary> /// <param name="ds"></param> /// <param name="period"></param> /// <param name="name"></param> /// <returns></returns> public static CCI Series(DataBars ds, double period, string name) { //Build description string description = "(" + name + "," + period.ToString() + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (CCI)obj; //Create CCI, cache it, return it CCI cci = new CCI(ds, period, description); ds.Cache.Add(description, cci); return cci; }
/// <summary> /// Static method to create WILLR DataSeries /// </summary> /// <param name="ds"></param> /// <param name="period"></param> /// <param name="name"></param> /// <returns></returns> public static WILLR Series(DataBars ds, double period, string name) { //Build description string description = "(" + name + period.ToString() + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (WILLR)obj; //Create indicator, cache it, return it WILLR indicator = new WILLR(ds, period, description); ds.Cache.Add(description, indicator); return indicator; }
/// <summary> /// Static method to create Arron DataSeries /// </summary> /// <param name="ds"></param> /// <param name="period"></param> /// <param name="name"></param> /// <returns></returns> public static Aroon Series(DataBars ds, double period, string name) { //Build description string description = "(" + name + "," + period.ToString() + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (Aroon)obj; //Create Aroon, cache it, return it Aroon aroon = new Aroon(ds, period, description); ds.Cache.Add(description, aroon); return aroon; }
public Fibonnanci(DataBars ds, double period, string name) : base(ds, name) { this.Name = name; //138.2%, 161.8%, 200% and 261.8% DataSeries min = Indicators.MIN.Series(ds.Low, period, "min"); DataSeries fibo100 = Indicators.MAX.Series(ds.High, period, "max"); DataSeries fibo23pc = new DataSeries(min, "fibo 23pc"); DataSeries fibo38pc = new DataSeries(min, "fibo 38pc"); DataSeries fibo50pc = new DataSeries(min, "fibo 50pc"); DataSeries fibo62pc = new DataSeries(min, "fibo 62pc"); DataSeries fibo138pc = new DataSeries(min, "fibo 138pc"); fibo23pc.Name = name + "-fibo 23pc"; fibo38pc.Name = name + "-fibo 38pc"; fibo50pc.Name = name + "-fibo 50pc"; fibo62pc.Name = name + "-fibo 62pc"; fibo138pc.Name = name + "-fibo 138pc"; fibo100.Name = name + "-fibo100"; FirstValidValue = (int)Math.Max(0,min.Count-period-1);; fibo100.FirstValidValue=FirstValidValue; fibo23pc.FirstValidValue = FirstValidValue; fibo38pc.FirstValidValue=FirstValidValue; fibo50pc.FirstValidValue = FirstValidValue; fibo62pc.FirstValidValue = FirstValidValue; fibo138pc.FirstValidValue = FirstValidValue; this.Name = name; for (int i = FirstValidValue; i < min.Count; i++) { this[i] = min[min.Count - 1]; fibo100[i] = fibo100[fibo100.Count - 1]; fibo23pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1]) * 23.6 / 100; fibo38pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1])*38.2/100; fibo50pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1]) * 50 / 100; fibo62pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1]) * 61.8 / 100; fibo138pc[i] = min[min.Count - 1] + (fibo100[fibo100.Count - 1] - min[min.Count - 1]) * 138.2 / 100; } this.Cache.Add(fibo100.Name, fibo100); this.Cache.Add(fibo23pc.Name, fibo38pc); this.Cache.Add(fibo38pc.Name, fibo38pc); this.Cache.Add(fibo50pc.Name, fibo50pc); this.Cache.Add(fibo62pc.Name, fibo62pc); this.Cache.Add(fibo138pc.Name, fibo138pc); }
/// <summary> /// Calculation of Balance of Power indicators /// </summary> /// <param name="db">data to calculate Bop</param> /// <param name="name"></param> public Bop(DataBars db, string name): base(db, name) { int begin = 0, length = 0; Core.RetCode retCode = Core.RetCode.UnknownErr; double[] output = new double[db.Count]; retCode = Core.Bop(0, db.Count - 1, db.Open.Values,db.High.Values, db.Low.Values, db.Close.Values, out begin, out length, output); if (retCode != Core.RetCode.Success) return; //Assign first bar that contains indicator data if (length <= 0) FirstValidValue = begin + output.Length + 1; else FirstValidValue = begin; this.Name = name; for (int i = begin, j = 0; j < length; i++, j++) this[i] = output[j]; }
public DataBars(DataBars ds, string _name) { Open = new DataSeries(ds.Open, _name); High = new DataSeries(ds.High, _name); Low = new DataSeries(ds.Low, _name); Close = new DataSeries(ds.Close, _name); Volume = new DataSeries(ds.Volume, _name); }
public static DataBars operator <<(DataBars ds, int n) { DataBars retVal = new DataBars(); retVal.Open = ds.Open << n; retVal.High = ds.High << n; retVal.Low = ds.Low << n; retVal.Close = ds.Close << n; retVal.Volume = ds.Volume << n; retVal.DateTime = ds.DateTime << n; return retVal; }
public SMAATRRules(DataBars db, double atrperiod, double shortperiod, double longperiod) { rules = new Rule[2]; rules[0] = new TwoSMARule(db.Close, shortperiod, longperiod); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }
public static DataBars operator -(DataBars d1, DataBars d2) { DataBars retVal = new DataBars(); retVal.Open = d1.Open - d2.Open; retVal.High = d1.High - d2.High; retVal.Low = d1.Low - d2.Low; retVal.Close = d1.Close - d2.Close; retVal.Volume = d1.Volume - d2.Volume; return retVal; }
public SARATRRules(DataBars db, double atrperiod, double optInAcc,double optLnMax) { rules = new Rule[2]; rules[0] = new BasicSARRule(db, optInAcc, optLnMax); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }
public MACDHistATRRules(DataBars db, double atrperiod, double fast, double slow,double signal) { rules = new Rule[2]; rules[0] = new MACD_HistogramRule(db.Close, fast, slow,signal); rules[1] = new BasicATRRule(db, atrperiod, "atr"); }
public static DataBars operator /(DataBars bar, int d) { if (d == 0) return bar; DataBars retVal = new DataBars(); retVal.Open = bar.Open / d; retVal.High = bar.High / d; retVal.Low = bar.Low / d; retVal.Close = bar.Close / d; retVal.Volume = bar.Volume / d; return retVal; }
/// <summary> /// Static method to create ADOSC DataSeries /// </summary> /// <param name="ds"></param> /// <param name="fastPeriod"></param> /// <param name="slowPeriod"></param> /// <param name="name"></param> /// <returns></returns> public static ADOSC Series(DataBars ds, double fastPeriod, double slowPeriod, string name) { //Build description string description = "(" + name + "," + fastPeriod.ToString() + "," + slowPeriod.ToString() + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (ADOSC)obj; //Create ADOSC, cache it, return it ADOSC adosc = new ADOSC(ds, fastPeriod, slowPeriod, description); ds.Cache.Add(description, adosc); return adosc; }
/// <summary> /// Calculation of Chaikin A/D Oscillator indicators /// </summary> /// <param name="db">data to calculate AD</param> /// <param name="name"></param> public ADOSC(DataBars db, double fastPeriod, double slowPeriod, string name) : base(db, name) { int begin = 0, length = 0; Core.RetCode retCode = Core.RetCode.UnknownErr; double[] output = new double[db.Count]; retCode = Core.AdOsc(0, db.Count - 1, db.High.Values, db.Low.Values, db.Close.Values, db.Volume.Values, (int)fastPeriod, (int)slowPeriod, out begin, out length, output); if (retCode != Core.RetCode.Success) return; //Assign first bar that contains indicator data FirstValidValue = begin; this.Name = name; for (int i = begin, j = 0; j < length; i++, j++) this[i] = output[j]; }
public static CDLBELTHOLD Series(DataBars ds, string name) { //Build description string description = "(" + name + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (CDLBELTHOLD)obj; //Create Doji, cache it, return it CDLBELTHOLD indicator = new CDLBELTHOLD(ds, description); ds.Cache.Add(description, indicator); return indicator; }
public CDLABANDONEDBABY(DataBars db,double optInPenetration, string name) : base(db, name) { int begin = 0, length = 0; Core.RetCode retCode = Core.RetCode.UnknownErr; int[] output = new int[db.Count]; retCode = Core.CdlAbandonedBaby(0, db.Count - 1, db.Open.Values, db.High.Values, db.Low.Values, db.Close.Values,optInPenetration, out begin, out length, output); if (retCode != Core.RetCode.Success) return; //Assign first bar that contains indicator data if (length <= 0) FirstValidValue = begin + output.Length + 1; else FirstValidValue = begin; this.Name = name; for (int i = begin, j = 0; j < length; i++, j++) this[i] = output[j]; }
public static CDLABANDONEDBABY Series(DataBars ds,double optInPenetration, string name) { //Build description string description = "(" + name + ")"; //See if it exists in the cache object obj = ds.Cache.Find(description); if (obj != null) return (CDLABANDONEDBABY)obj; //Create Doji, cache it, return it CDLABANDONEDBABY indicator = new CDLABANDONEDBABY(ds,optInPenetration, description); ds.Cache.Add(description, indicator); return indicator; }
public static DataBars operator >>(DataBars ds, int n) { DataBars retVal = new DataBars(); retVal.Open = ds.Open >> n; retVal.High = ds.High >> n; retVal.Low = ds.Low >> n; retVal.Close = ds.Close >> n; retVal.Volume = ds.Volume >> n; retVal.DateTime = ds.DateTime >> n; return retVal; }