How to get OHLC prices of different timeframes in a CBOT

Created at 21 Jan 2024, 15:14
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!
MI

mihlali700

Joined 22.12.2023

How to get OHLC prices of different timeframes in a CBOT
21 Jan 2024, 15:14


The method to get them in indicators and in a Bot is different it sees cause Cbot doesn't have “index”  and I just tried it like this and it didn't give me the current open price I wanted 

 

 




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.None)]
    public class CountBars : Robot
    {
    
        [Parameter(DefaultValue = "Hello world!")]
        public string Message { get; set; }
        
      
        private Bars Bars15Min; 

        protected override void OnStart()
        {
         
        Bars15Min = MarketData.GetBars(TimeFrame.Minute15);
         
        }

        protected override void OnTick()
        {
         
            double OpenNow = Bars15Min.OpenPrices.Last(0);
            
            Print(OpenNow);
          
       
        }
        
         protected override void OnBar()
        {
            
      
        
        
        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
        
        
    
    }
}

@mihlali700
Replies

PanagiotisCharalampous
22 Jan 2024, 06:40

Hi there,

Can you explain clearly what are you trying to do and why do you thing the result is wrong?

Best regards,

Panagiotis


@PanagiotisCharalampous

mihlali700
22 Jan 2024, 07:49

RE: How to get OHLC prices of different timeframes in a CBOT

PanagiotisCharalampous said: 

Hi there,

Can you explain clearly what are you trying to do and why do you thing the result is wrong?

Best regards,

Panagiotis

I want to get the Open,Close,High,Low prices of bars from different timeframes .


@mihlali700

mihlali700
22 Jan 2024, 07:49

RE: How to get OHLC prices of different timeframes in a CBOT

PanagiotisCharalampous said: 

Hi there,

Can you explain clearly what are you trying to do and why do you thing the result is wrong?

Best regards,

Panagiotis

I want to get the Open,Close,High,Low prices of bars from different timeframes .


@mihlali700

PanagiotisCharalampous
22 Jan 2024, 09:42

RE: RE: How to get OHLC prices of different timeframes in a CBOT

mihlali700 said: 

PanagiotisCharalampous said: 

Hi there,

Can you explain clearly what are you trying to do and why do you thing the result is wrong?

Best regards,

Panagiotis

I want to get the Open,Close,High,Low prices of bars from different timeframes .

and why do you think the result you are getting is wrong?


@PanagiotisCharalampous