How to add Text to Horizontal Line Indicator
How to add Text to Horizontal Line Indicator
24 Sep 2021, 19:00
Can someone please explain how to add a label/text to a Horizontal Line?
I have an Indicator that populates horizontal lines every X pips, I would like to add Text to each, so that I can differentiate between the lines that are every 100 Pips and the ones ever 1000 for example.
My code for the lines is below;
[Parameter("Hundred Pip Steps", DefaultValue = 100)]
public int StepPipsHun { get; set; }
double max = Bars.HighPrices.Maximum(Bars.HighPrices.Count);
double min = Bars.LowPrices.Minimum(Bars.LowPrices.Count);
double stepHun = Symbol.PipSize * StepPipsHun;
double startHun = Math.Floor(min / stepHun) * stepHun;
for (double level = startHun; level <= max + stepHun; level += stepHun)
{
ChartObjects.DrawHorizontalLine("line_2" + level, level, Colors.Blue);
}
Thanks
Replies
amusleh
27 Sep 2021, 10:42
You can use Chart.DrawText:
for (double level = startHun; level <= max + stepHun; level += stepHun)
{
ChartObjects.DrawHorizontalLine("line_2" + level, level, Colors.Blue);
// You can add some distance if you want to by adding some pips value to level
// The x axis value to last bar on chart, you can change it based on your needs
Chart.DrawText("line_2_text" + level, level.ToString(), Chart.LastVisibleBarIndex, level, Color.Blue);
}
@amusleh
DiamondTrades
27 Sep 2021, 11:28
RE:
firemyst said:
Use "Chart.DrawText" and put in your "level" parameter for the "double y" parameter.
Eg:
Chart.DrawText("line_2_text", "here is my text I want to draw", theBarIndex, level, Color.Red);
Thank you!
@DiamondTrades
DiamondTrades
27 Sep 2021, 11:29
RE:
amusleh said:
You can use Chart.DrawText:
for (double level = startHun; level <= max + stepHun; level += stepHun) { ChartObjects.DrawHorizontalLine("line_2" + level, level, Colors.Blue); // You can add some distance if you want to by adding some pips value to level // The x axis value to last bar on chart, you can change it based on your needs Chart.DrawText("line_2_text" + level, level.ToString(), Chart.LastVisibleBarIndex, level, Color.Blue); }
This works well, thanks
@DiamondTrades
firemyst
27 Sep 2021, 08:54
Use "Chart.DrawText" and put in your "level" parameter for the "double y" parameter.
Eg:
Chart.DrawText("line_2_text", "here is my text I want to draw", theBarIndex, level, Color.Red);
@firemyst