make your own Dataseries

Created at 19 Mar 2019, 12:48
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!
TO

TonNcie

Joined 23.01.2019

make your own Dataseries
19 Mar 2019, 12:48


I have to make my own Dataseries to feed it to an indicator, but get stuck somewhere

 

 public class IMySeries : MarketSeries
    {
        public DataSeries High { get; set; }
        public DataSeries Low { get; set; }
        public DataSeries Close { get; set; } 
        public DataSeries TickVolume { get; set; }
.......

Using it

  protected override void OnTick()
        {
            double jo = MySeries.High[1];
            MySeries.High[1]=jo; //this won't work, the set; is not implemented
     .....

It seems the set is not available.
Where am I making the obvious mistake?
Is there a better way to make your own MarketSeries?


@TonNcie
Replies

PanagiotisCharalampous
19 Mar 2019, 12:52

Hi El Antonio,

Can you please post the complete cBot code?

Best Regards,

Panagiotis


@PanagiotisCharalampous

TonNcie
19 Mar 2019, 13:06

RE:

 

using System;
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 Renner : Robot
    {
        private IMySeries MySeries;
        MyOwnIndicator _signalIndicator;

        protected override void OnStart()
        {
            MySeries = new IMySeries(Symbol);
            _signalIndicator = Indicators.GetIndicator<MyOwnIndicator>(MySeries);
        }

        protected override void OnTick()
        {
            double jo = MySeries.High[1];
            MySeries.High[1] = jo;
        }
    }
    public class IMySeries : MarketSeries
    {
        public DataSeries Open { get; set; }
        public DataSeries High { get; set; }
        public DataSeries Low { get; set; }
        public DataSeries Close { get; set; }
        public DataSeries TickVolume { get; set; }
        public DataSeries Median { get; set; }
        public DataSeries Typical { get; set; }
        public DataSeries Weighted { get; set; }
        public DataSeries WeightedClose { get; set; }
        public TimeSeries OpenTime { get; set; }
        public TimeFrame TimeFrame { get; set; }
        public string SymbolCode { get; set; }

        private Symbol symbol;
   
        public IMySeries(Symbol symbol)
        {
            this.symbol = symbol;
        }
    }
}

 


@TonNcie

PanagiotisCharalampous
19 Mar 2019, 14:25

Hi El Antonio,

DataSeries type does not feature a setter, see interface definition below

using System.Reflection;

namespace cAlgo.API
{
    //
    // Summary:
    //     Represents a read only list of values, typically used to represent market price
    //     series. The values are accessed with an array-like [] operator.
    [DefaultMember("Item")]
    public interface DataSeries
    {
        //
        // Summary:
        //     Gets the value in the dataseries at the specified position.
        double this[int index] { get; }

        //
        // Summary:
        //     Gets the last value of this DataSeries.
        //
        // Remarks:
        //     The last value may represent one of the values of the last bar of the market
        //     series, e.g. Open, High, Low and Close. Therefore, take into consideration that
        //     on each tick, except the Open price, the rest of the values will most probably
        //     change.
        double LastValue { get; }
        //
        // Summary:
        //     Gets the total number of elements contained in the DataSeries.
        int Count { get; }

        //
        // Summary:
        //     Access a value in the dataseries certain bars ago
        //
        // Parameters:
        //   index:
        //     Number of bars ago
        double Last(int index);
    }
}

 Which indicator are you trying to feed?

Best Regards,

Panagiotis


@PanagiotisCharalampous

TonNcie
19 Mar 2019, 16:20

RE:

Hi Panagiotis

Sorry i overlooked that.

The indicator is a selfmade indicator that needs a datafeed/timeframe that does not exist in ctrader and can be filled in the OnTick event handler.

 

 

 


@TonNcie

PanagiotisCharalampous
19 Mar 2019, 16:25

Hi El Antonio,

If it is custom made then you can use IndicatorDataSeries type in your class instead if DataSeries. IndicatorDataSeries allows setting values.

Best Regards,

Panagiotis 


@PanagiotisCharalampous