Highest -Lowest for regular hours only

Questions about MultiCharts and user contributed studies.
newdesigner
Posts: 7
Joined: 10 Feb 2009
Has thanked: 1 time

Highest -Lowest for regular hours only

Postby newdesigner » 16 Nov 2020

Hello,
I have an indicator to plot the Highest and Lowest for a period of bars intraday (minute bars) but needs to calculate only during market hours (9:30 to 4:00) even though I am including Pre-Market data in the chart. Inotherwords the highest and the Lowest for the Input Lookback shall fall within the regular market hours. The code I have shows for all time including Premarket hrs. See image below. Any suggestions to modify the code below are welcome. Thanks in advance.

The code below calculates premarket data as well which I don't want included in the plot calculation.

Code: Select all

Input: Lookback (20); Vars: UpperC(0), LowerC(0); If Time > 0930 AND Time < 1600 then begin UpperC = HighestFC (High, Lookback )[1]; LowerC = LowestFC (Low, Lookback )[1]; Plot1 (UpperC, "Upper"); Plot2 (LowerC, "Lower"); End;

HILO.jpg
(106.1 KiB) Not downloaded yet
Image
Last edited by newdesigner on 16 Nov 2020, edited 2 times in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Highest -Lowest for regular hours only

Postby TJ » 16 Nov 2020

See post #1 & post #2
viewtopic.php?t=11713

McGeorge
Posts: 49
Joined: 22 Jun 2018
Has thanked: 10 times
Been thanked: 6 times

Re: Highest -Lowest for regular hours only

Postby McGeorge » 20 Nov 2020

Hello,
I have an indicator to plot the Highest and Lowest for a period of bars intraday (minute bars) but needs to calculate only during market hours (9:30 to 4:00) even though I am including Pre-Market data in the chart. Inotherwords the highest and the Lowest for the Input Lookback shall fall within the regular market hours. The code I have shows for all time including Premarket hrs. See image below. Any suggestions to modify the code below are welcome. Thanks in advance.

The code below calculates premarket data as well which I don't want included in the plot calculation.

Code: Select all

Input: Lookback (20); Vars: UpperC(0), LowerC(0); If Time > 0930 AND Time < 1600 then begin UpperC = HighestFC (High, Lookback )[1]; LowerC = LowestFC (Low, Lookback )[1]; Plot1 (UpperC, "Upper"); Plot2 (LowerC, "Lower"); End;


HILO.jpg

Image
The "Time > 930" should be changed to "Time > 950" if Lookback is 20. That means you need to create a variable, say, StartTime, where the value is "930 + Lookback". Then change "Time > 930" to "Time > StartTime".


Return to “MultiCharts”