Replies

ericsson
17 Jun 2020, 13:27 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi ericsson,

You can send me the cBot with source code and the csv file at community@spotware.com and we will have a look.

Best Regards,

Panagiotis 

Join us on Telegram

Hello Panagiotis,
I think I found the cause to my problem. My TWAP indicator seems not to be working on historical data (on live data everything is fine)
When I stop the backtest I'm getting these messages in the log."time weighted" as in the indicator should reset on the first bar of the day (00:00)
"average price" as in ohlc4 data series



Looks like I'm having an issue both in the initialize and calculate function.

 

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TWAP : Indicator
    {

        private SimpleMovingAverage SMA;
        public IndicatorDataSeries ohlc4, price;
        public double cumPrice;

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

        [Parameter(DefaultValue = 11)]
        public int SmaLen { get; set; }

        [Parameter(DefaultValue = 20)]
        public int EnvOffset { get; set; }

        [Output("TWAP", LineColor = "Green", Thickness = 1)]
        public IndicatorDataSeries twap { get; set; }

        [Output("SMA", LineColor = "Blue", Thickness = 1)]
        public IndicatorDataSeries sma { get; set; }

        [Output("Envelope High", LineStyle = LineStyle.LinesDots, LineColor = "Green", Thickness = 1)]
        public IndicatorDataSeries HighEnv { get; set; }

        [Output("Envelope Low", LineStyle = LineStyle.LinesDots, LineColor = "Green", Thickness = 1)]
        public IndicatorDataSeries LowEnv { get; set; }

        protected override void Initialize()
        {

            //cumPrice = 0.0;

            ohlc4 = CreateDataSeries();
            price = CreateDataSeries();
        }


        public override void Calculate(int index)
        {
            SMA = Indicators.SimpleMovingAverage(Source, SmaLen);

            ohlc4[index] = (Bars.OpenPrices.LastValue + Bars.HighPrices.LastValue + Bars.LowPrices.LastValue + Bars.ClosePrices.LastValue) / 4;
            price[index] = ohlc4[index];

            int per = 0;
            cumPrice = 0.0;
            int day = Bars.OpenTimes[index].Day;

            while (Bars.OpenTimes[index - per].Day == day)
            {
                per++;
                ohlc4[index] = (Bars.OpenPrices.LastValue + Bars.HighPrices.LastValue + Bars.LowPrices.LastValue + Bars.ClosePrices.LastValue) / 4;
                cumPrice += price[index - per];
            }

            twap[index] = cumPrice / per;
            sma[index] = SMA.Result[index];
            HighEnv[index] = twap[index] + EnvOffset;
            LowEnv[index] = twap[index] - EnvOffset;
        }
    }
}

Sorry if the code is a mess - I'm learning...
Ericsson


@ericsson

ericsson
16 Jun 2020, 13:28 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi ericsson,

Thanks for your nice words! If you can provide more information about the CSV issue, we can have a look at this as well.

Best Regards,

Panagiotis 

Join us on Telegram

Nothing going on really, Panagiotis
so it's kinda hard to give you more information. Looks like my CSV is getting recognized because the dates in cTrader immediatly jump
to the start and end date of the CSV. When I start my algo it's just doing nothing as if the backtester has problems loading the bars from
the CSV. I can stop the backtest and keep on going, so there's no error code or something


@ericsson

ericsson
15 Jun 2020, 11:01

RE:

PanagiotisCharalampous said:

Hi ericsson,

Please note that this is a Beta so issues are expected.

Best Regards,

Panagiotis 

Join us on Telegram

No worries!
I was just wondering because I'm pretty sure the import worked already

I'm patient because I liked what I've seen so far with cTrader, I think
you guys are doing a great job!


@ericsson

ericsson
13 Jun 2020, 12:25

Something seems to be really off with the backtesting engine lately.

CSV-Import doesn't work anymore either...


@ericsson

ericsson
11 Jun 2020, 13:03

RE:

PanagiotisCharalampous said:

Hi ericsson,

Thanks for reporting this. We are aware of the issue and we will fix it in the next hotfix for 3.8.

Best Regards,

Panagiotis 

Join us on Telegram

 

Thank you Panagiotis!


@ericsson