private void CompositionTargetRendering(object sender, EventArgs e) { if (!viewModel.isConnectSet() || viewModel.vm_Stop) { stopwatch.Stop(); } else { if (!stopwatch.IsRunning) { stopwatch.Start(); } // update graphs info viewModel.UpdateDateLine(viewModel.PlotModel, viewModel.ChosenChunk, ref viewModel.lastUpdate); viewModel.UpdateDateLine(viewModel.PlotModel_corr, viewModel.CorrelatedChunk, ref viewModel.lastUpdateCorr); viewModel.updateRegLine(); // if 800 milliseconds passed - refresh graphs graphic. if (stopwatch.ElapsedMilliseconds > 800) { Plot1.RefreshPlot(true); Plot_corr.RefreshPlot(true); Plot_reg.RefreshPlot(true); stopwatch.Restart(); } } }
private void AddToDataCollection(DateTime now, double temp) { if (_tempDataCollection == null) { _tempDataCollection = new List <TemperatureData>(); } if (!_addingData) { _addingData = true; _tempDataCollection.Add(new TemperatureData() { Time = now, Value = temp }); _minTemp = _tempDataCollection.Min(x => x.Value); _maxTemp = _tempDataCollection.Max(x => x.Value); _avgTemp = _tempDataCollection.Average(x => x.Value); if (DataCollection.Count() > 60) { DataCollection.RemoveAt(0); } DataCollection.Add(new TemperatureData() { Time = now, Value = temp }); Plot1.InvalidatePlot(true); _addingData = false; } }
private void Plot1OnMouseMove(object sender, MouseEventArgs e) { var p = e.GetPosition(sender as IInputElement); var x = Plot1.XFromLeft(p.X); var y = Plot1.YFromTop(p.Y); coordinateTB.Text = $"{x},{y}"; }
protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. Plot0.Set(Close[0]); Plot1.Set(Close[0]); Plot3.Set(Close[0]); }
private void button_Click(object sender, RoutedEventArgs e) { foreach (var axe in Plot1.Axes) { axe.InternalAxis.Reset(); } Plot1.InvalidatePlot(); }
private void CompositionTargetRendering(object sender, EventArgs e) { if (stopwatch.ElapsedMilliseconds > lastUpdateMilliSeconds + 5000) { viewModel.UpdateModel(); Plot1.RefreshPlot(true); lastUpdateMilliSeconds = stopwatch.ElapsedMilliseconds; } }
public SummaryWin() { InitializeComponent(); CompositionTarget.Rendering += (sender, args) => { Plot1.InvalidatePlot(true); Plot2.InvalidatePlot(true); }; }
public void EnableDisableSeries(PingResult p, bool enable) { if (enable) { if (!Plot1.Series.Contains(p.Line)) { Plot1.Series.Add(p.Line); } p.Line.ItemsSource = p.Points; } else { Plot1.Series.Remove(p.Line); } Plot1.InvalidatePlot(true); }
private void RecalculateScale() { Point[] plot1 = new Point[0]; Point[] plot2 = new Point[0]; double actualWidth = 0; double actualHeight = 0; try { Dispatcher.Invoke(() => { plot1 = Plot1.ToArray(); plot2 = Plot2.ToArray(); actualWidth = Plots.ActualWidth; actualHeight = Plots.ActualHeight; }); } catch { } ValueToSet valueToSet = RecalculateScale(plot1, plot2, actualWidth, actualHeight, X1, Y1); try { if (!valueToSet.setXY && !valueToSet.setScale) { return; } Dispatcher.Invoke(() => { if (valueToSet.setXY) { X0 = valueToSet.x0; Y0 = valueToSet.y0; X1 = valueToSet.x1; Y1 = valueToSet.y1; } if (valueToSet.setScale) { ScaleX = valueToSet.scaleX; ScaleY = valueToSet.scaleY; } }); } catch { } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBar < 5) { return; } if (MACD(12, 26, 9).Diff[0] >= MACD(12, 26, 9).Diff[1]) { if ((MACD(12, 26, 9).Diff[1] < MACD(12, 26, 9).Diff[2]) & (MACD(12, 26, 9).Diff[2] < MACD(12, 26, 9).Diff[3]) & (MACD(12, 26, 9).Diff[3] < MACD(12, 26, 9).Diff[4]) & (MACD(12, 26, 9).Diff[4] < MACD(12, 26, 9).Diff[5])) { Plot5.Set(MACD(12, 26, 9).Diff[0]); } else { Plot5.Set(0); Plot1.Set(MACD(12, 26, 9).Diff[0]); } } else { Plot1.Set(0); } if (MACD(12, 26, 9).Diff[0] < MACD(12, 26, 9).Diff[1]) { if ((MACD(12, 26, 9).Diff[1] >= MACD(12, 26, 9).Diff[2]) & (MACD(12, 26, 9).Diff[2] >= MACD(12, 26, 9).Diff[3]) & (MACD(12, 26, 9).Diff[3] >= MACD(12, 26, 9).Diff[4]) & (MACD(12, 26, 9).Diff[4] >= MACD(12, 26, 9).Diff[5])) { Plot4.Set(MACD(12, 26, 9).Diff[0]); } else { Plot4.Set(0); Plot0.Set(MACD(12, 26, 9).Diff[0]); } } else { Plot0.Set(0); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 1) { return; } if ((High[0] > High[1]) & (Open[0] > Close[0]) & (Close[0] < Close[1])) { Plot0.Set(1); } if ((Low[0] < Low[1]) & (Close[0] > Open[0]) & (Close[0] > Close[1])) { Plot1.Set(1); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. // Plot0.Set(Close[0]); if (CurrentBar < 1) { return; } starttime = Time[1]; durationtime = Time[0] - starttime; totalseconds = (int)durationtime.TotalSeconds; if (totalseconds > myInput0) { totalseconds = myInput0; secperbar.Set(totalseconds); if (drawSMA) { Plot0.Set(SMA(secperbar, sMAPeriod)[0]); } Plot1.Set(totalseconds); // PlotColors[0][0] = Color.Red; PlotColors[1][0] = Color.Red; } else { secperbar.Set(totalseconds); if (drawSMA) { Plot0.Set(SMA(secperbar, sMAPeriod)[0]); } Plot1.Set(totalseconds); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 1) { return; } if ((EMA(fastEMA)[0] > EMA(slowEMA)[0]) & !(EMA(fastEMA)[1] > EMA(slowEMA)[1])) { Plot0.Set(1); //blue } if ((EMA(slowEMA)[0] > EMA(fastEMA)[0]) & !(EMA(slowEMA)[1] > EMA(fastEMA)[1])) { Plot1.Set(1); //red } }
private void CallBack(IAsyncResult res) { IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 4444); byte[] received = Client.EndReceive(res, ref RemoteIpEndPoint); string s = Encoding.ASCII.GetString(received); Console.WriteLine(s); if (!s.Contains("garbage")) { string[] lines = s.Split('\n'); foreach (var line in lines) { string[] split = line.Split(':'); if (split.Length > 1) { MainWindow.disp.BeginInvoke(DispatcherPriority.Normal, new Action(() => { double d = 0; d = Double.Parse(split[1] /*.Replace('.', ',')*/); PingResult temp = pingResults.Add(split[0], d); if (temp != null) { Plot1.Series.Add(temp.Line); temp.Line.ItemsSource = temp.Points; } Plot1.InvalidatePlot(true); })); } } } if (continous) { Client.BeginReceive(new AsyncCallback(CallBack), null); } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 4) { return; } if ((High[2] >= High[0]) && (High[2] >= High[1]) && (High[2] >= High[3]) && (High[2] >= High[4])) { Plot0.Set(2, 1); return; } if ((Low[2] <= Low[0]) && (Low[2] <= Low[1]) && (Low[2] <= Low[3]) && (Low[2] <= Low[4])) { Plot1.Set(2, 1); return; } }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 30) { return; } if ((Low[0] <= DonchianChannel(14)[0]) & (Low[1] > DonchianChannel(14)[1])) { Plot1.Set(1); } if ((High[0] >= DonchianChannel(14)[0]) & (High[1] < DonchianChannel(14)[1])) { Plot0.Set(1); } int up = 0; int down = 0; int y = 0; for (int x = 1; x <= 100; x++) { if ((Low[x] <= DonchianChannel(14)[x]) & (Low[x + 1] > DonchianChannel(14)[x + 1])) { up = 1; y = x; break; } if ((High[x] >= DonchianChannel(14)[x]) & (High[x + 1] < DonchianChannel(14)[x + 1])) { down = 1; y = x; break; } } int firstup = 0; int firstdown = 0; for (int x = 0; x <= 100; x++) { if ((up == 1) & (High[x] > High[x + 1])) { if (x >= y) { break; } if (x != 0) { firstup = 1; break; } /* * if (!(x < y)) * { * break; * }*/ } if ((down == 1) & (Low[x] < Low[x + 1])) { if (x >= y) { break; } if (x != 0) { firstdown = 1; break; } /* * if (!(x < y)) * { * break; * }*/ } } if ((firstup == 0) & (up == 1) & (High[0] > High[1])) { Plot3.Set(1); } if ((firstdown == 0) & (down == 1) & (Low[0] < Low[1])) { Plot2.Set(1); } }
public void Refresh() { Plot1.InvalidatePlot(true); }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Try to connect, if we are not yet connected. // We do this here so that we do not connect everytime the indicator is instanciated. // Indicators are often instanciated several times before they are actually used. if (_indicatorState == IndicatorState.Uninitialized) { OpenConnection(); } // Are we in an error state? If so, display and exit. if (_indicatorState == IndicatorState.Error) { DrawError(); return; } // If we are actually connected to a socket, then communicate with it. if (_sock != null) { StringBuilder line = new StringBuilder(); long when = Time[0].Second + Time[0].Minute * 100l + Time[0].Hour * 10000l + Time[0].Day * 1000000l + Time[0].Month * 100000000l + Time[0].Year * 10000000000l; line.Append("\"" + PACKET_BAR + "\","); line.Append(when); line.Append(",\""); line.Append(this.Instrument.FullName); line.Append("\""); foreach (string name in _sourceData) { IDataSeries source; int totalBars = 1; string name2 = name; ParseArraySize(name, ref totalBars, ref name2); if (string.Compare(name2, "HIGH", true) == 0) { source = High; } else if (string.Compare(name2, "LOW", true) == 0) { source = Low; } else if (string.Compare(name2, "OPEN", true) == 0) { source = Open; } else if (string.Compare(name2, "CLOSE", true) == 0) { source = Close; } else if (string.Compare(name2, "VOL", true) == 0) { source = Volume; } else if (string.Compare(name2, "THIS", true) == 0) { source = Values[0]; } else { source = Eval(name2); if (source == null) { return; } } // now copy needed data var cnt = CurrentBar + 1; for (int i = 0; i < totalBars; i++) { line.Append(","); if (i >= cnt) { line.Append("?"); } else { //line.Append(Convert.ToString(source[i])); line.Append(Convert.ToString(source[i], _cultureUSA)); } } } Send(line.ToString()); // if we are expecting data back from the socket, then wait for it. if (_blockingMode) { // we are now waiting for a bar _indicatorState = IndicatorState.SentBar; while (_indicatorState != IndicatorState.Error && _indicatorState != IndicatorState.Ready) { WaitForPacket(); } // we got a bar message, then display it if (_indicatorState == IndicatorState.Ready) { if (!double.IsNaN(_indicatorData[0])) { Plot1.Set(_indicatorData[0]); } if (!double.IsNaN(_indicatorData[1])) { Plot2.Set(_indicatorData[1]); } if (!double.IsNaN(_indicatorData[2])) { Plot3.Set(_indicatorData[2]); } if (!double.IsNaN(_indicatorData[3])) { Bar1.Set(_indicatorData[3]); } if (!double.IsNaN(_indicatorData[4])) { Bar2.Set(_indicatorData[4]); } if (!double.IsNaN(_indicatorData[5])) { Bar3.Set(_indicatorData[5]); } if (!double.IsNaN(_indicatorData[6])) { IndSell.Set(_indicatorData[6]); } if (!double.IsNaN(_indicatorData[7])) { IndBuy.Set(_indicatorData[7]); } } } else { var hold = this.DrawOnPricePanel; DrawOnPricePanel = false; DrawTextFixed("general msg", "This indicator only sends data, so there is no display.", TextPosition.Center); DrawOnPricePanel = hold; } } }
private void CompositionTargetRendering(object sender, EventArgs e) { Plot1.InvalidatePlot(true); }
/// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { // Use this method for calculating your indicator values. Assign a value to each // plot below by replacing 'Close[0]' with your own formula. if (CurrentBar < 10) { return; } if (High[2] < High[3] && High[1] < High[3]) { // Fractal type 1 if (High[5] < High[3] && High[4] < High[3]) { upFractal = High[3]; } // Fractal type 2 else if (High[6] < High[3] && High[5] < High[3] && High[4] == High[3]) { upFractal = High[3]; } // Fractal type 3, 4 else if (High[7] < High[3] && High[6] < High[3] && High[5] == High[3] && High[4] <= High[3]) { upFractal = High[3]; } // Fractal type 5 else if (High[8] < High[3] && High[7] < High[3] && High[6] == High[3] && High[5] < High[3] && High[4] == High[3]) { upFractal = High[3]; } // Fractal type 6 else if (High[8] < High[3] && High[7] < High[3] && High[6] == High[3] && High[5] == High[3] && High[4] < High[3]) { upFractal = High[3]; } // Fractal type 7 else if (High[9] < High[3] && High[8] < High[3] && High[7] == High[3] && High[6] < High[3] && High[5] == High[3] && High[4] < High[3]) { upFractal = High[3]; } } if (Low[2] > Low[3] && Low[1] > Low[3]) { // Fractal type 1 if (Low[5] > Low[3] && Low[4] > Low[3]) { downFractal = Low[3]; } // Fractal type 2 else if (Low[6] > Low[3] && Low[5] > Low[3] && Low[4] == Low[3]) { downFractal = Low[3]; } // Fractal type 3, 4 else if (Low[7] > Low[3] && Low[6] > Low[3] && Low[5] == Low[3] && Low[4] >= Low[3]) { downFractal = Low[3]; } // Fractal type 5 else if (Low[8] > Low[3] && Low[7] > Low[3] && Low[6] == Low[3] && Low[5] > Low[3] && Low[4] == Low[3]) { downFractal = Low[3]; } // Fractal type 6 else if (Low[8] > Low[3] && Low[7] > Low[3] && Low[6] == Low[3] && Low[5] == Low[3] && Low[4] > Low[3]) { downFractal = Low[3]; } // Fractal type 7 else if (Low[9] > Low[3] && Low[8] > Low[3] && Low[7] == Low[3] && Low[6] > Low[3] && Low[5] == Low[3] && Low[4] > Low[3]) { downFractal = Low[3]; } } if (upFractal != 0) { Plot0.Set(upFractal); } if (downFractal != 0) { Plot1.Set(downFractal); } if (Math.Abs(Math.Abs(upFractalSeries[0]) - Math.Abs(upFractalSeries[1])) <= 0.0001) { upFractalSeries[0] = upFractalSeries[1]; } else { upFractalSeries[0] = upFractal; } if (Math.Abs(Math.Abs(downFractalSeries[0]) - Math.Abs(downFractalSeries[1])) <= 0.0001) { downFractalSeries[0] = downFractalSeries[1]; } else { downFractalSeries[0] = downFractal; } }
private void timer_Tick(object sender, EventArgs e) { Plot1.InvalidatePlot(true); }
private void btn_Serial_Refresh_Click(object sender, RoutedEventArgs e) { Serial_Add_Element(); Plot1.InvalidatePlot(true); }
private void LoadButton_Click(object sender, RoutedEventArgs e) { try { OpenFileDialog load = new OpenFileDialog(); load.Filter = "CSV|*.csv|Log|*.log"; string title = ""; if ((bool)load.ShowDialog()) { //Plot1.ResetAllAxes(); Plot1.Series.Clear(); foreach (var p in pingResults._collection) { p.Points.Clear(); } pingResults._collection.Clear(); if (load.FilterIndex == 2) { XmlSerializer mySerializer = new XmlSerializer(typeof(ResultsCollection)); FileStream myFileStream = new FileStream(load.FileName, FileMode.Open); // Call the Deserialize method and cast to the object type. pingResults = (ResultsCollection)mySerializer.Deserialize(myFileStream); } else { var f = File.OpenRead(load.FileName); var stream = new StreamReader(f); string header = stream.ReadLine(); while (header.TrimStart().StartsWith("//")) { title += header; header = stream.ReadLine(); // VESC MOnitor first line is a summary/comment } var columns = header.Split(','); int columnCount = columns.Count(); int lineNumber = 0; int hasTime = -1; if (columns[0].ToUpper().Contains("TIME")) { hasTime = 0; } if (columns.Contains("TimePassedInMs")) { hasTime = Array.IndexOf(columns, "TimePassedInMs"); } while (!stream.EndOfStream) { var line = stream.ReadLine(); int i = 0; int t = 0; if (hasTime != -1) { double d; double.TryParse(line.Split(',')[hasTime], out d); t = (int)d; } foreach (var c in line.Split(',')) { double d = 0; if (i == hasTime) { i++; continue; // don't graph the timestamp } if (double.TryParse(c, out d)) { PingResult temp; if (hasTime != -1) { temp = pingResults.Add(columns[i], d, t / 1000.0); } else { temp = pingResults.Add(columns[i], d, lineNumber++); } if (temp != null) { Plot1.Series.Add(temp.Line); temp.Line.ItemsSource = temp.Points; } } i++; } //if (lineNumber % columnCount==0) //Plot1.InvalidatePlot(true); } } /*foreach (var p in pingResults._collection) * EnableDisableSeries(p, true);*/ Plot1.InvalidatePlot(true); this.Title = Path.GetFileName(load.FileName) + title; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }