CountIf Example [SOLVED]
- Angelina MultiСharts
- Posts: 260
- Joined: 28 Dec 2016
- Has thanked: 28 times
- Been thanked: 66 times
Re: CountIf Example [SOLVED]
Hello GTrader,
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
public class CountIF_Ex : IndicatorObject
{
public CountIF_Ex(object _ctx):base(_ctx)
{
Length = 9;
}
private IPlotObject plot1;
protected override void Create()
{
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
}
[Input]
public int Length { get; set; }
ISeries<bool> condition;
protected override void StartCalc()
{
condition = new Lambda<bool>(_bn => Bars.Close[_bn] > Bars.Open[_bn]);
}
protected override void CalcBar()
{
plot1.Set(Function._CountIf.CountIF(condition, Length));
}
}
}