/* Usage: run in Execute: * public override void Execute(BarHistory bars, int idx) * { * Color col = new Color(); * if (idx >= bars.Count-100) * { * if ( bars.Close[idx] > bars.Close[idx - 50]) * col = Color.Green; * else col = Color.Red; * * DrawLinRegChannel(idx, bars.AveragePriceHL, 45, 2, Color.FromArgb(30, col), PlotStyles.Line, 2); * } * } */ public static void DrawLinRegChannel(this UserStrategyBase obj, int bar, TimeSeries series, int period, double width, Color color, PlotStyles style, int line) { double Slope = (period - 1) * LRSlope.Series(series, period)[bar]; double Intercept = LR.Series(series, period)[bar]; width *= StdError.Series(series, period)[bar]; obj.DrawLine(bar - (period - 1), Intercept - Slope - width, bar, Intercept - width, color, 1); obj.DrawLine(bar - (period - 1), Intercept - Slope + width, bar, Intercept + width, color, 1); }
public void CopyStdio(DataHash hc) { var stderrfile = Cache.OutputCache.MakePath(hc.Hash, CompilerCacheBase.F_Stderr); var stdoutfile = Cache.OutputCache.MakePath(hc.Hash, CompilerCacheBase.F_Stdout); StdOutput.Clear(); StdError.Clear(); StdOutput.Append(File.ReadAllText(stdoutfile)); StdError.Append(File.ReadAllText(stderrfile)); }
protected override void Create() { m_linearregvalue1 = new LinearRegValue(this); m_stderror1 = new StdError(this); m_linregvalue = new VariableSeries <Double>(this); m_lowerband = new VariableSeries <Double>(this); m_upperband = new VariableSeries <Double>(this); Plot1 = AddPlot(new PlotAttributes("UpperBand", 0, Color.Yellow, Color.Empty, 0, 0, true)); Plot2 = AddPlot(new PlotAttributes("LowerBand", 0, Color.Blue, Color.Empty, 0, 0, true)); Plot3 = AddPlot(new PlotAttributes("MidLine", 0, Color.Gray, Color.Empty, 0, 0, true)); }
public string GetDebugInfo() { var sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine("Debugging Information:"); sb.AppendLine("----------------------"); sb.AppendLine($"Executed command: {ExecutedCommand}"); if (Process.HasExited) { sb.AppendLine($"Exit code: {Process.ExitCode}"); } sb.AppendLine($"StdOutput: {StdOutput.ToString()}"); sb.AppendLine($"StdError: {StdError.ToString()}"); sb.AppendLine($"Exception: {Exception?.Message}"); return(sb.ToString()); }
private void ErrorDataReceived(object sender, DataReceivedEventArgs e) { if (e.Data != null) { if (OnStderrLine != null) { OnStderrLine(e.Data); } if (StdError.LinesCount >= MAX_BUFFER_LINE_COUNT) { StdError.PopFront(); } StdError.PushBack(e.Data); } else { ErrorWaitHandle.Set(); } }
public void AppendToStdError(string err) => StdError.AppendLine(err);
/// <summary> /// Launch programm in separate process /// </summary> /// <param name="parameters"></param> /// <param name="workingDir"></param> /// <param name="msecLockTimeout">if == 0, then parent process does not lock</param> /// <returns></returns> private CmdResult RunProcess( string parameters = "", string workingDir = null, int msecLockTimeout = 0) { CmdResult result = null; if (SystemProcessObject != null) { throw new ProcessAlreadyStartedException(); } var process = new Process(); try { var startInfo = new ProcessStartInfo { WindowStyle = ProcessWindowStyle.Hidden, FileName = QuoteString(AppPath), Arguments = parameters, UseShellExecute = false, RedirectStandardError = true, RedirectStandardInput = true, RedirectStandardOutput = true, CreateNoWindow = true, StandardOutputEncoding = Encoding.GetEncoding(866), StandardErrorEncoding = Encoding.GetEncoding(866) }; if (workingDir != null) { startInfo.WorkingDirectory = workingDir; } process.StartInfo = startInfo; OutputWaitHandle = new AutoResetEvent(msecLockTimeout == 0); ErrorWaitHandle = new AutoResetEvent(msecLockTimeout == 0); // Capture stdout data process.OutputDataReceived += this.OutputDataReceived; // Capture stderr data process.ErrorDataReceived += this.ErrorDataReceived; CurrentCommandLine = AppPath + " " + parameters; // Process process's execution end process.EnableRaisingEvents = true; process.Exited += this.Exited; process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); SystemProcessObject = process; } catch (Exception ex) { process.Dispose(); throw; } if (msecLockTimeout != 0) { if (SystemProcessObject.WaitForExit(msecLockTimeout) && OutputWaitHandle.WaitOne(msecLockTimeout) && ErrorWaitHandle.WaitOne(msecLockTimeout)) { int exitCode = SystemProcessObject.ExitCode; // Call WaitForExit() once more to ensure stdout and stderr are read to end (see Remarks section in msdn doc for this method) SystemProcessObject.WaitForExit(); SystemProcessObject.Dispose(); result = new CmdResult { ExitCode = exitCode, StandardError = StdError.ToString(), StandardOutput = StdOut.ToString() }; StdError.Clear(); StdOut.Clear(); SystemProcessObject = null; } else { Kill(); throw new Exception("Process did not exit in a given timeout"); } } return(result); }