private void TestIndicator(IIndicator indicator, SlotTypes slotType, IDataSet dataSet, Random random) { indicator.Initialize(slotType); // List parameters foreach (ListParam list in indicator.IndParam.ListParam) if (list.Enabled) { list.Index = random.Next(list.ItemList.Length); list.Text = list.ItemList[list.Index]; } // Numeric parameters foreach (NumericParam num in indicator.IndParam.NumParam) if (num.Enabled) { double step = Math.Pow(10, -num.Point); double minimum = num.Min; double maximum = num.Max; double value = minimum + step * random.Next((int)((maximum - minimum) / step)); num.Value = Math.Round(value, num.Point); } indicator.Calculate(dataSet); }
private void ShowResult(IIndicator indicator) { Console.WriteLine(indicator.ToString()); Console.WriteLine("Slot type: {0}", indicator.IndParam.SlotType); Console.WriteLine("Logic rule: {0}", indicator.IndParam.ListParam[0].Text); foreach (IndicatorComp component in indicator.Component) { if(component == null) continue; IndComponentType type = component.DataType; int bars = component.Value.Length; string name = component.CompName; double value = component.Value[bars - 1]; double val = Math.Abs(value); string format = val < 10 ? "F5" : val < 100 ? "F4" : val < 1000 ? "F3" : val < 10000 ? "F2" : val < 100000 ? "F1" : "F0"; if (!component.ShowInDynInfo) continue; if (type == IndComponentType.AllowOpenLong || type == IndComponentType.AllowOpenShort || type == IndComponentType.ForceClose || type == IndComponentType.ForceCloseLong || type == IndComponentType.ForceCloseShort) Console.WriteLine("{0}: {1} ", name, (value < 1 ? "No" : "Yes")); else Console.WriteLine("{0}: {1}", name, value.ToString(format)); } Console.WriteLine(); }
/// <summary> /// Weight must be within ]0;1] /// </summary> public WeightedIndicator( IIndicator indicator, double weight ) { CheckRange( weight ); Weight = weight; myIndicator = indicator; }
private void OnChartPanelSubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries candleSeries, IIndicator indicator) { _drawTimer.Cancel(); _elements.Add(new RefPair<IChartElement, int>(element, 0)); _indicators.Add(element, indicator); _drawTimer.Activate(); }
public Ema(IIndicator baseIndicator, int period) { if (baseIndicator == null) throw new ArgumentNullException("baseIndicator"); _base = baseIndicator; if (_base.Updatable) _base.UpdateEvent += BaseUpdated; SetPeriod(period); }
private static void PrintFirstValues(IIndicator indicator, int componentIndex, int countOfValuesToPrint) { int firstBar = indicator.Component[componentIndex].FirstBar; var sb = new StringBuilder(); sb.AppendLine("bar value"); sb.AppendLine("--------------------------"); for (int bar = firstBar; bar < firstBar + countOfValuesToPrint; bar++) sb.AppendLine(bar + " : " + indicator.Component[componentIndex].Value[bar]); Console.WriteLine(sb.ToString()); }
public Simple(IIndicator baseIndicator, int period) { if (baseIndicator == null) throw new ArgumentNullException("baseIndicator"); _base = baseIndicator; _period = period; if (_base.Updatable) _base.UpdateEvent += BaseUpdated; //UpdateData(); }
public void CalculateIndicatorWithRandomParameters(IIndicator indicator, IDataSet dataSet, int testPerSlot) { Random random = new Random(DateTime.Now.Second); var types = (SlotTypes[])Enum.GetValues(typeof(SlotTypes)); foreach (var type in types) if (indicator.TestPossibleSlot(type)) for (int i = 0; i < testPerSlot; i++) { TestIndicator(indicator, type, dataSet, random); ShowResult(indicator); } }
public SubscribeIndicatorElementCommand(ChartIndicatorElement element, CandleSeries candleSeries, IIndicator indicator) { if (element == null) throw new ArgumentNullException(nameof(element)); if (candleSeries == null) throw new ArgumentNullException(nameof(candleSeries)); if (indicator == null) throw new ArgumentNullException(nameof(indicator)); Element = element; CandleSeries = candleSeries; Indicator = indicator; }
private void Chart_OnSubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries series, IIndicator indicator, ChartPanel chart) { var values = _allCandles .Select(candle => { if (candle.State != CandleStates.Finished) candle.State = CandleStates.Finished; return new RefPair<DateTimeOffset, IDictionary<IChartElement, object>>(candle.OpenTime, new Dictionary<IChartElement, object> { { element, indicator.Process(candle) } }); }) .ToArray(); chart.Draw(values); }
/// <summary> /// remove indicator from candlestick chart / /// удалить индикатор со свечного графика /// </summary> /// <param name="indicator">индикатор</param> public void DeleteCandleIndicator(IIndicator indicator) { _chartMaster.DeleteIndicator(indicator); }
public void AddIndicator( IIndicator indicator ) { myIndicator.AddIndicator( indicator ); }
/// <summary> /// accept button /// кнопка принять /// </summary> private void ButtonAccept_Click(object sender, RoutedEventArgs e) { if (_lastScriptGrid) { AcceptCreationScriptIndicator(); return; } string areaName = _gridViewAreas.SelectedCells[0].Value.ToString(); if (areaName == "NewArea") { for (int i = 0; i < 30; i++) { if (_chartMaster.AreaIsCreate("NewArea" + i) == false) { areaName = "NewArea" + i; break; } } } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Trades") { _chartMaster.CreateTickChart(); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "TickVolume") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "TickVolume" + i) == false) { name = "VWAP" + i; break; } } IndicatorCandle = new TickVolume(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "VWAP") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "VWAP" + i) == false) { name = "VWAP" + i; break; } } IndicatorCandle = new Vwap(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "UltimateOscillator") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "UltimateOscillator" + i) == false) { name = "UltimateOscillator" + i; break; } } IndicatorCandle = new UltimateOscillator(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "KalmanFilter") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "KalmanFilter" + i) == false) { name = "KalmanFilter" + i; break; } } IndicatorCandle = new KalmanFilter(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Moving Average") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Sma" + i) == false) { name = "Sma" + i; break; } } IndicatorCandle = new MovingAverage(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Volume") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Volume" + i) == false) { name = "Volume" + i; break; } } IndicatorCandle = new Volume(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Price Channel") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Price Channel" + i) == false) { name = "Price Channel" + i; break; } } IndicatorCandle = new PriceChannel(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Bollinger") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Bollinger" + i) == false) { name = "Bollinger" + i; break; } } IndicatorCandle = new Bollinger(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "DonchianChannel") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "DonchianChannel" + i) == false) { name = "DonchianChannel" + i; break; } } IndicatorCandle = new DonchianChannel(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "BFMFI") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "BFMFI" + i) == false) { name = "BFMFI" + i; break; } } IndicatorCandle = new BfMfi(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "BullsPower") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "BullsPower" + i) == false) { name = "BullsPower" + i; break; } } IndicatorCandle = new BullsPower(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "CMO") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "CMO" + i) == false) { name = "CMO" + i; break; } } IndicatorCandle = new Cmo(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "BearsPower") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "BearsPower" + i) == false) { name = "BeasPower" + i; break; } } IndicatorCandle = new BearsPower(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Stochastic Oscillator") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "StochasticOscillator" + i) == false) { name = "StochasticOscillator" + i; break; } } IndicatorCandle = new StochasticOscillator(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Stochastic Rsi") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "StochasticRsi" + i) == false) { name = "StochasticRsi" + i; break; } } IndicatorCandle = new StochRsi(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "RSI") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "RSI" + i) == false) { name = "RSI" + i; break; } } IndicatorCandle = new Rsi(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "ROC") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "ROC" + i) == false) { name = "ROC" + i; break; } } IndicatorCandle = new Roc(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "RVI") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "RVI" + i) == false) { name = "RVI" + i; break; } } IndicatorCandle = new Rvi(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Alligator") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Alligator" + i) == false) { name = "Alligator" + i; break; } } IndicatorCandle = new Alligator(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "AO") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "AO" + i) == false) { name = "AO" + i; break; } } IndicatorCandle = new AwesomeOscillator(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "AccumulationDistribution") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "AccumulationDistribution" + i) == false) { name = "AccumulationDistribution" + i; break; } } IndicatorCandle = new AccumulationDistribution(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Force Index") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Force Index" + i) == false) { name = "Force Index" + i; break; } } IndicatorCandle = new ForceIndex(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "OnBalanceVolume") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "OnBalanceVolume" + i) == false) { name = "OnBalanceVolume" + i; break; } } IndicatorCandle = new OnBalanceVolume(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Fractal") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Fractal" + i) == false) { name = "Fractal" + i; break; } } IndicatorCandle = new Fractal(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "ADX") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "ADX" + i) == false) { name = "ADX" + i; break; } } IndicatorCandle = new Adx(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "ATR") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "ATR" + i) == false) { name = "ATR" + i; break; } } IndicatorCandle = new Atr(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Price Oscillator") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Price Oscillator" + i) == false) { name = "Price Oscillator" + i; break; } } IndicatorCandle = new PriceOscillator(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "MACD Histogram") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "MACD Histogram" + i) == false) { name = "MACD Histogram" + i; break; } } IndicatorCandle = new MacdHistogram(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "MACD Line") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "MACD Line" + i) == false) { name = "MACD Line" + i; break; } } IndicatorCandle = new MacdLine(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Momentum") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Momentum" + i) == false) { name = "Momentum" + i; break; } } IndicatorCandle = new Momentum(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "MoneyFlowIndex") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "MoneyFlowIndex" + i) == false) { name = "MoneyFlowIndex" + i; break; } } IndicatorCandle = new MoneyFlowIndex(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Envelops") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Envelops" + i) == false) { name = "Envelops" + i; break; } } IndicatorCandle = new Envelops(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Efficiency Ratio") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "EfficiencyRatio" + i) == false) { name = "EfficiencyRatio" + i; break; } } IndicatorCandle = new EfficiencyRatio(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Adaptive Look Back") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Adaptive Look Back" + i) == false) { name = "Adaptive Look Back" + i; break; } } IndicatorCandle = new AdaptiveLookBack(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "IvashovRange") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "IvashovRange" + i) == false) { name = "IvashovRange" + i; break; } } IndicatorCandle = new IvashovRange(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Volume Oscillator") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Volume Oscillator" + i) == false) { name = "Volume Oscillator" + i; break; } } IndicatorCandle = new VolumeOscillator(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Parabolic SAR") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Parabolic SAR" + i) == false) { name = "Parabolic SAR" + i; break; } } IndicatorCandle = new ParabolicSaR(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "CCI") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "CCI" + i) == false) { name = "CCI" + i; break; } } IndicatorCandle = new Cci(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Standard Deviation") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Standard Deviation" + i) == false) { name = "Standard Deviation" + i; break; } } IndicatorCandle = new StandardDeviation(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "AC") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "AC" + i) == false) { name = "AC" + i; break; } } IndicatorCandle = new Ac(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "VerticalHorizontalFilter") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "VerticalHorizontalFilter" + i) == false) { name = "VerticalHorizontalFilter" + i; break; } } IndicatorCandle = new VerticalHorizontalFilter(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "WilliamsRange") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "WilliamsRange" + i) == false) { name = "WilliamsRange" + i; break; } } IndicatorCandle = new WilliamsRange(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Trix") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Trix" + i) == false) { name = "Trix" + i; break; } } IndicatorCandle = new Trix(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Ichimoku") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Ichimoku" + i) == false) { name = "Ichimoku" + i; break; } } IndicatorCandle = new Ichimoku(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "TradeThread") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "TradeThread" + i) == false) { name = "TradeThread" + i; break; } } IndicatorCandle = new TradeThread(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Pivot") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "Pivot" + i) == false) { name = "Pivot" + i; break; } } IndicatorCandle = new Pivot(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "Pivot Points") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "PivotPoints" + i) == false) { name = "PivotPoints" + i; break; } } IndicatorCandle = new PivotPoints(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "LinearRegressionCurve") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "LinearRegressionCurve" + i) == false) { name = "LinearRegressionCurve" + i; break; } } IndicatorCandle = new LinearRegressionCurve(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } if (_gridViewIndicators.SelectedCells[0].Value.ToString() == "SimpleVWAP") { string name = ""; for (int i = 0; i < 30; i++) { if (_chartMaster.IndicatorIsCreate(_chartMaster.Name + "SimpleVWAP" + i) == false) { name = "SimpleVWAP" + i; break; } } IndicatorCandle = new SimpleVWAP(_chartMaster.Name + name, true); _chartMaster.CreateIndicator(IndicatorCandle, areaName); } Close(); if (IndicatorCandle != null) { IndicatorCandle.ShowDialog(); } }
/** * Constructor. * * @param ref the indicator * @param timeFrame the time frame */ public IsHighestRule(IIndicator <decimal> indicator, int timeFrame) { _indicator = indicator; _timeFrame = timeFrame; }
/// <summary> /// To replace the indicator input value by new one (for example it is received from another indicator). /// </summary> /// <typeparam name="T">The data type, operated by indicator.</typeparam> /// <param name="indicator">Indicator.</param> /// <param name="value">Value.</param> /// <returns>Replaced copy of the input value.</returns> public override IIndicatorValue SetValue <T>(IIndicator indicator, T value) { throw new NotSupportedException(); }
/// <summary> /// Initializes a new instance of the <see cref="ShiftedIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> public ShiftedIndicatorValue(IIndicator indicator) : base(indicator) { }
private void Chart_OnSubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries series, IIndicator indicator) { var chartData = new ChartDrawData(); foreach (var candle in _allCandles.Cache) { //if (candle.State != CandleStates.Finished) // candle.State = CandleStates.Finished; chartData.Group(candle.OpenTime).Add(element, indicator.Process(candle)); } Chart.Draw(chartData); _indicators.Add(element, indicator); CustomColors_Changed(null, null); }
/// <summary> /// Initializes a new instance of the <see cref="CandleIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> /// <param name="value">Value.</param> public CandleIndicatorValue(IIndicator indicator, Candle value) : this(indicator, value, ByClose) { }
/// <summary> /// Initializes a new instance of the <see cref="DecimalIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> public DecimalIndicatorValue(IIndicator indicator) : base(indicator) { }
/// <summary> /// Initializes a new instance of the <see cref="DecimalIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> /// <param name="value">Value.</param> public DecimalIndicatorValue(IIndicator indicator, decimal value) : base(indicator, value) { }
/// <summary> /// Initializes a new instance of the <see cref="SingleIndicatorValue{T}"/>. /// </summary> /// <param name="indicator">Indicator.</param> public SingleIndicatorValue(IIndicator indicator) : base(indicator) { IsEmpty = true; }
/// <summary> /// Initializes a new instance of the <see cref="SingleIndicatorValue{T}"/>. /// </summary> /// <param name="indicator">Indicator.</param> /// <param name="value">Value.</param> public SingleIndicatorValue(IIndicator indicator, TValue value) : base(indicator) { Value = value; IsEmpty = value.IsNull(); }
/// <inheritdoc /> public abstract IIndicatorValue SetValue <T>(IIndicator indicator, T value);
/// <summary> /// Initialize <see cref="BaseIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> protected BaseIndicatorValue(IIndicator indicator) { Indicator = indicator ?? throw new ArgumentNullException(nameof(indicator)); IsFormed = indicator.IsFormed; }
public RsiStrategy(IIndicatorFactory indicatorFactory) { _rsiIndicator = indicatorFactory.GetRsiIndicator(14); }
/// <summary> /// Initializes a new instance of the <see cref="CandleIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> private CandleIndicatorValue(IIndicator indicator) : base(indicator) { }
protected ProcessApp(string code, IIndicator indicator) : base(code, indicator) { ProvidersFactory = new ProvidersFactory(); }
/// <summary> /// Initializes a new instance of the <see cref="MarketDepthIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> /// <param name="depth">Market depth.</param> public MarketDepthIndicatorValue(IIndicator indicator, MarketDepth depth) : this(indicator, depth, ByMiddle) { }
/// <summary> /// Initializes a new instance of the <see cref="ShiftedIndicatorValue"/>. /// </summary> /// <param name="shift">The shift of the indicator value.</param> /// <param name="value">Indicator value.</param> /// <param name="indicator">Indicator.</param> public ShiftedIndicatorValue(IIndicator indicator, int shift, IIndicatorValue value) : base(indicator, value) { Shift = shift; }
/// <summary> /// Initializes a new instance of the <see cref="PairIndicatorValue{T}"/>. /// </summary> /// <param name="indicator">Indicator.</param> /// <param name="value">Value.</param> public PairIndicatorValue(IIndicator indicator, Tuple <TValue, TValue> value) : base(indicator, value) { }
private void Chart_OnSubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries series, IIndicator indicator) { _dataThreadActions.Add(() => { var oldReset = Chart.DisableIndicatorReset; try { Chart.DisableIndicatorReset = true; indicator.Reset(); } finally { Chart.DisableIndicatorReset = oldReset; } var chartData = new ChartDrawData(); foreach (var candle in _allCandles.CachedValues) { chartData.Group(candle.OpenTime).Add(element, indicator.Process(candle)); } Chart.Reset(new[] { element }); Chart.Draw(chartData); _indicators[element] = indicator; }); }
/// <summary> /// Initializes a new instance of the <see cref="PairIndicatorValue{T}"/>. /// </summary> /// <param name="indicator">Indicator.</param> public PairIndicatorValue(IIndicator indicator) : base(indicator) { }
/** * Constructor. * @param indicator a related indicator (with a time series) */ public RecursiveCachedIndicator(IIndicator <T> indicator) : this(indicator.TimeSeries) { }
private void OnChartPanelSubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries candleSeries, IIndicator indicator) { new SubscribeIndicatorElementCommand(element, candleSeries, indicator).Process(this); }
public Monitor(Reporter reporter, IIndicator indicator) { Reporter = reporter; Indicator = indicator; }
private void SetSource(ChartIndicatorElement element, CandleSeries candleSeries, IIndicator indicator) { List<RefPair<DateTimeOffset, IDictionary<IChartElement, object>>> values = null; lock (_syncRoot) { _indicators[element] = indicator; var isNew = !_elementsBySeries.ContainsKey(candleSeries); if (!isNew && CanProcess) { values = ProcessHistoryCandles(element, candleSeries); } else if (isNew) SubscribeSeries(candleSeries); var lastDate = values == null || values.IsEmpty() ? DateTimeOffset.MinValue : values.Last().First; _elementsInfo.SafeAdd(element, e => RefTuple.Create(lastDate, candleSeries)); _elementsBySeries.SafeAdd(candleSeries).Add(element); } if (values != null && values.Count > 0) new ChartDrawCommand(values).Process(this); }
public void AddIndicator( double weight, IIndicator indicator ) { AddIndicator( new WeightedIndicator( indicator, weight ) ); }
/// <inheritdoc /> public NetPosition(IIndicator <IOrder> orders) { Orders = orders; Orders.Update += OrdersOnUpdate; }
public DxValue(IIndicator indicator) : base(indicator) { }
public override IIndicatorValue SetValue <T>(IIndicator indicator, T value) { IsEmpty = false; _value = value.To <decimal>(); return(new DecimalIndicatorValue(indicator, _value)); }
/// <summary> /// Initializes a new instance of the <see cref="ComplexIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> public ComplexIndicatorValue(IIndicator indicator) : base(indicator) { InnerValues = new Dictionary <IIndicator, IIndicatorValue>(); }
/* * upThrust * traverse >= 10 bars * >= 7 bars have low mid above the 3x3 * >= 5 consecutive bars must have low mid above the 3x3 * sequence may not start with > 3 bars with low mid below 3x3 * if (any of?) top 3 bars of sequence have low mid below 3x3 then lowest low mid of those below the 3x3 must be > .386 ask price * thrust range must be >= (.06 x thrust ReactionPrice) * MACD histogram value of all thrust frames must be > 0 * * downThrust * traverse >= 10 bars * >= 7 bars have low mid above the 3x3 * >= 5 consecutive bars must have low mid above the 3x3 * sequence may not start with > 3 bars with low mid below 3x3 * if (any of?) top 3 bars of sequence have low mid below 3x3 then lowest low mid of those below the 3x3 must be > .386 ask price * thrust range must be >= (.06 x thrust ReactionPrice) * MACD histogram value of all thrust frames must be > 0 * above or below the 3x3? */ #endregion /// <summary> /// Searches the chart for a thrust pattern. /// </summary> /// <param name="chart">Chart object containing at least 20 frames</param> /// <returns>A tradeable thrust object, if found.</returns> protected override Thrust DetectThrust() { _minThrustPercentRange = .003; Thrust thrust = null; if (_chart.Frames.Count >= 20) { Frame frame; bool upThrustFound = false, downThrustFound = false; short above3x3Count = 0, above3x3Links = 0, below3x3Count = 0, below3x3Links = 0, across3x3Count = 0; Func <short> sequentialAbove3x3Count = () => { return(above3x3Links > 0 ? (short)(above3x3Links + 1) : (short)0); }; Func <short> sequentialBelow3x3Count = () => { return(below3x3Links > 0 ? (short)(below3x3Links + 1) : (short)0); }; AboveBelowDMA previousCandleSide = AboveBelowDMA.Unknown, currentCandleSide = AboveBelowDMA.Unknown; List <AboveBelowDMA> leaderSides = new List <AboveBelowDMA>(); // only need to sniff 20 frames to find thrust // if not in 20 frames, whatever thrust exists has yielded to a consolidation period .. no good short loopCount = 0; while (loopCount < 20) { loopCount++; int i = _chart.Frames.Count - loopCount; frame = _chart.Frames[i]; IPriceBar candle = frame.Bar; IIndicator displaced3x3 = frame.Indicators.First(k => k.Type == IndicatorType.DisplacedMovingAverage && k.ParentOrdinal == 0); if (candle.lowMid >= displaced3x3.Value) { above3x3Count++; if (previousCandleSide == AboveBelowDMA.Above) { above3x3Links++; } currentCandleSide = previousCandleSide = AboveBelowDMA.Above; } else if (candle.highMid <= displaced3x3.Value) { below3x3Count++; if (previousCandleSide == AboveBelowDMA.Below) { below3x3Links++; } currentCandleSide = previousCandleSide = AboveBelowDMA.Below; } else { across3x3Count++; currentCandleSide = previousCandleSide = AboveBelowDMA.Across; } // save the first 3 bar sides if (leaderSides.Count < 3) { leaderSides.Add(currentCandleSide); } // start thrust parsing once 10 bars have been examined if (loopCount > 9) { upThrustFound = sequentialAbove3x3Count() >= 6 && sequentialBelow3x3Count() <= 3 && CheckLeaders(leaderSides, AboveBelowDMA.Above); downThrustFound = sequentialBelow3x3Count() >= 6 && sequentialAbove3x3Count() <= 3 && CheckLeaders(leaderSides, AboveBelowDMA.Below); if (upThrustFound || downThrustFound) { EPatternDirection direction = upThrustFound ? EPatternDirection.Up : EPatternDirection.Down; Frame reactionFrame = FindReactionFrame(frame, i, direction); if (reactionFrame != null) { int checkAcrossIndex = GetCheckAcrossIndex(reactionFrame, direction); AboveBelowDMA checkAcrossSide = upThrustFound ? AboveBelowDMA.Above : AboveBelowDMA.Below; if (CheckAcrossFrames(checkAcrossIndex, checkAcrossSide)) { thrust = BuildThrust(reactionFrame, direction); } } break; } } } } return(thrust); }
private void OnChartPanelSubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries candleSeries, IIndicator indicator) { _bufferedChart.SetSource(element, candleSeries); _indicators.Add(element, indicator); AddElement(element, candleSeries); }
public PeriodicThread(ProcessProject project, int id, string name, IIndicator indicator, double periodMinutes, double lateMinutes) : base(project, id, name, indicator, LoggerStability.Periodic) { PeriodMinutes = periodMinutes; LateMinutes = lateMinutes; }
private void Chart_SubscribeIndicatorElement(ChartIndicatorElement element, CandleSeries series, IIndicator indicator) { var candles = _candles.TryGetValue(series.Security); if (candles == null) throw new InvalidOperationException("_candles == null"); var values = candles .Select(candle => { if (candle.State != CandleStates.Finished) candle.State = CandleStates.Finished; return new RefPair<DateTimeOffset, IDictionary<IChartElement, object>>(candle.OpenTime, new Dictionary<IChartElement, object> { { element, indicator.Process(candle) } }); }) .ToArray(); Chart.Draw(values); }
/// <summary> /// Initializes a new instance of the <see cref="VolumeProfileIndicatorValue"/>. /// </summary> /// <param name="indicator">Indicator.</param> public VolumeProfileIndicatorValue(IIndicator indicator) : base(indicator) { Levels = new Dictionary <decimal, decimal>(); }