How to draw previous day High and Low in the history
How to draw previous day High and Low in the history
03 Oct 2023, 20:06
I have an indicator, I am able to draw previous day High a Low on today chart only. I need to draw it on the days in the history too.
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 PreviousHL : Indicator
{
[Parameter("Length", DefaultValue = 200)]
public int length { get; set; }
[Parameter("LookBack", DefaultValue = 1)]
public int lback { get; set; }
[Parameter("No trading zone", DefaultValue = 0.3 )]
public double offset { get; set; }
[Parameter("Daily Close", Group = "Colors", DefaultValue = "Green")]
public Color wc { get; set; }
[Parameter("Previous daily H,L", Group = "Colors", DefaultValue = "DarkGray")]
public Color dc { get; set; }
[Parameter("No trade Colors", Group = "Colors", DefaultValue = "DarkGray")]
public Color nc { get; set; }
[Parameter("Close", Group = "Line styles", DefaultValue = LineStyle.Dots)]
public LineStyle LineStyleCL { get; set; }
[Parameter("No trading zone", Group = "Line styles", DefaultValue = LineStyle.Dots)]
public LineStyle LineStyleNT { get; set; }
[Parameter("Previous daily H,L", Group = "Line styles", DefaultValue = LineStyle.Lines)]
public LineStyle LineStyleHL{ get; set; }
[Parameter("Show prevoius daily HL", Group = "Prices", DefaultValue = true)]
public bool showD { get; set; }
[Parameter("Show prevoius Close", Group = "Prices", DefaultValue = true)]
public bool showClose { get; set; }
[Parameter("Show No trade zones", Group = "Prices", DefaultValue = true)]
public bool showNZ { get; set; }
[Output("Main")]
public IndicatorDataSeries Result { get; set; }
private MarketSeries d;
protected override void Initialize()
{
d = MarketData.GetSeries(TimeFrame.Daily);
}
public override void Calculate(int index)
{
if (showD)
{
Chart.DrawTrendLine("dh", index, d.High[d.High.Count - lback - 1], index - length, d.High[d.High.Count - lback - 1], dc , 1 ,LineStyleHL); // normalni H
Chart.DrawTrendLine("dl", index, d.Low[d.High.Count - lback - 1], index - length, d.Low[d.High.Count - lback - 1], dc,1 , LineStyleHL); // normalni L
}
if (showNZ)
{
double Habove = d.High[d.High.Count - lback - 1] + offset;
double Hbelow = d.High[d.High.Count - lback - 1] - offset;
double Labove = d.Low[d.High.Count - lback - 1] + offset;
double Lbelow = d.Low[d.High.Count - lback - 1] - offset;
Chart.DrawTrendLine("dhA", index, Habove, index - length, Habove, nc, 1, LineStyleNT);
Chart.DrawTrendLine("dhB", index, Hbelow, index - length, Hbelow, nc, 1, LineStyleNT);
Chart.DrawTrendLine("dlA", index, Labove, index - length, Labove, nc, 1, LineStyleNT);
Chart.DrawTrendLine("dlB", index, Lbelow, index - length, Lbelow, nc, 1, LineStyleNT);
}
if (showClose)
Chart.DrawTrendLine("dc", index, d.Close[d.High.Count - lback - 1], index - length, d.Close[d.High.Count - lback - 1], wc,1, LineStyleCL);
}
}
}
Replies
martinnoha18
04 Oct 2023, 11:59
( Updated at: 05 Oct 2023, 05:25 )
RE: How to draw previous day High and Low in the history
PanagiotisChar said:
Hi there,
What is the question? What information are you missing to achieve this?
Can you help me how to draw a horizontal lines (previous daily Low, High) from 0:00 to 23:59:59 every day in the past.
@martinnoha18
PanagiotisChar
05 Oct 2023, 06:04
( Updated at: 05 Oct 2023, 06:09 )
Hi there,
If you want somebody to do the job for you, you can post a Job. If you are trying to program it and you have a specific question, feel free to ask
@PanagiotisChar
martinnoha18
05 Oct 2023, 11:44
( Updated at: 05 Oct 2023, 12:17 )
RE: How to draw previous day High and Low in the history
PanagiotisChar said:
Hi there,
If you want somebody to do the job for you, you can post a Job. If you are trying to program it and you have a specific question, feel free to ask
Thank you. I posted a job.
@martinnoha18
PanagiotisChar
04 Oct 2023, 06:00 ( Updated at: 04 Oct 2023, 06:09 )
Hi there,
What is the question? What information are you missing to achieve this?
@PanagiotisChar