Bars.CurrentBar...PROBLEM

Questions about MultiCharts .NET and user contributed studies.
turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Bars.CurrentBar...PROBLEM

Postby turbofib » 05 Aug 2014

Code: Select all


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

namespace PowerLanguage.Indicator{
public class canc : IndicatorObject {
public canc(object _ctx):base(_ctx)
{
Contabarre=3;
}

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

private IPlotObject plot1;

private Function.CANC_ Test;

private int Flag=0;


protected override void Create() {
// create variable objects, function objects, plot objects etc.
plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
Test = new Function.CANC_(this);
}
protected override void StartCalc() {
// assign inputs
Test.contabarre = Contabarre;
}
protected override void CalcBar(){
// indicator logic

}
}
}

using System;
using System.Drawing;
using System.Linq;


namespace PowerLanguage
{
namespace Function
{
public sealed class CANC_ : FunctionSeries<System.Int32>
{
public CANC_(CStudyControl _master) : base(_master) { }
public CANC_(CStudyControl _master, int _ds) : base(_master, _ds) { }

public int contabarre { get; set; }

......
.....
protected override void StartCalc()
{
// assign inputs
}

protected override System.Int32 CalcBar()
{


Output.WriteLine("OUT CICLO ** bars {0}" , Bars.CurrentBar );

....
....
}
OUTPUT:
OUT CICLO ** bars 1
OUT CICLO ** bars 1
OUT CICLO ** bars 2
OUT CICLO ** bars 3
OUT CICLO ** bars 4
OUT CICLO ** bars 5
OUT CICLO ** bars 1
OUT CICLO ** bars 2
OUT CICLO ** bars 3
OUT CICLO ** bars 4
OUT CICLO ** bars 5
OUT CICLO ** bars 6
OUT CICLO ** bars 7
OUT CICLO ** bars 8
OUT CICLO ** bars 9
OUT CICLO ** bars 10
OUT CICLO ** bars 11
OUT CICLO ** bars 12
OUT CICLO ** bars 13
OUT CICLO ** bars 14
OUT CICLO ** bars 15
OUT CICLO ** bars 16
OUT CICLO ** bars 17
OUT CICLO ** bars 18
OUT CICLO ** bars 19
OUT CICLO ** bars 20
OUT CICLO ** bars 21
OUT CICLO ** bars 22
OUT CICLO ** bars 23
OUT CICLO ** bars 24
OUT CICLO ** bars 25
OUT CICLO ** bars 1 ================> WHY? count of the bars will reset after a certain number
OUT CICLO ** bars 2
OUT CICLO ** bars 3
OUT CICLO ** bars 4
OUT CICLO ** bars 5
OUT CICLO ** bars 6
OUT CICLO ** bars 7
OUT CICLO ** bars 8
OUT CICLO ** bars 9

PROBLEM : the count of the bars will reset after a certain number
(if I remember right .. this was the problem in the first versions in powerlanguage (not mc.net), then the problem was solved

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Bars.CurrentBar...PROBLEM

Postby Henry MultiСharts » 05 Aug 2014

Hello turbofib,

The calculation is re-initiated because of max bars back auto adjustment. More info here: Barsback.


Return to “MultiCharts .NET”