Drawing a line at high/low
Drawing a line at high/low
28 May 2019, 19:32
Specifically high and low for the day on the Hourly chart (between 8am-5pm for e.g.) How would I go about doing that? Here is my template - currently this moves the line on every new bar which I don't want.
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class ActiveAreas : Indicator { public Color _textColor; [Parameter("High Color", DefaultValue = "DarkOrange")] public string ColorH { get; set; } [Parameter("Low Color", DefaultValue = "Orange")] public string ColorL { get; set; } [Parameter("Low Lookback", DefaultValue = "0")] public int Low { get; set; } [Parameter("High Lookback", DefaultValue = "2")] public int High { get; set; } //[Output("Line")] //public IndicatorDataSeries Result { get; set; } protected override void Initialize() { // Initialize and create nested indicators } public override void Calculate(int index) { // Draw the text on the last bar high. var highPrice = MarketSeries.High.Last(High); var lowPrice = MarketSeries.Low.Last(Low); Chart.DrawHorizontalLine("Active Area High", highPrice, ColorH, 2, LineStyle.Solid); Chart.DrawHorizontalLine("Active Area Low", lowPrice, ColorL, 2, LineStyle.Solid); } } }
Replies
alex_mihail
29 May 2019, 11:45
Thanks Panagiotis!
EDIT: Is there a way to specify this to grab the highest point WITHIN 5 bars back rather than the high FROM 5 bars back exactly?
@alex_mihail
igorjrmedeiros
18 Jul 2019, 17:24
RE:
alex_mihail said:
Thanks Panagiotis!
EDIT: Is there a way to specify this to grab the highest point WITHIN 5 bars back rather than the high FROM 5 bars back exactly?
Hi alex_mihail,
Look this, I hope help you.
double max = Functions.Maximum(MarketSeries.High, period); // where: period is the bars back //
@igorjrmedeiros
PanagiotisCharalampous
29 May 2019, 09:38
Hi Alex,
See below an example for using the Daily timeframe
Best Regards,
Panagiotis
@PanagiotisCharalampous