void Source_Change(ValueRow src, bool isReset) { _bbTop.SuspendEvents(); _bbBottom.SuspendEvents(); if (isReset) { _bbTop.Clear(); _bbBottom.Clear(); } if (_source != null) { int startIndex = isReset ? 0 : _bbTop.Count; for (int i = startIndex; i <= _source.LastIndex; i++) { CalcTop(i); } startIndex = isReset ? 0 : _bbBottom.Count; for (int i = startIndex; i <= _source.LastIndex; i++) { CalcBottom(i); } } _bbTop.ResumeEvents(); _bbBottom.ResumeEvents(); }
private void valueRow_Change(ValueRow valueRow, bool isReset) { if (isReset) { return; // reset мы не обрабатываем, т.е. reset означает очистку массива, а не добавление нового значения } if (valueRow == null || valueRow.LastIndex < 0) { return; // пустой список, добавлять нечего } decimal?val = valueRow[valueRow.LastIndex]; if (val == null) { return; // пустые значения не добавляем } var sers = _series_vrdata.Where(r => r.Value.Item1 == valueRow).Select(r => r.Key).ToList(); foreach (var s in sers) { var tl = _series_vrdata[s].Item2; var funcSp = _series_vrdata[s].Item3; var time = tl.Start(valueRow.LastIndex); if (time == null) { continue; // не смогли определить время } var sp = funcSp?.Invoke(val.Value); AddSeriesValue(s.SeriesID, time.Value, val.Value, sp); } }
public Ama() { _source = null; _n = 10; _fastSmooth = 2m / 3; _slowSmooth = 2m / 31; }
void Sources_Change(ValueRow src, bool isReset) { SuspendEvents(); if (isReset) { Clear(); } if (_source != null) { int startIndex = isReset ? 0 : this.Count; for (int i = startIndex; i <= _source.LastIndex; i++) { if (_am == AverageMethod.Simple) { CalcSimple(i); } else if (_am == AverageMethod.Exponencial) { CalcExponencial(i); } else if (_am == AverageMethod.Wilder) { CalcWilder(i); } } } ResumeEvents(); }
/// <summary> /// Расчет адаптивной средней по smoothRow. /// Значения ряда сглаживания должны лежать в диапазоне [0 .. 1]. /// При нулевом значении новое значение адаптивной средней совпадает со своим предыдущим значением. /// При единичном значении новон значение адаптивной средней совпадает со значением source. /// При значении smoothRow = 0,5 новое значение адаптивной средней будет, соответственно, посередине. /// </summary> /// <param name="source">Источник</param> /// <param name="smoothRow">Ряд сглаживания</param> public Ama(ValueRow source, ValueRow smoothRow) : base() { _source = source; _source.Change += Sources_Change; _smoothRow = smoothRow; _smoothRow.Change += Sources_Change; Sources_Change(null, false); }
public BollingerBands() { _n = 1; _width = 2; _bbMiddle = new Ma(); _stdDev = new StdDev(); _bbTop = new ValueRow(); _bbBottom = new ValueRow(); }
public Macd(ValueRow src, int longPeriod = 26, int shortPeriod = 12, int signalPeriod = 9, AverageMethod method = AverageMethod.Exponencial) { this.Source1 = new Ma(src, method, longPeriod); this.Source2 = new Ma(src, method, shortPeriod); this.CalcMethod = (s1, s2, i) => { return(s2[i] - s1[i]); }; _signal = new Ma(this, method, signalPeriod); _hist = new Calc2(this, _signal, (m, s, i) => { return(m[i] - s[i]); }); }
/// <summary> /// 加入ValueRow /// </summary> /// <returns></returns> public static ValueRow AddValueRowToFixedFooter(this IGrid grid) { ValueRow valueRow = new ValueRow(); valueRow.CanBeCurrent = false; valueRow.CanBeSelected = false; valueRow.BackColor = Color.LightBlue; grid.FixedFooterRows.Add(valueRow); return(valueRow); }
public CurveChart(ValueRow source, ChartBrush brush) { if (source == null) { throw new ArgumentNullException("source"); } this._source = source; _source.Change += _source_Change; this._brush = brush != null ? brush : new ChartBrush(0, 0, 0); }
public Equity(IInsStoreBL insStoreBL, IInstrumBL instrumBL, IAccountDA accountDA) { _instrumBL = instrumBL; _insStoreBL = insStoreBL; _accountDA = accountDA; _cashRow = new ValueRow(); _portfolioRow = new ValueRow(); _equityRow = new ValueRow(); _prices = new Dictionary <int, BarRow>(); }
private void _bars1_ma_Change(ValueRow vr, bool isReset) { if (!isReset && _bars1_ma.LastValue != null) { ma1 = _bars1_ma.LastValue.Value; } else { ma1 = 0; } }
public StdDev(ValueRow source, int n) : this() { _source = source; _n = n < 1 ? 1 : n; if (_source != null) { _source.Change += Source_Change; Source_Change(null, true); } }
/// <summary> /// 得到ValueRow /// </summary> /// <returns></returns> public static ValueRow GetValueRow(this IGrid grid) { foreach (Row row in grid.FixedFooterRows) { ValueRow r = row as ValueRow; if (r != null) { return(r); } } return(null); }
public Ma(ValueRow source, AverageMethod method, int n) { _source = source; _am = method; _n = n < 1 ? 1 : n; if (_source != null) { _source.Change += Sources_Change; Sources_Change(null, true); } }
/// <summary> /// Clear Values in SumRow /// </summary> public void ResetSumRow() { ValueRow valueRow = m_grid.GetValueRow(); if (valueRow != null) { foreach (Cell cell in valueRow.Cells) { cell.Value = null; } } }
public Ama(ValueRow source, int n, int fastPeriod = 2, int slowPeriod = 30) : base() { _source = source; _n = n; _fastSmooth = 2m / (fastPeriod + 1); _slowSmooth = 2m / (slowPeriod + 1); source.Change += Sources_Change; if (source.Count > 0) { Sources_Change(null, false); } }
void Source_Change(ValueRow src, bool isReset) { if (_calc == null || _source == null) { return; } int startIndex = isReset ? 0 : this.Count; for (int i = startIndex; i <= _source.LastIndex; i++) { this.Add(_calc(_source, i)); } }
void Source_Change(ValueRow src, bool isReset) { if (_calc == null || _source1 == null || _source2 == null) { return; } int startIndex = isReset ? 0 : this.Count; int endIndex = Math.Min(_source1.LastIndex, _source2.LastIndex); for (int i = startIndex; i <= endIndex; i++) { this.Add(_calc(_source1, _source2, i)); } }
public BollingerBands(ValueRow source, int n, decimal width) { _source = source; _n = n; _width = width >= 0 ? width : 0; _bbMiddle = new Ma(source, AverageMethod.Simple, n); _stdDev = new StdDev(source, n); _bbTop = new ValueRow(); _bbBottom = new ValueRow(); if (source != null) { source.Change += Source_Change; Source_Change(null, true); } }
void Sources_Change(ValueRow src, bool isReset) { if (_smoothRow == null) { for (int i = this.Count; i <= this._source.LastIndex; i++) { Calc(i); } } else { int min = Math.Min(_source.LastIndex, _smoothRow.LastIndex); for (int i = this.Count; i <= min; i++) { Calc(i); } } }
/// <summary> /// Constructor to receive ValueRow. Used for receiving values for groups, should be used to receive all classification values in the future. /// </summary> /// <param name="myValueRow"></param> /// <param name="LanguageCodes"></param> /// <param name="MainLanguageCode"></param> public PXSqlValue(ValueRow myValueRow, StringCollection LanguageCodes, string MainLanguageCode) { //this.meta = meta; this.mContentsCode = null; // only for contentsvalues this.ValueCode = myValueRow.ValueCode; this.ValueSet = null; this.ValuePool = myValueRow.ValuePool; this.SortCodePxs = 0; // is sometimes overridden from outside this.mSortCodeValue = myValueRow.texts[MainLanguageCode].SortCode; this.mSortCodeVsValue = null; //this.SortCodeDb = myValueRow.SortOrder; foreach (string langCode in LanguageCodes) { this.ValueTextS[langCode] = myValueRow.texts[langCode].ValueTextS; this.ValueTextL[langCode] = myValueRow.texts[langCode].ValueTextL; } }
void Source_Change(ValueRow src, bool isReset) { SuspendEvents(); if (isReset) { Clear(); _mo.Clear(); } if (_source != null) { int startIndex = isReset ? 0 : this.Count; for (int i = startIndex; i <= _source.LastIndex; i++) { Calc(i); } } ResumeEvents(); }
/// <summary> /// Подписывание ValueRow. /// Все новые значение ValueRow будут автоматически добавляться в серию. /// </summary> /// <param name="seriesID">Идентификатор серии</param> /// <param name="valueRow">Ряд значений</param> /// <param name="timeline">Временная ось</param> /// <param name="funcSp">Метод получения SeriesProps по значению</param> public void SubscribeValueRow(int seriesID, ValueRow valueRow, Timeline timeline, Func <decimal, ISeriesProps> funcSp = null) { var ser = _series.FirstOrDefault(s => s.SeriesID == seriesID); if (ser == null) { return; } if (_series_vrdata.ContainsKey(ser)) { var old_vr = _series_vrdata[ser].Item1; old_vr.Change -= valueRow_Change; _series_vrdata.Remove(ser); } if (valueRow != null && timeline != null) { _series_vrdata.Add(ser, new Tuple <ValueRow, Timeline, Func <decimal, ISeriesProps> >(valueRow, timeline, funcSp)); valueRow.Change += valueRow_Change; } }
public Calc(ValueRow source) { this.Source = source; }
public Calc(ValueRow source, CalcDelegate calc) { this.Source = source; this.CalcMethod = calc; }
void CheckColumn_ValueChanged(object sender, EventArgs e) { if (m_isBatchSetting) { return; } SummaryRow sumRow = m_grid.GetSummaryRow(); if (sumRow != null) { List <string> sumColumnNames = new List <string>(); List <string> countColumnNames = new List <string>(); foreach (Cell cell in sumRow.Cells) { SummaryCell sumCell = cell as SummaryCell; if (sumCell != null) { if (sumCell.StatFunction == StatFunction.Sum) { sumColumnNames.Add(cell.ParentColumn.FieldName); } else if (sumCell.StatFunction == StatFunction.Count) { countColumnNames.Add(cell.ParentColumn.FieldName); } } } if (sumColumnNames.Count > 0 || countColumnNames.Count > 0) { ValueRow valueRow = m_grid.GetValueRow(); if (valueRow == null) { sumRow.Visible = false; valueRow = m_grid.AddValueRowToFixedFooter(); } bool allSelect = true; bool noneSelect = true; decimal[] sum = new decimal[sumColumnNames.Count]; for (int i = 0; i < sumColumnNames.Count; ++i) { sum[i] = 0; } int[] count = new int[countColumnNames.Count]; for (int i = 0; i < countColumnNames.Count; ++i) { count[i] = 0; } foreach (Xceed.Grid.DataRow row in m_grid.DataRows) { if (Convert.ToBoolean(row.Cells[m_selectColumnName].Value)) { for (int i = 0; i < sumColumnNames.Count; ++i) { decimal?d = ConvertHelper.ToDecimal(row.Cells[sumColumnNames[i]].Value); sum[i] += d.HasValue ? d.Value : 0; } for (int i = 0; i < countColumnNames.Count; ++i) { count[i] += 1; } noneSelect = false; } else { allSelect = false; } } for (int i = 0; i < sumColumnNames.Count; ++i) { valueRow.Cells[sumColumnNames[i]].Value = sum[i]; } for (int i = 0; i < countColumnNames.Count; ++i) { valueRow.Cells[countColumnNames[i]].Value = count[i]; } if (allSelect) { valueRow.Cells[m_selectColumnName].Value = true; } else if (noneSelect) { valueRow.Cells[m_selectColumnName].Value = false; } else { valueRow.Cells[m_selectColumnName].Value = null; } } } }
public StdDev() : base() { _n = 1; _mo = new ValueRow(); }
public Calc2(ValueRow source1, ValueRow source2, CalcDelegate2 calc) { _source1 = source1; _source2 = source2; _calc = calc; }
/// <summary> /// 加入ValueRow /// </summary> /// <returns></returns> public static ValueRow AddValueRowToFixedFooter(this IGrid grid) { ValueRow valueRow = new ValueRow(); valueRow.CanBeCurrent = false; valueRow.CanBeSelected = false; valueRow.BackColor = Color.LightBlue; grid.FixedFooterRows.Add(valueRow); return valueRow; }
void _source_Change(ValueRow vr, bool isReset) { RaiseChanged(); }
public Calc2(ValueRow source1, ValueRow source2) { _source1 = source1; _source2 = source2; }