Stochastic Multi timeframe

Created at 12 Sep 2020, 04:58
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!
AL

alexbourret09

Joined 12.09.2020

Stochastic Multi timeframe
12 Sep 2020, 04:58


Howdy! I'm trying to get Stochastic data from another timeframe but I'm getting these errors:

Error CS1502: The best overloaded method match for 'cAlgo.API.Internals.IIndicatorsAccessor.StochasticOscillator(cAlgo.API.Internals.MarketSeries, int, int, int, cAlgo.API.MovingAverageType)' has some invalid arguments

Error CS1503: Argument 1: cannot convert from 'cAlgo.API.DataSeries' to 'cAlgo.API.Internals.MarketSeries'

I've been through the other threads regarding multi timeframe and still couldn't figure out what's wrong.

Here's the code:

using System;
using System.Linq;
using System.Collections.Generic;
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 TheBot : Robot
    {

[Parameter("K Periods", Group = "Stochastic", DefaultValue = 14, MinValue = 1)]
        public int kPeriods { get; set; }

        [Parameter("K Slowing", Group = "Stochastic", DefaultValue = 3, MinValue = 1)]
        public int kSlowing { get; set; }

        [Parameter("D Periods", Group = "Stochastic", DefaultValue = 3, MinValue = 1)]
        public int dPeriods { get; set; }

        [Parameter("Stoch High", Group = "Stochastic", DefaultValue = 80)]
        public int Stoch_High { get; set; }

        [Parameter("Stoch Low", Group = "Stochastic", DefaultValue = 20)]
        public int Stoch_Low { get; set; }

        [Parameter("MA Type", Group = "Stochastic", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType maType { get; set; }

        private StochasticOscillator stochastic;

        private Bars h1;

protected override void OnStart()

{

h1 = MarketData.GetBars(TimeFrame.hour);

stochastic = Indicators.StochasticOscillator(h1.ClosePrices, kPeriods, kSlowing, dPeriods, maType);



}

 

Then I have OnBar logic etc.

 

Thank you!


@alexbourret09
Replies

PanagiotisCharalampous
14 Sep 2020, 08:09

Hi alexbourret09,

Here is the correct code

            h1 = MarketData.GetBars(TimeFrame.Hour);

            stochastic = Indicators.StochasticOscillator(h1, kPeriods, kSlowing, dPeriods, maType);

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

alexbourret09
15 Sep 2020, 01:14

RE:

This fixed the error thank you, but the thing is that the Stochastic is not taking the data from the other timeframe.

Let's say the bot is initially setup to H2 to validate most of the indicators on H2 but I want it to validate the Stochastic on H1. Would it be the right way to proceed with GetBars? Unless I'm misunderstanding the feature itself.

Thank you again.

 

PanagiotisCharalampous said:

Hi alexbourret09,

Here is the correct code

            h1 = MarketData.GetBars(TimeFrame.Hour);

            stochastic = Indicators.StochasticOscillator(h1, kPeriods, kSlowing, dPeriods, maType);

Best Regards,

Panagiotis 

Join us on Telegram

 


@alexbourret09

PanagiotisCharalampous
15 Sep 2020, 08:19

Hi alexbourret09,

but the thing is that the Stochastic is not taking the data from the other timeframe.

Why do you think so?

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

alexbourret09
16 Sep 2020, 03:17

RE:

Update: While typing this I figured something out, would the result be affected because the TP and SL are based on the bot initial configuration? If not, follow with that haha:

 

Well, when I setup the bot in two different timeframes, backtesting gives me 2 different results. I only have this stochastic indicator running and nothing else.

From what I understand, the results should remain the same whatever the bot is initially setup in.

Ex:

I setup the bot for H4 and Stochastic for H1, backtesting gives me result X.

I setup the bot for H1 and Stochastic for H1, backtesting gives me result Y.

 

The goal I want eventually is to have some indicators being followed in different timeframes, but from what I understand, the whole thing changes when the bot have a different initial timeframe. That's where I might misunderstand the multi timeframe concept.

 

 

PanagiotisCharalampous said:

Hi alexbourret09,

but the thing is that the Stochastic is not taking the data from the other timeframe.

Why do you think so?

Best Regards,

Panagiotis 

Join us on Telegram

 


@alexbourret09

PanagiotisCharalampous
16 Sep 2020, 07:47

Hi alexbourret09,

Ti help you further, you will need to provide us with the complete cBot code and steps to reproduce the behavior you are experiencing.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous