How to get OHLC prices of different timeframes in a CBOT
Created at 21 Jan 2024, 15:14
MI
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
}
}
}
PanagiotisCharalampous
22 Jan 2024, 06:43
Responded here
https://ctrader.com/forum/calgo-support/42742#post-107021
@PanagiotisCharalampous