CountIf Example  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
GTrader
Posts: 83
Joined: 30 Oct 2012
Has thanked: 24 times
Been thanked: 8 times

CountIf Example

Postby GTrader » 24 May 2017

Can you give an example of how to use the CountIf function?

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: CountIf Example  [SOLVED]

Postby Angelina MultiСharts » 25 May 2017

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));
}
}
}


Return to “MultiCharts .NET”