Using a custom indicator within a bot but calculate values for a lower timeframe

Created at 03 Mar 2023, 15:10
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!
JA

jaydcrowe1989

Joined 11.08.2022

Using a custom indicator within a bot but calculate values for a lower timeframe
03 Mar 2023, 15:10


Hi,

I have created a custom indicator and it works perfectly on the live chart and calculates the values correctly for the current timeframe that I am viewing the indicator on. What I want to do now is use it within my bot but calculate the values for a lower timeframe. So I am using my bot on the hourly timeframe but I want to get the values of my indicator from the 5 minute timeframe.

I have implemented the indicator into my bot but it only seems to calculate the values every hour instead of every 5 minutes?

I am initialising my indicator in my bot in the onstart method via:

 _highsAndLows = Indicators.GetIndicator<AP_HighsAndLows>(TimeFrame.Minute5);

Then within my ontick method I am getting the values like so:

double latestLow = _highsAndLows.Lows.LastValue;

 double latestHigh = _highsAndLows.Highs.LastValue;

But these values only seem to update every hour and not every 5 minutes.

I am thinking (but could be incorrect) I need to call the calculate method of my indicator but I am not sure how?

Any help would be appreciated.

Regards,

Jay


@jaydcrowe1989
Replies

firemyst
01 Jun 2023, 05:56

First question: how do you know the code in your indicator is retrieving the correct market data for the faster time frame?

And do you have your indicator set up to handle multiple time frames? Eg, look at this example:

 

 


@firemyst