DrawText of TimeFrame
Created at 24 Sep 2017, 09:35
DrawText of TimeFrame
24 Sep 2017, 09:35
Hi,
can somebody tell me how to draw the TimeFrame Text "H12" instead of Hour12?
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator("Text", IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Text : Indicator { [Parameter("Test TimeFrame", DefaultValue = "Hour12")] public TimeFrame TestTimeFrame { get; set; } private MarketSeries T; // ----- Colors Tc = Colors.Black; // ------------------------------------------------------ protected override void Initialize() { T = MarketData.GetSeries(Symbol, TestTimeFrame); } // ------------------------------------------------------ public override void Calculate(int index) { var Text = TestTimeFrame; ChartObjects.DrawText("Text", "Text " + Text, index + 1, T.Close.Last(1), VerticalAlignment.Top, HorizontalAlignment.Right, Tc); } } }
Replies
... Deleted by UFO ...
PanagiotisCharalampous
25 Sep 2017, 11:26
Hi MaVe,
The below should be working
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator("Text", IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Text : Indicator { [Parameter("Test TimeFrame", DefaultValue = "Hour12")] public TimeFrame TestTimeFrame { get; set; } private MarketSeries T; // ----- Colors Tc = Colors.White; // ------------------------------------------------------ protected override void Initialize() { T = MarketData.GetSeries(Symbol, TestTimeFrame); } // ------------------------------------------------------ public override void Calculate(int index) { var Text = GetTimeFrameText(); ChartObjects.DrawText("Text", "Text " + Text, index + 1, T.Close.Last(1), VerticalAlignment.Top, HorizontalAlignment.Right, Tc); } private string GetTimeFrameText() { if (TestTimeFrame == TimeFrame.Hour12) { return "H12"; } return TestTimeFrame.ToString(); } } }
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
25 Sep 2017, 09:51
Hi MaVe,
There is no build in way to do that. You can try implementing your own function as below
You can add more conditions and put the text you need for each timeframe. Let me know if this helps.
Best Regards,
Panagiotis
@PanagiotisCharalampous