0
Not a bug

Trouble using DynamicLevels indicator in chart strategy

Mauricio Lopez 1 year ago updated by Андрей Ринас2 (ATAS developer) 1 year ago 3

Hello, I am having trouble updating a DynamicLevels indicator in my custom chart strategy.

I declare it like this:

private readonly DynamicLevels levels = new DynamicLevels();

Then I try to keep it updated in two different ways that both fail.

First I add it in my strategy's constructor like you normally do with indicators in a chart strategy:

        public DynamicLevelsStrategy() : base()
        {
            Add(levels);
            ...

Which gives me the following error when I try to add the strategy in ATAS:

System.NullReferenceException: Object reference not set to an instance of an object.
   at ATAS.Indicators.Technical.DynamicLevels.OnCalculate(Int32 bar, Decimal value)
   at ATAS.Indicators.ExtendedIndicator.Calculate(Int32 bar, Decimal value)
   at ATAS.Indicators.BaseIndicator.RecalculateValues()
   at ATAS.Indicators.BaseIndicator.set_SourceDataSeries(IDataSeries value)
   at ATAS.Indicators.BaseIndicator.set_SourceDataSeries(IDataSeries value)
   at ATAS.Indicators.ExtendedIndicator.OnDataProviderChanged(IIndicatorDataProvider oldDataProvider, IIndicatorDataProvider newDataProvider)
   at ATAS.Strategies.Chart.ChartStrategy.OnDataProviderChanged(IIndicatorDataProvider oldDataProvider, IIndicatorDataProvider newDataProvider)
   at ATAS.Indicators.BaseIndicatorsManager.OnLoad(String settings, IIndicatorDataProvider dataProvider)
   ...

The second thing I try is to not add the indicator in the constructor, but to call the calculate function by hand, like this:

        protected override void OnCalculate(int bar, decimal value)
{
levels.Calculate(bar, value); ...

And this gives the following error (again, when trying to add the strategy):

System.ArgumentException: ??? ?????????? ?????????? ????? ?? ????????.
Parameter name: value
   at ATAS.Indicators.BaseIndicator.set_SourceDataSeries(IDataSeries value)
   at ATAS.Indicators.Extensions.Calculate(Indicator indicator, Int32 bar, Decimal value)
   at AUBStrategies.DynamicLevelsStrategy.OnCalculate(Int32 bar, Decimal value)
   at ATAS.Indicators.ExtendedIndicator.Calculate(Int32 bar, Decimal value)
   at ATAS.Indicators.BaseIndicator.RecalculateValues()
   at ATAS.Indicators.BaseIndicator.set_SourceDataSeries(IDataSeries value)
   at ATAS.Indicators.ExtendedIndicator.OnDataProviderChanged(IIndicatorDataProvider oldDataProvider, IIndicatorDataProvider newDataProvider)
   at ATAS.Strategies.Chart.ChartStrategy.OnDataProviderChanged(IIndicatorDataProvider oldDataProvider, IIndicatorDataProvider newDataProvider)
   at ATAS.Indicators.BaseIndicatorsManager.OnLoad(String settings, IIndicatorDataProvider dataProvider)
   ...

Where "??? ?????????? ?????????? ????? ?? ????????" appears as "Для индикатора необходима серия со свечками" in the user interface.

Thanks a lot for whatever clarity you can give me!

Under review

Could you please provie us with sample of your code and we will do changes in it.

If your question is still active, please provide us with sample of your code. Otherwise this ticket will be closed automatically in 2 days.

Not a bug

Ticket has been closed automatically. Please create new ticket if you have any questions.