What does hl2, ohlc4, and hlc3 do in thinkscript?


New member
There's a lot of interest here in indicators that use aggregation periods. Typically, the prices used for the indicators are the open or the close for the aggregation period, but plenty of other price types exist (e.g., hl2). If I wanted to use one of these other price types for an indicator, my concern is that there could be a delay in when those price types (e.g., hl2) become available for recent aggregation periods. For example, if I'm on a 5 minute aggregation period, how quickly will the hl2 for the most recent aggregation period become available - in enough time to make real-time decisions?


Well-known member
@BigBuzz Some Studies and Indicators already make use of hl2 and hlc3 for price calculations... I use hl2 quite often myself... The best way to determine the differences between price types is to display two charts, or more, side by side and observe how the price types change chart paints... You will observe timing and repainting differences... Don't take our word for it, experiment... After all, experimenting is free...

HL2 formula: (high+close)/2
HLC3 formula: (high+low+close)/3
HOLC4 formula: (high+open+low+close)/4


(Open+Close)/2 would be smoother the HL2 , but you would have to define (Open+Close)/2.

Using an Aggregation statement:

input agg1 = AggregationPeriod.FIVE_MIN;
input agg2 = AggregationPeriod.Thirty_MIN;
input agg3 = AggregationPeriod. Hour;

def openA = open(period = agg1);
def highA = high(period = agg1);
def lowA = low(period = agg1);
def closeA = close(period = agg1);
def openB = open(period = agg2);
def highB = high(period = agg2);
def lowB = low(period = agg2);
def closeB = close(period = agg2);
def openC = open(period = agg3);
def highC = high(period = agg3);
def lowC = low(period = agg3);
def closeC = close(period = agg3);

def PriceA = (OpenA+CloseA)/2;
def PriceB = (OpenB+CloseB)/2;
def PriceC = (OpenC+CloseC)/2;

Similar threads