Using 24 hour GLOBEX intraday data, how can I get the highest high of the past 5 sessions and the lowest low of the past 5 sessions? Sessions start at 6:00pom ET the day before the close at 5:00pm ET the next day.
you will have to track the extremes for every session using two variables (one for the high, one for the low). At the beginning of a new session you store the tracking variables in an array (so you need two arrays for that) and reset the tracking variables.
The array has the size of 5 in your example. You'll also need a counter that increments at every new session, starting from 0 and once it's > 4 it has to reset to 0. This will be used to store the tracking variables.
Once you have stored 5 values within your array and starting to overwrite values you can start calculating the highest high and lowest low. For that I'd suggest using a third array. You copy the values of the array containing the highest highs of the last 5 sessions to the new array and sort it in descending order. This gives you the highest high of the last 5 session at position 0 of the new array.
For the lowest low you'd copy the values into the new array and sort it in ascending order. Again giving you the lowest low at position 0.
This is your blueprint and should get you what you want.
The following 2 users say Thank You to ABCTG for this post: