Searching for something else than VariableSeries

Questions about MultiCharts .NET and user contributed studies.
Jobauma
Posts: 18
Joined: 16 Apr 2013
Has thanked: 7 times
Been thanked: 1 time

Searching for something else than VariableSeries

Postby Jobauma » 30 Aug 2017

Hi.



This has bothered me for some time. :) How do you store values for only new values when they are applied in a sequence, unlike VariableSeries which do repeat the previous value when nothing new is applied to the variable. I would like to keep some values in a variable without repeats like in this example.

if ( Bars.High[0] > Bars.High[1] ) m_VariableWithoutRepeats = Bars.High[0] // New value is assigned to 0.
// else "no new value gets assigned to 0, and 0 remains as 0."

Next time this condition isn't met, 0 still remains as 0 until the condition actually is met once more, and the value moves to 1, when the new value is assigned to 0.



Any help will be highly appreciated. :)

chi jeongki
Posts: 39
Joined: 29 Nov 2007
Has thanked: 8 times
Been thanked: 2 times

Re: Searching for something else than VariableSeries

Postby chi jeongki » 31 Aug 2017

How about using c# Stack?

Code: Select all

using System.Collections.Generic;


        private IPlotObject plot1;

        private class _HighInfo
        {
            public _HighInfo(int HBar, double HValue)
            {
                HighBar = HBar;
                HighValue = HValue;
            }
            public int HighBar { get; set; }
            public double HighValue { get; set; }
        }

        private Stack<_HighInfo> HighInfo = null;

        protected override void Create()
        {
            plot1 = AddPlot(new PlotAttributes("", EPlotShapes.Line, Color.Red));
            HighInfo = new Stack<_HighInfo>();
        }

        protected override void StartCalc()
        {
            HighInfo.Clear();
        }

        protected override void CalcBar()
        {
            if (Bars.High[0] > Bars.High[1])
            {
                HighInfo.Push(new _HighInfo(Bars.CurrentBar, Bars.High[0]));
            }

            if (HighInfo.Count > 0)
            {
                plot1.Set(HighInfo.ElementAt(0).HighValue);
            }

            for (int i = 0; i < HighInfo.Count; ++i)
            {
                Output.WriteLine("HighInfo: i = {0}, HighBar = {1}, HighValue = {2}",
                    i, HighInfo.ElementAt(i).HighBar, HighInfo.ElementAt(i).HighValue);
            }
            Output.WriteLine("");
        }


Return to “MultiCharts .NET”