QuickStart - ChartObjects
Created at 15 Jan 2014, 11:49

QuickStart - ChartObjects
15 Jan 2014, 11:49
// --------------------------------------------------------------------------------------- // // This code demonstrates use of ChartObjects // It shows the maximum of a DataSeries for a period. // // --------------------------------------------------------------------------------------- using System; using cAlgo.API; namespace cAlgo.Indicators { [Indicator(IsOverlay = true)] public class ChartObjectsSample : Indicator { [Parameter("Source")] public DataSeries Source { get; set; } [Parameter("Period", DefaultValue = 30, MinValue = 3)] public int Period { get; set; } [Parameter("Text Color", DefaultValue = "Yellow")] public string TextColor { get; set; } [Parameter("Line Color", DefaultValue = "White")] public string LineColor { get; set; } private Colors _colorText; private Colors _colorLine; protected override void Initialize() { // Parse color from string if (!Enum.TryParse(TextColor, out _colorText)) { ChartObjects.DrawText("errorMsg1", "Invalid Color for Text", StaticPosition.TopLeft, Colors.Red); _colorText = Colors.Yellow; } if (!Enum.TryParse(LineColor, out _colorLine)) { ChartObjects.DrawText("errorMsg2", "\nInvalid Color for Line", StaticPosition.TopLeft, Colors.Red); _colorLine = Colors.White; } } public override void Calculate(int index) { if (!IsLastBar) return; ChartObjects.DrawVerticalLine("vLine", index - Period, _colorLine); int maxIndex=index; double max = Source[index]; for (int i = index - Period; i <= index; i++) { if (max >= Source[i]) continue; max = Source[i]; maxIndex = i; } var text = "max " + max.ToString("0.0000"); var top = VerticalAlignment.Top; var center = HorizontalAlignment.Center; ChartObjects.DrawText("max", text, maxIndex, max, top, center, _colorText); ChartObjects.DrawLine("line", maxIndex, max, index, Source[index], _colorLine); } } }
Replies
ABR170173
17 Jul 2015, 13:55
RE:
Spotware said:
At the moment it is not possible to change the font size.
Does something has been changed in this case? Is possible to change font parameters now?
@ABR170173
cTrader Team
17 Jul 2015, 14:23
Dear Traders,
This option is still not available. For your information you can post your ideas/suggestions to http://vote.spotware.com/.
@Spotware
bellong
07 Apr 2014, 15:50
RE: how to change default font text size ?
Spotware said:
I have uploaded the indicator "draw spread" from your repo; and try to set a bigger font text size for displaying the "spread". But im not lucky with my tweaks: how to insert the font size parameter ?
@bellong