Price_Channel Indicator  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
datamonkey
Posts: 95
Joined: 19 Nov 2013
Has thanked: 39 times
Been thanked: 6 times

Price_Channel Indicator

Postby datamonkey » 02 Feb 2016

Hi,

Would someone be so kind to upload the 'Price_Channel' indicator that comes with MC.NET as I have messed mine up in the Powerlanguage editor and now it won't compile... Oops!

Thanks in advance...

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Price_Channel Indicator  [SOLVED]

Postby JoshM » 03 Feb 2016

Here you go:

Code: Select all

using System;
using System.Drawing;

namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
public class Price_Channel : IndicatorObject
{
private VariableSeries<Double> m_lowerband;

private VariableSeries<Double> m_upperband;

private IPlotObject Plot1;

private IPlotObject Plot2;

public Price_Channel(object ctx) :
base(ctx){
length = 20;
}

[Input]
public int length { get; set; }

[Input]
public int displace { get; set; }

protected override void Create(){
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));
}

protected override void CalcBar(){
m_lowerband.Value = Bars.Low.Lowest(length, 1);
m_upperband.Value = Bars.High.Highest(length, 1);
if (((displace >= 0) || Bars.CurrentBar > Math.Abs(displace))){
Plot1.Set(displace, m_upperband.Value);
Plot2.Set(displace, m_lowerband.Value);
if ((displace <= 0)){
if (this.CrossesUnder(Bars.Low, m_lowerband)){
Alerts.Alert("Price making new low");
}
if (this.CrossesOver(Bars.High, m_upperband)){
Alerts.Alert("Price making new high");
}
}
}
}
}
}

datamonkey
Posts: 95
Joined: 19 Nov 2013
Has thanked: 39 times
Been thanked: 6 times

Re: Price_Channel Indicator

Postby datamonkey » 03 Feb 2016

Here you go:
Many thanks Josh, appreciate it.

I'll try and be more careful with my code in future! :)


Return to “MultiCharts .NET”