So I am creating an indicator that will sit on a one minute chart.
I would like for example, to display the OPEN price of say a 6 hour bar. On that one minute chart (I will do other things too, but for now this should serve as an example). But the OPEN of a higher TF is all I want as I will calculate everything else I need with the 1 minute data.
I can do this with a secondary series like so:
protected override void Initialize() { Overlay = true; Add(PeriodType.Minute, 360); Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "1) HTF_OPEN")); //1 } protected override void OnBarUpdate() { if(CurrentBar==0) ClearOutputWindow(); if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired) return; if (BarsInProgress == 1) { htf_Oprice = Open[-1]; htf_Obar =CurrentBars[0]; DrawVerticalLine("htfOpen"+CurrentBar,0,Color.Orange,DashStyle.Dash,1); Print(Times[0][0]+" , "+htf_Oprice+" , "+htf_Obar); } if (BarsInProgress == 0) { HTF_Open[0] = htf_Oprice; // Print(Time[0]+" , "+htf_Oprice+" , "+htf_Obar); } }
So my question, is there any logic that will allow me to do this without using an MTF or seconary series?
I'm sure I could just check on each bar if the time coincides with the open of whatever larger time frame bar I want. But then this would require re-coding anytime I want to change the larger TF.
I could simply sum the smaller TF bars up to equal the number required to fit in the larger TF, but this seems kinda sloppy and sometimes there may not be exactly 360 one minute bars in every one.
Has anyone had a similar need and if so what was your programming logic to do this?
Thanks!
Comment