Fourier Transform Indicator is not updated with incoimng new bars

Created at 08 Mar 2020, 13:40
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
SY

sylwester.guzek

Joined 05.01.2019

Fourier Transform Indicator is not updated with incoimng new bars
08 Mar 2020, 13:40


Hello,

I need some help with running Fourier Transform indicator  in cBot  ( https://ctrader.com/algos/indicators/show/1971 ) . The problem is that the indicator is executed only one time on the beginning. Later on each new bar indicator values are not updated. I tried to force re-calculation of indicator calling Calculate() but it does not work.

Below code for problem replication, I will be appreciated for any advice.

Consider to tune Period value to be lower than the number of bars loaded by bot. With H1 it was around 119.

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NEWFurierSandbox : Robot
    {

        [Parameter()]
        public DataSeries SourceSeries { get; set; }

        [Parameter(DefaultValue = 1, MinValue = 0)]
        public int Volume { get; set; }

        [Parameter("Period", DefaultValue = 100)]
        public int Npast { get; set; }

        [Parameter("Projection", DefaultValue = 10)]
        public int Nfut { get; set; }

        [Parameter("N° Harmonics", DefaultValue = 15)]
        public int Nharm { get; set; }

        [Parameter("Tolerance in Hz", DefaultValue = 1E-05)]
        public double FreqTOL { get; set; }

        [Parameter("Show Starting and Ending Points", DefaultValue = true)]
        public bool points { get; set; }

        private const string label = "NEW FT Sandbox";
        private FourierTransform ft;

        protected override void OnStart()
        {
            Print("initialization: ", Npast, " ", Nfut, " ", Nharm, " ", FreqTOL, " ", SourceSeries,
            " ", points);
            ft = Indicators.GetIndicator<FourierTransform>(Npast, Nfut, Nharm, FreqTOL, SourceSeries, points);
        }

        protected override void OnBar()
        {
            for (int i = 0; i < 200; i++)
            {
                //ft.Calculate(i);
                Print(i, " >> ", ft.fit[i], " # ", ft.proj[i], " # ", SourceSeries.Last(i));
                //ft.fit[i] = 0;
            }

        }

    }
}

 


@sylwester.guzek
Replies

firemyst
10 Mar 2020, 01:49

 

If you read what the author of the indicator wrote:

"To set starting and ending points, use, as usual, Shift + Click for the starting point and Ctrl + Click for the endpoint.

If you're applying this on another indicator, remember you should click on the main chart anyway to set the interval."

 

How are you setting the starting and ending points? I don't see anything in your code to do this other than the basic parameter initialization.

Have you tried physically clicking on the chart?


@firemyst