Syntax
public static void DrawLinRegChannel(this WealthScript obj, int bar, DataSeries ds, int period, double width, Color color, LineStyle style, int line)
public static void DrawLinRegChannel(this WealthScript obj, int bar, DataSeries series, int period, Color color, LineStyle style, int line)
public static void DrawLinRegChannel(this WealthScript obj, int bar, DataSeries series, int period, double width, Color color, LineStyle style, int line, StdDevCalculation sdCalc)
public void DrawLinRegChannel( WealthScript obj, int bar, DataSeries ds, int period, double width, Color color, LineStyle style, int line)
public void DrawLinRegChannel(int bar, DataSeries series, int period, Color color, LineStyle style, int line)
public void DrawLinRegChannel(int bar, DataSeries series, int period, double width, Color color, LineStyle style, int line, StdDevCalculation sdCalc)
Parameter Description
bar | Ending bar |
ds | Source data series |
period | Lookback period |
width | Channel line width |
color | Channel line color (System.Color) |
style | Channel line style (WealthLab.LineStyle) |
sdCalc | Select between the standard deviation of a sample and that of an entire population |
Description
Allows to code a linear regression slope channel. Credit for this method goes to
Giorgio Beltrame.
Two overloads added by Robert Sucher: the first replicates the Manual Drawing tool for Regression Channel if Close is used as series, the second defines Channel width by Standard Deviations instead of Standard Error.
Look at an example below:
Example
Example using C# extension methods:
using System;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
public class LinRegChannelsDemo: WealthScript
{
protected override void Execute()
{
Color col = new Color();
for(int bar = Bars.Count-100; bar < Bars.Count; bar++)
{
if( Closebar > Closebar-50 )
col = Color.Green; else col = Color.Red;
this.DrawLinRegChannel( bar, AveragePrice.Series(Bars), 45, 2, Color.FromArgb(30, col), LineStyle.Solid, 1 );
}
}
}
Legacy syntax example:
using System;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components; // DrawLinRegChannel here
public class LinRegChannelsDemo: WealthScript
{
protected override void Execute()
{
Calculate calc = new Calculate(this); // pass WealthScript as "this"
Color col = new Color();
for(int bar = Bars.Count-100; bar < Bars.Count; bar++)
{
if( Closebar > Closebar-50 )
col = Color.Green; else col = Color.Red;
calc.DrawLinRegChannel( bar, AveragePrice.Series(Bars), 45, 2, Color.FromArgb(30, col), LineStyle.Solid, 1 );
}
}
}