Tick chart problem

Created at 07 Apr 2019, 13:52
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!
A.

a.fernandez.martinez

Joined 02.03.2019

Tick chart problem
07 Apr 2019, 13:52


Hello,

 

I have an indicator on a t1 (tick) chart and I want to calculate averages and more things from the past data on the OnStart function.

I can't do GetSeries to access .Close because TimeFrame.Tick does not exist. How can I do it ?


@a.fernandez.martinez
Replies

a.fernandez.martinez
08 Apr 2019, 05:17

The only solution I found for the moment is run the bot on backtesting first and get the values from the variables you want to pass to the real bot, is there another way to do all in one?


@a.fernandez.martinez

PanagiotisCharalampous
10 Apr 2019, 15:54

Hi a.fernandez.martinez,

You can pass the timeframe as a parameter like the below

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewIndicator : Indicator
    {
        [Parameter(DefaultValue = 0.0)]
        public TimeFrame Timeframe { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        MarketSeries series;
        protected override void Initialize()
        {
            series = MarketData.GetSeries(Timeframe);
        }

        public override void Calculate(int index)
        {
            Print(series.Close.LastValue);
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous