Get high and low price between a specific timeframe
Created at 27 Dec 2022, 04:10
CT
Get high and low price between a specific timeframe
27 Dec 2022, 04:10
Hi there,
I'm trying to get the high and low price between a specific set timeframe.
Any help with what I've got so far would be appreciated.
using cAlgo.API;
using cAlgo.API.Internals;
using System;
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class HighAndLowPriceBot : Robot
{
[Parameter("Symbol", DefaultValue = "USDJPY")]
public string Symbol { get; set; }
[Parameter("TimeFrame", DefaultValue = TimeFrame.Minute)]
public TimeFrame TimeFrame { get; set; }
[Parameter("Start Time (UTC)", DefaultValue = "15:00:00")]
public DateTime StartTime { get; set; }
[Parameter("End Time (UTC)", DefaultValue = "15:10:00")]
public DateTime EndTime { get; set; }
protected override void OnStart()
{
// get the candles between the specified start and end times
var candles = MarketData.GetBars(TimeFrame);
var filtered_candles = candles.where(x => x.CloseTime >= StartTime && x.CloseTime <= EndTime);
// get the high and low prices from the candles
var high = filtered_candles.Max(x => x.High);
var low = filtered_candles.Min(x => x.Low);
Print("High: {0}", high);
Print("Low: {0}", low);
}
}
ctid2434759
27 Dec 2022, 05:28 ( Updated at: 02 Jan 2023, 04:33 )
Ignore
Ignore this, not sure how to delete the above post.
@ctid2434759