public Revenue(int type) { this.type = type; b = new BollingerBands(20, 2); ema = new EMA(5, 60); sma = new double[b.MidPeriod]; trend_width = new List <double>(32768); short_ema = new List <double>(32768); long_ema = new List <double>(32768); shortDay = new List <double>(512); longDay = new List <double>(512); Send += Analysis; foreach (string rd in new Daily(type)) { arr = rd.Split(','); if (arr[1].Contains("-")) { arr[1] = arr[1].Substring(1); } Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]))); } foreach (string rd in new Tick(type)) { arr = rd.Split(','); if (arr[1].Contains("-")) { arr[1] = arr[1].Substring(1); } Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]), int.Parse(arr[2]))); } Send -= Analysis; arr = SetSecret(type).Split('^'); Secret = int.Parse(arr[0]); Tick = int.Parse(arr[1]); api = Futures.Get(); api.Send += Analysis; }
public SubtleSwing(int reaction, int type) { this.type = type; info = new Information(type); b = new BollingerBands(20, 2); ema = new EMA(5, 60); sma = new double[b.MidPeriod]; open = new double[3]; trend_width = new List <double>(32768); short_ema = new List <double>(32768); long_ema = new List <double>(32768); shortDay = new List <double>(512); longDay = new List <double>(512); act = new Action(() => info.Log(reaction)); Send += Analysis; foreach (string rd in new Daily(type)) { arr = rd.Split(','); if (arr[1].Contains("-")) { arr[1] = arr[1].Substring(1); } Send?.Invoke(this, new Datum(reaction, arr[0], double.Parse(arr[1]))); } foreach (string rd in new Tick(type)) { arr = rd.Split(','); if (arr[1].Contains("-")) { arr[1] = arr[1].Substring(1); } Send?.Invoke(this, new Datum(reaction, arr[0], double.Parse(arr[1]), int.Parse(arr[2]))); } act.BeginInvoke(act.EndInvoke, null); }
public Statistics() { b = new BollingerBands(20, 2); ema = new EMA(5, 60); sma = new double[b.MidPeriod]; trend_width = new List <double>(32768); short_ema = new List <double>(32768); long_ema = new List <double>(32768); shortDay = new List <double>(512); longDay = new List <double>(512); Send += Analysis; foreach (string rd in new Daily()) { string[] arr = rd.Split(','); if (arr[1].Contains("-")) { arr[1] = arr[1].Substring(1); } Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]))); } foreach (string rd in new Tick()) { string[] arr = rd.Split(','); if (arr[1].Contains("-")) { arr[1] = arr[1].Substring(1); } Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]), int.Parse(arr[2]))); } Send -= Analysis; api = Futures.Get(); api.Send += Analysis; }
public Scalping(int type, int se, int le) { this.type = type; ema = new EMA(se, le); short_ema = new List <double>(32768); long_ema = new List <double>(32768); Send += Analysis; foreach (string rd in new Daily(type)) { arr = rd.Split(','); if (arr[1].Contains("-")) { arr[1] = arr[1].Substring(1); } Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]))); } foreach (string rd in new Tick(type)) { arr = rd.Split(','); if (arr[1].Contains("-")) { arr[1] = arr[1].Substring(1); } Send?.Invoke(this, new Datum(arr[0], double.Parse(arr[1]), int.Parse(arr[2]))); } Send -= Analysis; arr = SetSecret(type).Split('^'); Secret = int.Parse(arr[0]); api = Futures.Get(); api.Send += Analysis; }
void OnReceiveDrawChart(object sender, SendConsecutive e) { int tShort, tLong, tMinute, trend; switch (strategics) { case TrendsInValuation _: tShort = tv.Short; tLong = tv.Long; trend = tv.Trend; if (GetCheckOnDate(e.Date, 0x5A0)) { Short.Pop(); Long.Pop(); Trend.Pop(); } Trend.Push(Trend.Count > 0 ? EMA.Make(trend, Trend.Count, e.Price, Trend.Peek()) : EMA.Make(e.Price)); tMinute = tv.AddtionalInterval; break; case TrendToCashflow _: tShort = tc.Short; tLong = tc.Long; trend = tc.Trend; if (GetCheckOnDate(e.Date, 0x5A0)) { Short.Pop(); Long.Pop(); Trend.Pop(); } Trend.Push(Trend.Count > 0 ? EMA.Make(trend, Trend.Count, e.Price, Trend.Peek()) : EMA.Make(e.Price)); tMinute = tc.Interval; break; case TrendsInStockPrices _: tShort = ts.Short; tLong = ts.Long; trend = ts.Trend; switch (ts) { case TrendsInStockPrices sp when sp.LongShort.Equals(LongShort.Minute) && sp.TrendType.Equals(Interface.Trend.Minute) || sp.LongShort.Equals(LongShort.Day) && sp.TrendType.Equals(Interface.Trend.Day): if (GetCheckOnDate(e.Date, sp.LongShort.Equals(LongShort.Minute) && sp.TrendType.Equals(Interface.Trend.Minute) ? 1 : 0x5A0)) { Short.Pop(); Long.Pop(); Trend.Pop(); } break; case TrendsInStockPrices sp when sp.LongShort.Equals(LongShort.Day) && sp.TrendType.Equals(Interface.Trend.Minute): if (GetCheckOnDate(e.Date, 1)) Trend.Pop(); if (GetCheckOnDate(e.Date, 0x5A0)) { Short.Pop(); Long.Pop(); } break; case TrendsInStockPrices sp when sp.LongShort.Equals(LongShort.Minute) && sp.TrendType.Equals(Interface.Trend.Day): if (GetCheckOnDate(e.Date, 0x5A0)) Trend.Pop(); if (GetCheckOnDate(e.Date, 1)) { Short.Pop(); Long.Pop(); } break; } Trend.Push(Trend.Count > 0 ? EMA.Make(trend, Trend.Count, e.Price, Trend.Peek()) : EMA.Make(e.Price)); tMinute = (int)ts.TrendType; break; case TrendFollowingBasicFutures _: if (GetCheckOnDate(e.Date, tf.Minute)) { Short.Pop(); Long.Pop(); } tShort = tf.Short; tLong = tf.Long; tMinute = tf.Minute; break; case ScenarioAccordingToTrend _: tShort = st.Short; tLong = st.Long; trend = st.Trend; if (e.Date.Length > 6 && double.IsNaN(Compare) && Trend.Count > 0 && string.IsNullOrEmpty(st.Calendar) == false && (e.Date.Length == 8 ? e.Date.Substring(2) : e.Date.Substring(0, 6)).CompareTo(st.Calendar) >= 0) { Compare = Trend.Pop(); if (int.TryParse(e.Date.Length == 8 ? e.Date.Substring(2, 4) : e.Date.Substring(0, 4), out int closest)) { var baseDate = int.MaxValue; var temp = string.Empty; var list = new List <ConvertConsensus>(ho.Consensus.Item1); list.AddRange(ho.Consensus.Item2); foreach (var parse in list.OrderByDescending(o => o.Date)) { if (int.TryParse(parse.Date.Substring(0, 5).Replace(".", string.Empty), out int date) && Math.Abs(date - closest) < baseDate) { baseDate = Math.Abs(date - closest); temp = parse.Date; } } var estimate = new Security(temp, list, st).EstimateThePrice(e.Date, Compare); if (estimate.Count > 3) { ho.EstimatedPrice = estimate; } else { return; } } Trend.Clear(); } if (GetCheckOnDate(e.Date, 0x5A0)) { Short.Pop(); Long.Pop(); if (double.IsNaN(Compare) && Trend.Count > 0) { Trend.Pop(); } } if (double.IsNaN(Compare)) { Trend.Push(Trend.Count > 0 ? EMA.Make(trend, Trend.Count, e.Price, Trend.Peek()) : EMA.Make(e.Price)); } tMinute = st.IntervalInSeconds; break; default: return; } Short.Push(Short.Count > 0 ? EMA.Make(tShort, Short.Count, e.Price, Short.Peek()) : EMA.Make(e.Price)); Long.Push(Long.Count > 0 ? EMA.Make(tLong, Long.Count, e.Price, Long.Peek()) : EMA.Make(e.Price)); if (e.Volume != 0 && e.Date.Length != 8 && Short.Count > 1 && Long.Count > 1) { double popShort = Short.Pop(), popLong = Long.Pop(), gap = popShort - popLong - (Short.Peek() - Long.Peek()); Short.Push(popShort); Long.Push(popLong); switch (sender) { case OpenAPI.HoldingStocks os: os.OnReceiveTrendsInPrices(e, gap, Trend.Peek()); break; case XingAPI.HoldingStocks xs: xs.OnReceiveTrendsInPrices(e, gap, tMinute); break; case HoldingStocks hs: hs.OnReceiveTrendsInPrices(e, gap, popShort, popLong, hs.Code.Length == 6 ? (Trend.Count > 0 ? Trend.Peek() : CalculateTheEstimatedPrice(e.Date)) : tMinute); break; } } }
private void Analysis(Chart ch) { bool check = false; string time = ch.Date.ToString(); if (specify.Time > 0 && specify.Time < 1440) { check = time.Length > 8 && GetCheckOnTime(time); } else if (specify.Time == 1440) { check = time.Length > 8 && time.Substring(6).Equals("090000000") == false; } if (check) { Short.Pop(); Long.Pop(); } Short.Push(Short.Count > 0 ? EMA.Make(specify.Short, Short.Count, ch.Price, Short.Peek()) : EMA.Make(ch.Price)); Long.Push(Long.Count > 0 ? EMA.Make(specify.Long, Long.Count, ch.Price, Long.Peek()) : EMA.Make(ch.Price)); double popShort = Short.Pop(), popLong = Long.Pop(); var trend = Short.Count > 1 && Long.Count > 1 ? popShort - popLong - (Short.Peek() - Long.Peek()) > 0 ? 1 : -1 : 0; Short.Push(popShort); Long.Push(popLong); }