How to access Tick-based MarketSeries in Time-based chart

Created at 19 Apr 2020, 23:22
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!
MI

mizo.rakkii

Joined 19.04.2020

How to access Tick-based MarketSeries in Time-based chart
19 Apr 2020, 23:22


I have an indicator which works accurately only in 1-tick chart. However, I would like to use it in a cBot for M1 chart.

Is there any idea to get tick-based MarketSeries?

 

I found someone faced to the same problem in the below url, but there is no solution on this page.

 


@mizo.rakkii
Replies

PanagiotisCharalampous
21 Apr 2020, 09:39

Hi mizo.rakkii,

If you need to get tick data of a symbol you can use MarketData.GetTicks(Symbol) method.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

mizo.rakkii
22 Apr 2020, 18:56

Hi PanagiotisCharalampous ,

Thank you for replying.

I tried your command, but It didn't work.
To apply tick data to simple moving average, I used the method as follows.

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

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class cBot1 : Robot
    {
        private SimpleMovingAverage sma1;

        protected override void OnTick()
        {
           sma1 = Indicators.SimpleMovingAverage(MarketData.GetTicks(Symbol.Name),20);
           ............
        }
    }
}

 I used GetTicks(Symbol.Name) method because I couldn't compile it with GetTicks(Symbol) method.

What is the problem on my code?
 

Best Regards,

 mizo.rakkii


@mizo.rakkii

PanagiotisCharalampous
23 Apr 2020, 08:21

Hi mizo.rakkii,

You can not use Ticks as an input to a SimpleMovingAverage. The method takes only DataSeries as an input. The only workaround to this is to get the timeframe as a parameter. See below an example

        [Parameter()]
        public TimeFrame Timeframe { get; set; }

        protected override void OnStart()
        {
            var sma1 = Indicators.SimpleMovingAverage(MarketData.GetBars(Timeframe, Symbol.Name).ClosePrices, 20);
        }

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

mizo.rakkii
29 Apr 2020, 15:01

Hi PanagiotisCharalampous ,

Thank you for your advice.

I was able to complete the accurate system with your bright solution.

 

Best Regards,

mizo.rakkii


@mizo.rakkii

slmberglund
18 Jun 2020, 18:18

RE:

Hi Panagiotis,

To clarify:

- Would this solution enable me to reference the t50 "time"series in a robot trading on the t100 chart?

- If not, is there any way I could build such capability in my robot?

- Is Spotware planning to release the capability to reference different tick-series bars in the robots/indicators?

Many thanks

Markus 

 

PanagiotisCharalampous said:

Hi mizo.rakkii,

You can not use Ticks as an input to a SimpleMovingAverage. The method takes only DataSeries as an input. The only workaround to this is to get the timeframe as a parameter. See below an example

        [Parameter()]
        public TimeFrame Timeframe { get; set; }

        protected override void OnStart()
        {
            var sma1 = Indicators.SimpleMovingAverage(MarketData.GetBars(Timeframe, Symbol.Name).ClosePrices, 20);
        }

Best Regards,

Panagiotis 

Join us on Telegram

 


@slmberglund

PanagiotisCharalampous
19 Jun 2020, 09:01

Hi Markus,

Would this solution enable me to reference the t50 "time"series in a robot trading on the t100 chart?

Yes

 Is Spotware planning to release the capability to reference different tick-series bars in the robots/indicators?

You can already do it with the method described above. The only thing missing at the moment is to add these timeframes in the Timeframe class. 

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous