Adding series and non series integers  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
beggar
Posts: 27
Joined: 22 Sep 2016

Adding series and non series integers

Postby beggar » 12 Feb 2017

I am trying to create an Aroon indictor using the ExtremeFC function. I tested the function with an indicator and it seems to work. I tried to create an Aroon indicator and I am getting an error that reads " Operator "-" cannot be applied to operands of type "int" and Powerlanguage.VariableSeries<int>". It looks like I am trying to add a regular integer to a series integer. Is there a way I can accomplish this? The error is down on line 62

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;

namespace PowerLanguage.Indicator{
public class Aroon : IndicatorObject {


private ExtremesFC m_extremesfc;

private IPlotObject Plot1;

private VariableSeries<Double> m_oextremeval { get; set; }

private VariableSeries<int> m_oextremebarraw { get; set; }

private VariableSeries<int> m_aroonup { get; set; }


public Aroon(object _ctx):base(_ctx){
length = 10;
hilo = 1;


}

public ISeries<Double> price { get; set; }

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

[Input]
public Int32 hilo { get; set; }





protected override void Create() {

m_extremesfc = new Function.ExtremesFC(this);

m_oextremeval = new VariableSeries<Double>(this);

m_oextremebarraw = new VariableSeries<int>(this);

m_aroonup = new VariableSeries<int>(this);

Plot1 =
AddPlot(new PlotAttributes("Aroonup", 0, Color.Yellow,
Color.Empty, 0, 0, true));
}
protected override void StartCalc() {
// assign inputs

m_extremesfc.length = length +1;
m_extremesfc.hilo = hilo;
m_extremesfc.price = Bars.High;
m_extremesfc.oextremeval = m_oextremeval;
m_extremesfc.oextremebarraw = m_oextremebarraw;


}
protected override void CalcBar(){

m_aroonup = 100 * ((length - m_oextremebarraw) / length) ;



//m_aroonup = 100 * ((Length - HighestBar(High, Length+1)) / Length);
// 100 * ( Length - ExtremeHighBar ) / Length
Plot1.Set(m_aroonup[0]);
}

}

}



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

Re: Adding series and non series integers  [SOLVED]

Postby JoshM » 13 Feb 2017

I think you need to replace the following..

Code: Select all

m_aroonup = 100 * ((length - m_oextremebarraw) / length) ;
with..

Code: Select all

m_aroonup.Value = 100 * ((length - m_oextremebarraw[0]) / length) ;
If I correctly glanced over your code.

beggar
Posts: 27
Joined: 22 Sep 2016

Re: Adding series and non series integers

Postby beggar » 13 Feb 2017

Josh the Great!! It looks like it worked. I tried checking just the output for the extreme bar and the multicharts.net values seem to be one bar behind regular multicharts

By the way awesome webpage. I have spent the last couple of weeks trying to learn C# and I ran across your page.


Return to “MultiCharts .NET”