Adding a Label to a Chart.DrawHorizontalLine
Created at 03 Dec 2021, 18:01
Adding a Label to a Chart.DrawHorizontalLine
03 Dec 2021, 18:01
Hi Guys,
Just a quick, and what i imagine to be a simple one!
I want to create a label that's displayed on my chart at the location of my Horizontal Line.
Here's the code that draws the line:
using System;
using System.Collections.Generic;
using cAlgo.API;
using cAlgo.API.Internals;
using System.Linq;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ChartDrawings : Robot
{
protected override void OnStart()
{
}
protected override void OnTick()
{
var monthly = MarketData.GetBars(TimeFrame.Monthly, Symbol.Name);
Chart.DrawHorizontalLine("MONTH OPEN", monthly.Last(0).Open, Color.Green, 2, LineStyle.Lines);
//Chart.DrawText("MONTHLABEL", "MONTHLY OPEN", monthly.Last(0).OpenTime, monthly.Last(0).Close, Color.Purple);
}
}
}
As you can see, i've tried to use Chart.DrawText to place the label at the same price as the Horizontal Line, but it doesn't show anywhere. Perhaps the Y axis is wrong?
Thank you for your help and time!
MTrade12
04 Dec 2021, 04:43
RE:
MTrade12 said:
Hey Guys,
I figured it out! :-)
Here's the code i used in case anyone wants the same thing in the future:
@MTrade12