Default timeframe set even for Custom Indicators?

Created at 30 Jul 2024, 09:43
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!
TB

tbbusinge

Joined 03.07.2024

Default timeframe set even for Custom Indicators?
30 Jul 2024, 09:43


Hello everyone,

I wrote a custom indicator that basically creates 3 EMAs for each timeframe provided, and uses that to determine the TrendPlusPhase of the market.

When I launch the bot though, my indicator forcefully uses only the h1 timeframe, regardless of what timeframe I have specified in the code, or even whatever chart timeframe it is running on. I am curious whether this behaviour is typical. When I manually change the timeframe using the parameter settings in cTrader while the bot is running it correctly uses that specific timeframe regardless of what timeframe it is put on. Why can't I do this programmatically? Below is all the relevant code.

 

Below is the TrendPlusPhase Indicator that is used basically to call the TripleMA which does the calculation, I separated it so that I can plot the Triple MA separately and the actual code corresponding to the trend and phase separately(as a histogram in another panel)

using System;

 

 

And below is the TripleMA that I wrote to use whatever timeframe it has been given, but is defaulting to the 1H timeframe regardless.

 

 

Any  help rendered will be appreciated.


@tbbusinge
Replies

PanagiotisCharalampous
30 Jul 2024, 12:25

Hi there,

It's a known issue and it will be fixed in an upcoming update.

Best regards,

Panagiotis


@PanagiotisCharalampous

tbbusinge
30 Jul 2024, 12:31

RE: Default timeframe set even for Custom Indicators?

PanagiotisCharalampous said: 

Hi there,

It's a known issue and it will be fixed in an upcoming update.

Best regards,

Panagiotis

Okay thanks for the feedback.
What is your best guess on when this will be done?
Also, is there any work around you recommend, because this project is required in the next few weeks?
 


@tbbusinge

PanagiotisCharalampous
31 Jul 2024, 05:47

RE: RE: Default timeframe set even for Custom Indicators?

tbbusinge said: 

PanagiotisCharalampous said: 

Hi there,

It's a known issue and it will be fixed in an upcoming update.

Best regards,

Panagiotis

Okay thanks for the feedback.
What is your best guess on when this will be done?
Also, is there any work around you recommend, because this project is required in the next few weeks?
 

Unfortunately we do not have an ETA or a workaround at the moment


@PanagiotisCharalampous

tbbusinge
31 Jul 2024, 09:10 ( Updated at: 01 Aug 2024, 05:20 )

RE: RE: RE: Default timeframe set even for Custom Indicators?

PanagiotisCharalampous said: 

tbbusinge said: 

PanagiotisCharalampous said: 

Hi there,

It's a known issue and it will be fixed in an upcoming update.

Best regards,

Panagiotis

Okay thanks for the feedback.
What is your best guess on when this will be done?
Also, is there any work around you recommend, because this project is required in the next few weeks?
 

Unfortunately we do not have an ETA or a workaround at the moment

Okay thanks.

I have found a pretty easy workaround. In case anyone is interested.

Simply create an enum for the timeframes.

public enum TimeFrames
       {
           Daily,
           H4,
           H1,
           M30,
           M15,
           M5,
           M1
       }

And then pass those to whatever indicator you need to use, once you need to use actual timeframes (of type TimeFrame) simply create a switch statement that will reliably map each enum option back to actual timeframes.


switch (RequiredTimeframeName)
           {
               case "Daily":
                   RequiredTimeFrame = TimeFrame.Daily;
                   break;
               case "H4":
                   RequiredTimeFrame = TimeFrame.Hour4;
                   break;
               case "H1":
                   RequiredTimeFrame = TimeFrame.Hour;
                   break;
               case "M30":
                   RequiredTimeFrame = TimeFrame.Minute30;
                   break;
               case "M15":
                   RequiredTimeFrame = TimeFrame.Minute15;
                   break;
               case "M5":
                   RequiredTimeFrame = TimeFrame.Minute5;
                   break;
               case "M1":
                   RequiredTimeFrame = TimeFrame.Minute;
                   break;
               default:
                   break;
           }

Hope that helps.


@tbbusinge