- Home
- Forum
- Indicators API Help
- How to add Text to Horizontal Line Indicator
How to add Text to Horizontal Line Indicator
How to add Text to Horizontal Line Indicator
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
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);
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);
}
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!
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