multiple time frame indicators

Created at 13 Jan 2016, 17:38
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!
J.

j.kozlowski.net

Joined 15.11.2015

multiple time frame indicators
13 Jan 2016, 17:38


Hello,

I wondered if one could access an indicator on a multiple time frame basis, which doesn't take "DataSeries source" as a variable as seen here /api/guides/indicators#el12 ? I was hoping to use a number of stochastic indicators, each with a different time frame but it takes integer and MovingAverageType inputs. Is there a workaround for this?

Best regards.


@j.kozlowski.net
Replies

DeletedUser2
14 Jan 2016, 02:33 ( Updated at: 16 Aug 2022, 15:13 )

RE:

 

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        private MarketSeries anothertimeframe;

        private StochasticOscillator stoc1;
        private StochasticOscillator stoc2;

        protected override void OnStart()
        {
            // Put your initialization logic here
            anothertimeframe = MarketData.GetSeries(Symbol, TimeFrame.Minute5);

            stoc1 = Indicators.StochasticOscillator(MarketSeries, 9, 3, 9, MovingAverageType.Exponential);

            stoc2 = Indicators.StochasticOscillator(anothertimeframe, 9, 3, 9, MovingAverageType.Exponential);
        }

        protected override void OnTick()
        {
            // Put your core logic here
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

 


@DeletedUser2

j.kozlowski.net
14 Jan 2016, 11:02

Oh wow, I can't believe it's that basic. Huge thanks for your reply!


@j.kozlowski.net

huhax
14 Feb 2016, 02:46

RE: RE:

I keep geting Error CS0246. Can't find type name or namespace "MarketSeries".

What can be wrong?


@huhax

huhax
14 Feb 2016, 15:51

RE: RE: RE:

Ok, I got rid of the above error by using your header, but there is still an issue.

stoc2 = Indicators.StochasticOscillator(anothertimeframe, 9, 3, 9, MovingAverageType.Exponential);

"anothertimeframe" here doesn't work alone. It works only, if I use "anothertimeframe.close", etc., but this gives results different from expected.

 

What can be wrong about this?


@huhax

huhax
14 Feb 2016, 21:48

There was no question. I already know, what I didn't.


@huhax