I'm having an issue with an indicator that I'm working on that uses HMA(30). My goal is to get the High, Low, Open, Close of HMA for the working bar. How can I get the Max High and Min Low for HMA(30)[0] while it calculates on each tick or on price change?
Here is my code so far:
protected override void OnStateChange() if (State == State.SetDefaults) Calculate = Calculate.OnEachTick AddPlot(new Stroke(Brushes.Lime, 1), PlotStyle.Square, "HMAHigh"); AddPlot(new Stroke(Brushes.Red, 1), PlotStyle.Square, "HMALow"); AddPlot(new Stroke(Brushes.DodgerBlue, 1), PlotStyle.Square, "HMAOpen"); AddPlot(new Stroke(Brushes.Goldenrod, 1), PlotStyle.Square, "HMAClose"); protected override void OnBarUpdate() if (BarsInProgress != 0) return; if (CurrentBars[0] < 33) return; Print(">>>Price Change<<<"); HMAOpen[0] = Math.Round(HMA(30)[1],2); HMAClose[0] = Math.Round(HMA(30)[0],2); HMAHigh[0] = Math.Round(Math.Max(HMAOpen[0],HMAClose[0]),2); HMALow[0] = Math.Round(Math.Min(HMAOpen[0],HMAClose[0]),2); Print("HMAHigh = "+HMAHigh[0]); Print("HMALow = "+HMALow[0]); Print("HMAOpen = "+HMAOpen[0]); Print("HMAClose = "+HMAClose[0]);
>>>Price Change<<< HMAHigh = 7621.47 HMALow = 7621.07 HMAOpen = 7621.47 HMAClose = 7621.07
How can I get accurate HMAHigh and HMALow values?
Comment