Tutorial - Accessing Day Sessions High/Low

User Submitted: by Eddie (alias Ftrader)

This tutorial is a good example of how to use SSTAT and Custom Prices.

The issue is the following :

Let's consider an Emini future instrument (like ES H3) being set up on a 24 hours session (Session start = 4.45 pm / session end = 4.15 pm). This page shows how to build a custom indicator so that one may access the daily low and high of the previous DAY sessions only (Session start = 9.30 am / session end = 4.15 pm). If you're not concerned about the session, and just would like to access the high, low, or close of the previous day, click here.

Together with the custom price features introduced in the release 5.8 of IRT, the solution will be using following RTL tokens as custom indicator elements :

a) the signal statistic token (SSTAT) b) the SBAR (number of bar in session) and MPB (Minute Per Bar) tokens, introduced in IRT 5.5 release

I would recommend a reread of corresponding IRT web pages on these tokens if you are not familiar with them...

1) First step : building custom indicators representing the Daily High (Daily Low) of the ES day session

We need for that to define two trading signals (part A) which will be used in two SSTAT tokens (part B)

A) Definition of the Trading signals spotting the start and the end of the ES day session (within the 24 hour session)

Quick reminder : as the Eminis are trading non stops from 4.45 pm to 4.15 pm the next day : i.e., on a 1 minute chart, there are 1410 bars for the full session, but only 405 bars for the day session

- The first bar of the full session (the 4.46 pm one) corresponds to SBAR=1

- The last bar before the start of the day session (the 9.30 pm one) corresponds to SBAR=1005

- The last bar of the full session (the 4.15 pm one) corresponds to SBAR=1410

If we were on a 5 minute bar chart, this would be respectively SBAR=1005/5 = 201 and SBAR=1410/5=282

We can even generalize that in IRT using the MPB token (minutes per bar token) so we may define the following trading signals :

TSIGstart : SBAR = 1005/MPB ...will return true only at the bar preceding the start of the day session / otherwise false

TSIGend : SBAR = 1410/MPB ...will return true only at the last bar of the day session / otherwise false

B) Definition of the SSTAT token involved in the Daily High and Low definition

This Daily High/Low custom indicators will involve two SSTAT tokens :

a) A first SSTAT token named SSTATHI (& SSTATLO) will be equal to the ongoing daily Highest Hi of the ES during the day session (& Lowest Low)

SSTATHI definition : Scan/Signal : TSIGstart Result : Highest Price since last Signal Price : High

SSTATLO definition : Scan/Signal : TSIGstart Result : Lowest Price since last Signal Price : Low

At the bar ending the day session (ie SBAR=1410), SSTATHI is exactly equal to the highest high experienced during the day session

b) We will define a second SSTAT token named SSTATdetect in order to "store" this daily High value. This one will be used to detect the last bar of the session

SSTATdetect definition : Scan/Signal : TSIGend Result : Sum of Session Signals (intraday) Subtract 1 for False signals : Unchecked

Conclusion Part 1 :

We define a custom indicators named HH_ES and LL_ES being equal to HH_ES : SSTATHI x (SSTATdetect=1) LL_ES : SSTATLO x (SSTATdetect=1)

For an intraday chart, if you would plot these custom indicators on a separate pane (using the histogram style for example), you will get only zero on all bars EXCEPT once a day, at the 4.15 pm bar, where you will get the value of the daily high (& daily low) of the ES for the day session who just ended...

Part 2) Accessing the historical value of the HH_ES and LL_ES custom indicators

Here come the real tricky part, ie how to be able to access the historical daily value of LL_ES and HH_ES so that you may make further calculation with them in a Quote page or on a chart...

Let's say we are on the Day D, somewhere in the morning, before the opening of the ES day session (but the current full ES session started yesterday afternoon at 4.45 pm) You would like to get the value of the daily High of the previous day session, i.e. the last non zero value of HH_ES which was plotted at last session close...

First step : In Setup Pref, define PriceOne, a custom price, as being equal to the custom indicator HH_ES (PriceTwo will be LL_ES)

Second step : we are going to define a custom indicator (Hist_HH_ES) which will be equal to the last single non zero value of HH_ES (at D - 1) for all bars of the current full ES session.

In fact, in RTL, this Custom indicator Hist_HH_ES is directly equal to the following SSTATDH token with :

Scan/Signal : TSIG onebar before Session close SBAR = (1410/MPB)-1 Result : Highest Price since last Signal Price : PriceOne

The Trading signal used should detect the one bar before the close, ie SBAR=1409 on a 1 minute chart, or SBAR=281 on a 5 minute chart. (Strangely enough, you need to consider the bar preceding the close otherwise it won't work...)

Note : for Hist_LL_ES, just replace PriceOne! by PriceTwo, BUT keep of course Highest Price since last Signal in order to filter the non zero data

If you plot on your current intraday chart Hist_HH_ES (the chart session need to be the full session one..), you will get an horizontal line changing from level at each full session start (i.e. 4.45 pm) and representing the Historical Daily High of the previous DAY session

In order to get the daily low/high of 2/3/..sessions ago, just use SSTATDH.1410 / STATDH.2820/.. if you are on a one minute chart or SSTATDH.282 / 564.. if you are on a 5 minutes charts, and so on....

Be aware that ".282" is for example looking 282 bars back but will count only bars with quotes : As there might be some quote without data, you will get a bit of time shift, but shouldn't be a problem while you are on the current day session...

Another solution to access the past value for 1/2/3 etc days ago is to use a STAT statement with following settings :

Calculate : Maximum PriceOne From : 1 (& 2/3/4 etc) days back / 16.00 pm To : Next 20 Bars for example

This way, you are able to catch the value daily non single data corresponding to the Daily Low/high But, as you know, you can not use that for plotting historical data as the STAT days lookback period always start from the current day (i.e. today)...