Multi-timeframe robots/indicators

10 Feb 2018, 15:28Multi-timeframe robots/indicators#21
irmscher9posts: 144since: 22 Dec 2016

The code above seem doesn;t work...

12 Feb 2018, 11:35#22
Panagiotis Charalampousposts: 2821since: 13 Jan 2017

Hi irmscher9,

Why do you say that the code is not working? Do you get an exception? Do you get unexpected results? If you give us more information, it will be easier for us to help you.

Best Regards,

Panagiotis


Head of Community Management at cTrader
25 Feb 2018, 22:26#23
Dagfxposts: 6since: 04 Dec 2017

Whenever I install the Multi-timeframe moving average, the ctrader keeps disconnecting and reconnecting and so on...Till I remove the indicator all of it. What's the problem?

26 Feb 2018, 11:17#24
Panagiotis Charalampousposts: 2821since: 13 Jan 2017

Hi daguerfi,

When did you observe this behavior? Was it during a weekend?

Best Regards,

Panagiotis


Head of Community Management at cTrader
26 Mar 2018, 23:16RE: Indicator example: Multi-timeframe moving average#25
rmsulemanposts: 3since: 17 Mar 2017

I am trying to install the code using calgo but I get the following error when I try to build it. Please let me know how to fix it. Thanks

 

cAlgo_Development said:

In this example, we output moving averages with the same period for different timeframes on a single chart:

 

Source code:

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC)]
    public class MultiTF_MA : Indicator
    {
        [Parameter(DefaultValue = 50)]
        public int Period { get; set; }

        [Output("MA", Color = Colors.Yellow)]
        public IndicatorDataSeries MA { get; set; }

        [Output("MA5", Color = Colors.Orange)]
        public IndicatorDataSeries MA5 { get; set; }

        [Output("MA10", Color = Colors.Red)]
        public IndicatorDataSeries MA10 { get; set; }

        private MarketSeries series5;
        private MarketSeries series10;

        private MovingAverage ma;
        private MovingAverage ma5;
        private MovingAverage ma10;

        protected override void Initialize()
        {
            series5 = MarketData.GetSeries(TimeFrame.Minute5);
            series10 = MarketData.GetSeries(TimeFrame.Minute10);

            ma = Indicators.MovingAverage(MarketSeries.Close, Period, MovingAverageType.Triangular);
            ma5 = Indicators.MovingAverage(series5.Close, Period, MovingAverageType.Triangular);
            ma10 = Indicators.MovingAverage(series10.Close, Period, MovingAverageType.Triangular);
        }

        public override void Calculate(int index)
        {
            MA[index] = ma.Result[index];

            var index5 = GetIndexByDate(series5, MarketSeries.OpenTime[index]);
            if (index5 != -1)
                MA5[index] = ma5.Result[index5];

            var index10 = GetIndexByDate(series10, MarketSeries.OpenTime[index]);
            if (index10 != -1)
                MA10[index] = ma10.Result[index10];
        }


        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            for (int i = series.Close.Count - 1; i > 0; i--)
            {
                if (time == series.OpenTime[i])
                    return i;
            }
            return -1;
        }
    }
}

 

 

27 Mar 2018, 09:27#26
Panagiotis Charalampousposts: 2821since: 13 Jan 2017

Hi rmsuleman,

I tried to build the indicator and I have no problems. However the error message references Robots folder which is used for cBots. Am I missing something?

Best Regards,

Panagiotis


Head of Community Management at cTrader
03 Nov 2018, 23:41RE:#27
Vitali Gajdabrusposts: 30since: 20 Aug 2015

Panagiotis Charalampous said:

Hi Panagiotis...

How to use timeframe Tick: t1, t2 ... t50 and others?

series_t5 = MarketData.GetSeries(TimeFrame.Tick5); ???

 

04 Nov 2018, 18:24RE:#28
Vitali Gajdabrusposts: 30since: 20 Aug 2015

Panagiotis Charalampous said:

How to do it?

double dY = 0.5 * args.ChartArea.Height;
double dX0 = 0.25 * args.ChartArea.Width;
double dX1 = 0.75 * args.ChartArea.Width;
Chart.DrawTrendLine("test", dX0, dY, dX1, dY, Color.Red);

 

05 Nov 2018, 07:29RE: RE:#29
Vitali Gajdabrusposts: 30since: 20 Aug 2015

Vitali Gajdabrus said:

...

Chart.DrawTrendLine("test", dX0, dY, dX1, dY, Color.Red);

I have already solved this problem.

 Thank.

12 Dec 2018, 20:09RE:#30
oliveira.phcposts: 21since: 15 Nov 2018

cAlgo_Development said:

We added new functionality to cAlgo - the ability for robots and indicators to retrieve OHLCV data for multiple timeframes. This can be done using the MarketData.GetSeries method:

MarketSeries m5series = MarketData.GetSeries(TimeFrame.Minute5);

We recommend to call the GetSeries method in the Robot.OnStart() or the Indicator.Initialize() methods.

When the series for a specified timeframe is received, you can access the series values or build an indicator based on that series:

private MarketSeries m10;
private MovingAverage ma;

protected override void OnStart()
{
    m10 = MarketData.GetSeries(TimeFrame.Minute10);
    ma = Indicators.SimpleMovingAverage(m10.High, 14);
}

The new version of our Demo cTrader and cAlgo is released and can be downloaded from www.spotware.com

Update: Backtesting of Multi-timeframe robots is supported now.

Hello again.

Is it technically impossible to have multiple timeframes of type "tick"? If not, I will make a suggestion for it.

Kind regards,

Paulo Oliveira