Hurts MTF Indicator for ThinkorSwim

germanburrito

Active member
I found that by using the hurts indicators on different time frames the 5, 10, 15, 30, and hour can create walls that are difficult to break when this walls converge than the stock may become exhausted. The bigger the time frame the more difficult for the wall to move, however if the trend is strong then all walls may move at the same time, when there is a divergence then that means that the bigger time frames do not "care" about the smaller time frames. When the different time frames diverge too much, meaning the different time frames are closer to the 0 line and are at different prices than you might be in a stable, accumulation, or choppy market.

Code:
# Hurst_Oscillator
#
# www.trendxplorer.info
# [email protected]
#
# Build: July 25, 2012
# Rev 2: July 29, 2012: FlowPrice value to better reflect extremes
#

#
# --- script begin ----
#

declare lower;
input agg = AggregationPeriod.FIVE_MIN;
input price = hl2;
input length = 10;
input InnerValue = 1.6;
input OuterValue = 2.6;
input ExtremeValue = 4.2;

def displacement = (-length / 2) + 1;
def dPrice = price[displacement];

rec CMA = if !IsNaN(dPrice) then Average(dPrice, AbsValue(length)) else CMA[1] + (CMA[1] - CMA[2]);

#Rev 2: July 29, 2012: improved FlowPrice for better extremes
#def OscValue = if close > close[1] then high else if close < close[1] then low else (high + low)/2;
def OscValue =
    if high(period = agg) >= high(period = agg)[1] and low(period = agg) <= low(period = agg)[1]
    then
        if close(period = agg) >= close(period = agg)[1]    # high >= high[2]
        then high(period = agg)
        else low (period = agg)
    else
        if high(period = agg) > high(period = agg)[1]
        then high (period = agg)
        else
            if low(period = agg) < low(period = agg)[1]
            then low (period = agg)
            else
                if close (period = agg) > close(period = agg)[1]
                then high (period = agg)
                else
                    if close (period = agg) < close(period = agg)[1]
                    then low (period = agg)
                    else (high(period = agg) + low(period = agg)) / 2;

plot HurstOsc = (100 * OscValue / CMA) - 100;

HurstOsc.SetDefaultColor(GetColor(1));
HurstOsc.SetLineWeight(2);

input agg2 = AggregationPeriod.FIVE_MIN;
input price2 = hl2;


def displacement2 = (-length / 2) + 1;
def dPrice2 = price2[displacement2];

rec CMA2 = if !IsNaN(dPrice2) then Average(dPrice2, AbsValue(length)) else CMA2[1] + (CMA2[1] - CMA2[2]);


def OscValue2 =
    if high(period = agg2) >= high(period = agg2)[1] and low(period = agg2) <= low(period = agg2)[1]
    then
        if close(period = agg2) >= close(period = agg2)[1]    # high >= high[2]
        then high(period = agg2)
        else low (period = agg2)
    else
        if high(period = agg2) > high(period = agg2)[1]
        then high (period = agg2)
        else
            if low(period = agg2) < low(period = agg2)[1]
            then low (period = agg2)
            else
                if close (period = agg2) > close(period = agg2)[1]
                then high (period = agg2)
                else
                    if close (period = agg2) < close(period = agg2)[1]
                    then low (period = agg2)
                    else (high(period = agg2) + low(period = agg2)) / 2;
plot HurstOsc2 = (100 * OscValue2 / CMA2) - 100;

input agg3 = AggregationPeriod.FIVE_MIN;
input price3 = hl2;


def displacement3 = (-length / 2) + 1;
def dPrice3 = price3[displacement3];

rec CMA3 = if !IsNaN(dPrice3) then Average(dPrice3, AbsValue(length)) else CMA3[1] + (CMA3[1] - CMA3[2]);

#Rev 2: July 29, 2012: improved FlowPrice for better extremes
#def OscValue = if close > close[1] then high else if close < close[1] then low else (high + low)/2;
def OscValue3 =
    if high(period = agg3) >= high(period = agg3)[1] and low(period = agg3) <= low(period = agg3)[1]
    then
        if close(period = agg3) >= close(period = agg3)[1]    # high >= high[2]
        then high(period = agg3)
        else low (period = agg3)
    else
        if high(period = agg3) > high(period = agg3)[1]
        then high (period = agg3)
        else
            if low(period = agg3) < low(period = agg3)[1]
            then low (period = agg3)
            else
                if close (period = agg3) > close(period = agg3)[1]
                then high (period = agg3)
                else
                    if close (period = agg3) < close(period = agg3)[1]
                    then low (period = agg3)
                    else (high(period = agg3) + low(period = agg3)) / 2;
plot HurstOsc3 = (100 * OscValue3 / CMA3) - 100;




input agg4 = AggregationPeriod.FIVE_MIN;
input price4 = hl2;


def displacement4 = (-length / 2) + 1;
def dPrice4 = price4[displacement4];

rec CMA4 = if !IsNaN(dPrice4) then Average(dPrice4, AbsValue(length)) else CMA4[1] + (CMA4[1] - CMA4[2]);


def OscValue4 =
    if high(period = agg4) >= high(period = agg4)[1] and low(period = agg4) <= low(period = agg4)[1]
    then
        if close(period = agg4) >= close(period = agg4)[1]    # high >= high[2]
        then high(period = agg4)
        else low (period = agg4)
    else
        if high(period = agg4) > high(period = agg4)[1]
        then high (period = agg4)
        else
            if low(period = agg4) < low(period = agg4)[1]
            then low (period = agg4)
            else
                if close (period = agg4) > close(period = agg4)[1]
                then high (period = agg4)
                else
                    if close (period = agg4) < close(period = agg4)[1]
                    then low (period = agg4)
                    else (high(period = agg4) + low(period = agg4)) / 2;
plot HurstOsc4 = (100 * OscValue4 / CMA4) - 100;

input agg5 = AggregationPeriod.FIVE_MIN;
input price5 = hl2;


def displacement5 = (-length / 2) + 1;
def dPrice5 = price5[displacement5];

rec CMA5 = if !IsNaN(dPrice5) then Average(dPrice5, AbsValue(length)) else CMA5[1] + (CMA5[1] - CMA5[2]);


def OscValue5 =
    if high(period = agg5) >= high(period = agg5)[1] and low(period = agg5) <= low(period = agg5)[1]
    then
        if close(period = agg5) >= close(period = agg5)[1]    # high >= high[2]
        then high(period = agg5)
        else low (period = agg5)
    else
        if high(period = agg5) > high(period = agg5)[1]
        then high (period = agg5)
        else
            if low(period = agg5) < low(period = agg5)[1]
            then low (period = agg5)
            else
                if close (period = agg5) > close(period = agg5)[1]
                then high (period = agg5)
                else
                    if close (period = agg5) < close(period = agg5)[1]
                    then low (period = agg5)
                    else (high(period = agg5) + low(period = agg5)) / 2;
plot HurstOsc5 = (100 * OscValue5 / CMA5) - 100;
plot CenterLine       =   0;
plot UpperExtremeBand =   ExtremeValue;
plot LowerExtremeBand = - ExtremeValue;
plot UpperOuterBand   =   OuterValue;
plot LowerOuterBand   = - OuterValue;
plot UpperInnerBand   =   InnerValue;
plot LowerInnerBand   = - InnerValue;

CenterLine.SetDefaultColor(GetColor(7));
CenterLine.SetLineWeight(1);

UpperExtremeBand.SetDefaultColor(GetColor(4));
UpperExtremeBand.SetLineWeight(1);
LowerExtremeBand.SetDefaultColor(GetColor(4));
LowerExtremeBand.SetLineWeight(1);
UpperExtremeBand.Hide();
LowerExtremeBand.Hide();

UpperOuterBand.SetDefaultColor(GetColor(5));
UpperOuterBand.SetLineWeight(1);
LowerOuterBand.SetDefaultColor(GetColor(6));
LowerOuterBand.SetLineWeight(1);

UpperInnerBand.SetDefaultColor(GetColor(5));
UpperInnerBand.SetLineWeight(1);
UpperInnerBand.SetStyle(Curve.SHORT_DASH);
LowerInnerBand.SetDefaultColor(GetColor(6));
LowerInnerBand.SetLineWeight(1);
LowerInnerBand.SetStyle(Curve.SHORT_DASH);

# Turn AddClouds off by putting a #-sign at the first position of the lines
AddCloud(UpperOuterBand, UpperInnerBand, Color.RED);
AddCloud(LowerInnerBand, LowerOuterBand, Color.GREEN);

#
# --- script end ----
#
 

henry1224

Active member
VIP
GermanBurrito, your Hurst Osc doesn't define the HL2 for each Agg Period, It uses the First Agg HL2 value for all of the time frames
here is the cleaned up version

Code:
###########
Declare lower;
input AGG1 = AggregationPeriod.FIVE_MIN;
input AGG2 = AggregationPeriod.FIFTEEN_MIN;
input AGG3 = AggregationPeriod.THIRTY_MIN;
input AGG4 = AggregationPeriod.HOUR;
input AGG5 = AggregationPeriod.Day;
input length = 10;
input InnerValue = 1.6;
input OuterValue = 2.6;
input ExtremeValue = 4.2;
Def PriceA = HL2(Period = AGG1);
Def PriceB = HL2(Period = AGG2);
Def PriceC = HL2(Period = AGG3);
Def PriceD = HL2(Period = AGG4);
Def PriceE = HL2(Period = AGG5);
Def HA = High(Period = AGG1);
Def HB = High(Period = AGG2);
Def HC = High(Period = AGG3);
Def HD = High(Period = AGG4);
Def HE = High(Period = AGG5);
Def LA = Low(Period = AGG1);
Def LB = Low(Period = AGG2);
Def LC = Low(Period = AGG3);
Def LD = Low(Period = AGG4);
Def LE = Low(Period = AGG5);
Def CA = Close(Period = AGG1);
Def CB = Close(Period = AGG2);
Def CC = Close(Period = AGG3);
Def CD = Close(Period = AGG4);
Def CE = Close(Period = AGG5);
Def Displacement = (-length/2)+1;
Def DPriceA = PriceA[Displacement];
Def DPriceB = PriceB[Displacement];
Def DPriceC = PriceC[Displacement];
Def DPriceD = PriceD[Displacement];
Def DPriceE = PriceE[Displacement];

Rec CMAA = if !IsNaN(DPriceA) then Average(DPriceA, AbsValue(length)) else CMAA[1] + (CMAA[1] - CMAA[2]);
Rec CMAB = if !IsNaN(DPriceB) then Average(DPriceB, AbsValue(length)) else CMAB[1] + (CMAB[1] - CMAB[2]);
Rec CMAC = if !IsNaN(DPriceC) then Average(DPriceC, AbsValue(length)) else CMAC[1] + (CMAC[1] - CMAC[2]);
Rec CMAD = if !IsNaN(DPriceD) then Average(DPriceD, AbsValue(length)) else CMAD[1] + (CMAD[1] - CMAD[2]);
Rec CMAE = if !IsNaN(DPriceE) then Average(DPriceE, AbsValue(length)) else CMAE[1] + (CMAE[1] - CMAE[2]);


def OscValueA =
    if HA >= HA[1] and LA <= LA[1]
    then
        if CA >= CA[1]    # high >= high[2]
        then HA
        else LA
    else
        if HA > HA[1]
        then HA
        else
            if LA < LA[1]
            then LA
            else
                if CA > CA[1]
                then HA
                else
                    if CA < CA[1]
                    then LA
                    else (HA + LA) / 2;

plot HurstOscA = (100 * OscValueA / CMAA) - 100;

HurstOscA.SetDefaultColor(GetColor(1));
HurstOscA.SetLineWeight(2);

def OscValueB =
    if HB >= HB[1] and LB <= LB[1]
    then
        if CB >= CB[1]    # high >= high[2]
        then HB
        else LB
    else
        if HB > HB[1]
        then HB
        else
            if LB < LB[1]
            then LB
            else
                if CB > CB[1]
                then HB
                else
                    if CB < CB[1]
                    then LB
                    else (HB + LB) / 2;

plot HurstOscB = (100 * OscValueB / CMAB) - 100;

def OscValueC =
    if HC >= HC[1] and LC <= LC[1]
    then
        if CC >= CC[1]    # high >= high[2]
        then HC
        else LC
    else
        if HC > HC[1]
        then HC
        else
            if LC < LC[1]
            then LC
            else
                if CC > CC[1]
                then HC
                else
                    if CC < CC[1]
                    then LC
                    else (HC + LC) / 2;

plot HurstOscC = (100 * OscValueC / CMAC) - 100;

def OscValueD =
    if HD >= HD[1] and LD <= LD[1]
    then
        if CD >= CD[1]    # high >= high[2]
        then HD
        else LD
    else
        if HD > HD[1]
        then HD
        else
            if LD < LD[1]
            then LD
            else
                if CD > CD[1]
                then HD
                else
                    if CD < CD[1]
                    then LD
                    else (HD + LD) / 2;

plot HurstOscD = (100 * OscValueD / CMAD) - 100;

def OscValueE =
    if HE >= HE[1] and LE <= LE[1]
    then
        if CE >= CE[1]    # high >= high[2]
        then HE
        else LE
    else
        if HE > HE[1]
        then HE
        else
            if LE < LE[1]
            then LE
            else
                if CE > CE[1]
                then HE
                else
                    if CE < CE[1]
                    then LE
                    else (HE + LE) / 2;

plot HurstOscE = (100 * OscValueE / CMAE) - 100;

plot CenterLine       =   0;
plot UpperExtremeBand =   ExtremeValue;
plot LowerExtremeBand = - ExtremeValue;
plot UpperOuterBand   =   OuterValue;
plot LowerOuterBand   = - OuterValue;
plot UpperInnerBand   =   InnerValue;
plot LowerInnerBand   = - InnerValue;

CenterLine.SetDefaultColor(GetColor(7));
CenterLine.SetLineWeight(1);

UpperExtremeBand.SetDefaultColor(GetColor(4));
UpperExtremeBand.SetLineWeight(1);
LowerExtremeBand.SetDefaultColor(GetColor(4));
LowerExtremeBand.SetLineWeight(1);
UpperExtremeBand.Hide();
LowerExtremeBand.Hide();

UpperOuterBand.SetDefaultColor(GetColor(5));
UpperOuterBand.SetLineWeight(1);
LowerOuterBand.SetDefaultColor(GetColor(6));
LowerOuterBand.SetLineWeight(1);

UpperInnerBand.SetDefaultColor(GetColor(5));
UpperInnerBand.SetLineWeight(1);
UpperInnerBand.SetStyle(Curve.SHORT_DASH);
LowerInnerBand.SetDefaultColor(GetColor(6));
LowerInnerBand.SetLineWeight(1);
LowerInnerBand.SetStyle(Curve.SHORT_DASH);

# Turn AddClouds off by putting a #-sign at the first position of the lines
AddCloud(UpperOuterBand, UpperInnerBand, Color.RED);
AddCloud(LowerInnerBand, LowerOuterBand, Color.GREEN);
 

henry1224

Active member
VIP
GermanBurrito here is my Binary version of the Hurst Osc
The lowest time frame is on the bottom and rises for each higher time frame
the highest line is squares and shows a consensus of the Osc

Here is the code This has been corrected and should now be used

Henry

Code:
#############
Declare lower;
DefineGlobalColor("TrendUp", Color.Cyan);
DefineGlobalColor("TrendDown", Color.Magenta);

input AGG1 = AggregationPeriod.FIVE_MIN;
input AGG2 = AggregationPeriod.FIFTEEN_MIN;
input AGG3 = AggregationPeriod.THIRTY_MIN;
input AGG4 = AggregationPeriod.HOUR;
input AGG5 = AggregationPeriod.Day;
input length = 10;

input DotSize = 4;
input n = 6;
def n1  = n + 1;

Def PriceA = HL2(Period = AGG1);
Def PriceB = HL2(Period = AGG2);
Def PriceC = HL2(Period = AGG3);
Def PriceD = HL2(Period = AGG4);
Def PriceE = HL2(Period = AGG5);
Def HA = High(Period = AGG1);
Def HB = High(Period = AGG2);
Def HC = High(Period = AGG3);
Def HD = High(Period = AGG4);
Def HE = High(Period = AGG5);
Def LA = Low(Period = AGG1);
Def LB = Low(Period = AGG2);
Def LC = Low(Period = AGG3);
Def LD = Low(Period = AGG4);
Def LE = Low(Period = AGG5);
Def CA = Close(Period = AGG1);
Def CB = Close(Period = AGG2);
Def CC = Close(Period = AGG3);
Def CD = Close(Period = AGG4);
Def CE = Close(Period = AGG5);
Def Displacement = (-length/2)+1;
Def DPriceA = PriceA[Displacement];
Def DPriceB = PriceB[Displacement];
Def DPriceC = PriceC[Displacement];
Def DPriceD = PriceD[Displacement];
Def DPriceE = PriceE[Displacement];

Rec CMAA = if !IsNaN(DPriceA) then Average(DPriceA, AbsValue(length)) else CMAA[1] + (CMAA[1] - CMAA[2]);
Rec CMAB = if !IsNaN(DPriceB) then Average(DPriceB, AbsValue(length)) else CMAB[1] + (CMAB[1] - CMAB[2]);
Rec CMAC = if !IsNaN(DPriceC) then Average(DPriceC, AbsValue(length)) else CMAC[1] + (CMAC[1] - CMAC[2]);
Rec CMAD = if !IsNaN(DPriceD) then Average(DPriceD, AbsValue(length)) else CMAD[1] + (CMAD[1] - CMAD[2]);
Rec CMAE = if !IsNaN(DPriceE) then Average(DPriceE, AbsValue(length)) else CMAE[1] + (CMAE[1] - CMAE[2]);


def OscValueA =
    if HA >= HA[1] and LA <= LA[1]
    then
        if CA >= CA[1]    # high >= high[2]
        then HA
        else LA
    else
        if HA > HA[1]
        then HA
        else
            if LA < LA[1]
            then LA
            else
                if CA > CA[1]
                then HA
                else
                    if CA < CA[1]
                    then LA
                    else (HA + LA) / 2;

Def HurstOscA = (100 * OscValueA / CMAA) - 100;

def OscValueB =
    if HB >= HB[1] and LB <= LB[1]
    then
        if CB >= CB[1]    # high >= high[2]
        then HB
        else LB
    else
        if HB > HB[1]
        then HB
        else
            if LB < LB[1]
            then LB
            else
                if CB > CB[1]
                then HB
                else
                    if CB < CB[1]
                    then LB
                    else (HB + LB) / 2;

Def HurstOscB = (100 * OscValueB / CMAB) - 100;

def OscValueC =
    if HC >= HC[1] and LC <= LC[1]
    then
        if CC >= CC[1]    # high >= high[2]
        then HC
        else LC
    else
        if HC > HC[1]
        then HC
        else
            if LC < LC[1]
            then LC
            else
                if CC > CC[1]
                then HC
                else
                    if CC < CC[1]
                    then LC
                    else (HC + LC) / 2;

Def HurstOscC = (100 * OscValueC / CMAC) - 100;

def OscValueD =
    if HD >= HD[1] and LD <= LD[1]
    then
        if CD >= CD[1]    # high >= high[2]
        then HD
        else LD
    else
        if HD > HD[1]
        then HD
        else
            if LD < LD[1]
            then LD
            else
                if CD > CD[1]
                then HD
                else
                    if CD < CD[1]
                    then LD
                    else (HD + LD) / 2;

Def HurstOscD = (100 * OscValueD / CMAD) - 100;

def OscValueE =
    if HE >= HE[1] and LE <= LE[1]
    then
        if CE >= CE[1]    # high >= high[2]
        then HE
        else LE
    else
        if HE > HE[1]
        then HE
        else
            if LE < LE[1]
            then LE
            else
                if CE > CE[1]
                then HE
                else
                    if CE < CE[1]
                    then LE
                    else (HE + LE) / 2;

Def HurstOscE = (100 * OscValueE / CMAE) - 100;

plot HOA_Dot = if IsNaN(CA) then Double.NaN else 1;
HOA_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOA_Dot.SetLineWeight(DotSize);
HOA_Dot.AssignValueColor(if HurstOscA < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

plot HOB_Dot = if IsNaN(CB) then Double.NaN else 2;
HOB_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOB_Dot.SetLineWeight(DotSize);
HOB_Dot.AssignValueColor(if HurstOscB < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

plot HOC_Dot = if IsNaN(CC) then Double.NaN else 3;

HOC_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOC_Dot.SetLineWeight(DotSize);
HOC_Dot.AssignValueColor(if HurstOscC < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

plot HOD_Dot = if IsNaN(CD) then Double.NaN else 4;
HOD_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOD_Dot.SetLineWeight(DotSize);
HOD_Dot.AssignValueColor(if HurstOscD < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

plot HOE_Dot = if IsNaN(CE) then Double.NaN else 5;
HOE_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOE_Dot.SetLineWeight(DotSize);
HOE_Dot.AssignValueColor(if HurstOscE < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

Def B1 = If(HurstOscA>=0,1,0);
Def B2 = If(HurstOscB>=0,1,0);
Def B3 = If(HurstOscC>=0,1,0);
Def B4= If(HurstOscD>=0,1,0);
Def B5 = If(HurstOscE>=0,1,0);


plot MTF_BDot = 6;
MTF_BDot.SetPaintingStrategy(PaintingStrategy.SQUARES);
MTF_BDot.SetLineWeight(lineWeight = 4);
MTF_BDot.DefineColor("Buy", Color.Green);
MTF_BDot.DefineColor("Sell", Color.Red);
MTF_BDot.AssignValueColor ( if (B1+B2+B3+B4+B5) >= 3 then MTF_BDot.Color("Buy") else MTF_BDot.Color("Sell"));
 
Last edited:

germanburrito

Active member
@henry1224 I think there was a small error in the code I might have fixed it, I don't know if I fixed it, but when I changed one of the plots and it seems to be working, this is a really amazing indicator from what I have seen so far.
 

Nomak

Member
2019 Donor
Got a 3 line error on this:

plot HOA_Dot = if IsNaN(CC) then Double.NaN else 3;
HOC_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOC_Dot.SetLineWeight(DotSize);
HOC_Dot.AssignValueColor(if HurstOscC < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
 

henry1224

Active member
VIP
Got a 3 line error on this:

plot HOA_Dot = if IsNaN(CC) then Double.NaN else 3;
HOC_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOC_Dot.SetLineWeight(DotSize);
HOC_Dot.AssignValueColor(if HurstOscC < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));
I corrected the code , try to create it again

Henry
 

henry1224

Active member
VIP
For any future viewers of this thread, it should be noted that this indicator has no historical veracity as it is a repainting indicator.
https://usethinkscript.com/threads/is-there-hurst-exponent-in-tos.2445/#post-22932
MerryDay, The top line"#6" which is the consensus vote line will repaint until the higher time frames complete! I can't comment about the HURST Osc. But as with all Higher time frames AGG formulas, the higher time frame has to finish making it's bar
 

MerryDay

Well-known member
VIP
@germanburrito @henry1224
While MTF indicators are NOT done 'painting' until the highest agg is completed; Hurst Bands have the added complication of repainting many candles back.
See URL in my above post or just google Hurst Bands repaint.

If they are working for you when you combine them into your strategy, you should keep using them.
My post was directed at future viewers of this thread.
 

henry1224

Active member
VIP
GermanBurrito here is my Binary version of the Hurst Osc
The lowest time frame is on the bottom and rises for each higher time frame
the highest line is squares and shows a consensus of the Osc

Here is the code This has been corrected and should now be used

Henry

Code:
#############
Declare lower;
DefineGlobalColor("TrendUp", Color.Cyan);
DefineGlobalColor("TrendDown", Color.Magenta);

input AGG1 = AggregationPeriod.FIVE_MIN;
input AGG2 = AggregationPeriod.FIFTEEN_MIN;
input AGG3 = AggregationPeriod.THIRTY_MIN;
input AGG4 = AggregationPeriod.HOUR;
input AGG5 = AggregationPeriod.Day;
input length = 10;

input DotSize = 4;
input n = 6;
def n1  = n + 1;

Def PriceA = HL2(Period = AGG1);
Def PriceB = HL2(Period = AGG2);
Def PriceC = HL2(Period = AGG3);
Def PriceD = HL2(Period = AGG4);
Def PriceE = HL2(Period = AGG5);
Def HA = High(Period = AGG1);
Def HB = High(Period = AGG2);
Def HC = High(Period = AGG3);
Def HD = High(Period = AGG4);
Def HE = High(Period = AGG5);
Def LA = Low(Period = AGG1);
Def LB = Low(Period = AGG2);
Def LC = Low(Period = AGG3);
Def LD = Low(Period = AGG4);
Def LE = Low(Period = AGG5);
Def CA = Close(Period = AGG1);
Def CB = Close(Period = AGG2);
Def CC = Close(Period = AGG3);
Def CD = Close(Period = AGG4);
Def CE = Close(Period = AGG5);
Def Displacement = (-length/2)+1;
Def DPriceA = PriceA[Displacement];
Def DPriceB = PriceB[Displacement];
Def DPriceC = PriceC[Displacement];
Def DPriceD = PriceD[Displacement];
Def DPriceE = PriceE[Displacement];

Rec CMAA = if !IsNaN(DPriceA) then Average(DPriceA, AbsValue(length)) else CMAA[1] + (CMAA[1] - CMAA[2]);
Rec CMAB = if !IsNaN(DPriceB) then Average(DPriceB, AbsValue(length)) else CMAB[1] + (CMAB[1] - CMAB[2]);
Rec CMAC = if !IsNaN(DPriceC) then Average(DPriceC, AbsValue(length)) else CMAC[1] + (CMAC[1] - CMAC[2]);
Rec CMAD = if !IsNaN(DPriceD) then Average(DPriceD, AbsValue(length)) else CMAD[1] + (CMAD[1] - CMAD[2]);
Rec CMAE = if !IsNaN(DPriceE) then Average(DPriceE, AbsValue(length)) else CMAE[1] + (CMAE[1] - CMAE[2]);


def OscValueA =
    if HA >= HA[1] and LA <= LA[1]
    then
        if CA >= CA[1]    # high >= high[2]
        then HA
        else LA
    else
        if HA > HA[1]
        then HA
        else
            if LA < LA[1]
            then LA
            else
                if CA > CA[1]
                then HA
                else
                    if CA < CA[1]
                    then LA
                    else (HA + LA) / 2;

Def HurstOscA = (100 * OscValueA / CMAA) - 100;

def OscValueB =
    if HB >= HB[1] and LB <= LB[1]
    then
        if CB >= CB[1]    # high >= high[2]
        then HB
        else LB
    else
        if HB > HB[1]
        then HB
        else
            if LB < LB[1]
            then LB
            else
                if CB > CB[1]
                then HB
                else
                    if CB < CB[1]
                    then LB
                    else (HB + LB) / 2;

Def HurstOscB = (100 * OscValueB / CMAB) - 100;

def OscValueC =
    if HC >= HC[1] and LC <= LC[1]
    then
        if CC >= CC[1]    # high >= high[2]
        then HC
        else LC
    else
        if HC > HC[1]
        then HC
        else
            if LC < LC[1]
            then LC
            else
                if CC > CC[1]
                then HC
                else
                    if CC < CC[1]
                    then LC
                    else (HC + LC) / 2;

Def HurstOscC = (100 * OscValueC / CMAC) - 100;

def OscValueD =
    if HD >= HD[1] and LD <= LD[1]
    then
        if CD >= CD[1]    # high >= high[2]
        then HD
        else LD
    else
        if HD > HD[1]
        then HD
        else
            if LD < LD[1]
            then LD
            else
                if CD > CD[1]
                then HD
                else
                    if CD < CD[1]
                    then LD
                    else (HD + LD) / 2;

Def HurstOscD = (100 * OscValueD / CMAD) - 100;

def OscValueE =
    if HE >= HE[1] and LE <= LE[1]
    then
        if CE >= CE[1]    # high >= high[2]
        then HE
        else LE
    else
        if HE > HE[1]
        then HE
        else
            if LE < LE[1]
            then LE
            else
                if CE > CE[1]
                then HE
                else
                    if CE < CE[1]
                    then LE
                    else (HE + LE) / 2;

Def HurstOscE = (100 * OscValueE / CMAE) - 100;

plot HOA_Dot = if IsNaN(CA) then Double.NaN else 1;
HOA_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOA_Dot.SetLineWeight(DotSize);
HOA_Dot.AssignValueColor(if HurstOscA < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

plot HOB_Dot = if IsNaN(CB) then Double.NaN else 2;
HOB_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOB_Dot.SetLineWeight(DotSize);
HOB_Dot.AssignValueColor(if HurstOscB < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

plot HOC_Dot = if IsNaN(CC) then Double.NaN else 3;

HOC_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOC_Dot.SetLineWeight(DotSize);
HOC_Dot.AssignValueColor(if HurstOscC < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

plot HOD_Dot = if IsNaN(CD) then Double.NaN else 4;
HOD_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOD_Dot.SetLineWeight(DotSize);
HOD_Dot.AssignValueColor(if HurstOscD < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

plot HOE_Dot = if IsNaN(CE) then Double.NaN else 5;
HOE_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
HOE_Dot.SetLineWeight(DotSize);
HOE_Dot.AssignValueColor(if HurstOscE < 0 then GlobalColor("TrendDown") else GlobalColor("TrendUp"));

Def B1 = If(HurstOscA>=0,1,0);
Def B2 = If(HurstOscB>=0,1,0);
Def B3 = If(HurstOscC>=0,1,0);
Def B4= If(HurstOscD>=0,1,0);
Def B5 = If(HurstOscE>=0,1,0);


plot MTF_BDot = 6;
MTF_BDot.SetPaintingStrategy(PaintingStrategy.SQUARES);
MTF_BDot.SetLineWeight(lineWeight = 4);
MTF_BDot.DefineColor("Buy", Color.Green);
MTF_BDot.DefineColor("Sell", Color.Red);
MTF_BDot.AssignValueColor ( if (B1+B2+B3+B4+B5) >= 3 then MTF_BDot.Color("Buy") else MTF_BDot.Color("Sell"));
The IDEA from the HURST OSC is if the current time frame' Hurst Osc is above or below 0,
you can see the Hurst OSC from 5 time frames and then see the consensus to make your decision
Remember that there is lag in all indicators , so look for improvement of the indicator or a worsening condition
 

MerryDay

Well-known member
VIP
The IDEA from the HURST OSC is if the current time frame' Hurst Osc is above or below 0,
you can see the Hurst OSC from 5 time frames and then see the consensus to make your decision
Remember that there is lag in all indicators , so look for improvement of the indicator or a worsening condition
@henry1224
You worded it much better than I! The BEST use of Hurst Bands is in the current time frame.
It has no historical veracity due to the constant repainting of past bars.
 

germanburrito

Active member
MerryDay, The top line"#6" which is the consensus vote line will repaint until the higher time frames complete! I can't comment about the HURST Osc. But as with all Higher time frames AGG formulas, the higher time frame has to finish making it's bar
the binary code looks to tell you the overall move, and the oscillator seems to predict the exhaustion when the points converge, as well as a representation of how ow they stock might fall, i will need to test it more, but so far it seems great i have other ideas we can work on.
 
Thread starter Similar threads Forum Replies Date
P rsi lagurre as mtf upper Custom 1
K ADX MTF Custom 0
F MTF strategy triggers in the past when trading real time Questions 7
R MTF Labels and a Question Questions 0
F Previous H/L MTF Questions 2

Similar threads

Top