Help complete this FE and Hurst Exp. coding request?

YungTraderFromMontana

Well-known member
There is one crucial signal of the fe and hurst exponent waves I use that I can not seem to get into code. If anyone can do this it will be the next big breakthrough for my Ultimate indicator thread and the community as well as myself would greatly appreciate it.

Here's the puzzle, along with the signal of these studies which is simply looking for a strong movement up or down, a second signal that can be easily seen with the eyes but difficult to translate the code is the difference between periods of seemingly random readings as compared to periods of precise readings of these indicators. Here are some examples. Remember that fe and he are non-directional. Ignore the acc/dist study at the bottom, this is somewhat of a csa I use. FE is in yellow/green/blue/purple and HE is in red/orange/yellow/purple, these studies are simply multiple lengths of the study.

In this picture I highlighted the areas I would call random and left alone the areas I would say the indicator readings are amalgamated.
Notice the different characteristics of these different states, random gaps between the lines and highly varied linear direction of the different fe lengths tell me to avoid a trade, when the lines form a synchronized sort of wave in length order with only gaps between lower lengths this tells me that the stock will trend after a breakout. These are the factors I want to be able to gauge somehow.

wXPnQmf.png


I'm going to put the code at the end for reference.


I really hope one of you will take on the challenge, it's certainly a difficult challenge that I have failed at many times. Although I can see the signals with my own eyes but this would save precious time when it comes to scan stocks by narrowing down the total amount of results massively. Please ask any questions if you have any.

Code:
# TheoTrade RSI in Laguerre Time Self Adjusting With Fractal Energy
# Mobius
# V03.06.15.2016
# Both Fractal Energy and RSI are plotted. RSI in cyan and FE in yellow. Look for trend exhaustion in the FE and a reversal of RSI or Price compression in FE and an RSI reversal.


declare lower;

input length69 = 4;
def factor = .869;
input mode = {default Range, ATR};

def range;
switch (mode) {
case Range:
    range = Highest(high, length69) - Lowest(low, length69);

case ATR:
    range = reference ATR();
}

plot RangeRatio = (range / range[length69])/20;
plot RangeFactor = factor/20;

RangeRatio.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RangeRatio.DefineColor("Consolidation", GetColor(4));
RangeRatio.DefineColor("Non-consolidation", GetColor(1));

RangeRatio.AssignValueColor( if (RangeRatio < RangeFactor) then RangeRatio.Color("Consolidation") else RangeRatio.Color("Non-consolidation"));
RangeFactor.SetDefaultColor(GetColor(7));

input length2 = 5;
input length3 = 7;
input length4 = 9;
input length5 = 11;
input length6 = 13;
input length7 = 17;


input averageType = AverageType.EXPONENTIAL;
input lengthave =2;

def ll2 = Lowest(low, length2);
def hh2 = Highest(high, length2);
def atr2 = MovingAverage(averageType, TrueRange(high, close, low), length2);
def tmp_H2 = (Log(hh2 - ll2) - Log(atr2)) / (Log(length2));

plot H2;
if tmp_H2 > 1
then {
    H2 = 1;
} else if tmp_H2 < 0 {
    H2 = 0;
} else {
    H2 = tmp_H2;
}
def ll3 = Lowest(low, length3);
def hh3 = Highest(high, length3);
def atr3 = MovingAverage(averageType, TrueRange(high, close, low), length3);
def tmp_H3 = (Log(hh3 - ll3) - Log(atr3)) / (Log(length3));

plot H3;
if tmp_H3 > 1
then {
    H3 = 1;
} else if tmp_H3 < 0 {
    H3 = 0;
} else {
    H3 = tmp_H3;
}

def ll4 = Lowest(low, length4);
def hh4 = Highest(high, length4);
def atr4 = MovingAverage(averageType, TrueRange(high, close, low), length4);
def tmp_H4 = (Log(hh4 - ll4) - Log(atr4)) / (Log(length4));

plot H4;
if tmp_H4 > 1
then {
    H4 = 1;
} else if tmp_H4 < 0 {
    H4 = 0;
} else {
    H4 = tmp_H4;
}

def ll5 = Lowest(low, length5);
def hh5 = Highest(high, length5);
def atr5 = MovingAverage(averageType, TrueRange(high, close, low), length5);
def tmp_H5 = (Log(hh5 - ll5) - Log(atr5)) / (Log(length5));

plot H5;
if tmp_H5 > 1
then {
    H5 = 1;
} else if tmp_H5 < 0 {
    H5 = 0;
} else {
    H5 = tmp_H5;
}

def ll6 = Lowest(low, length6);
def hh6 = Highest(high, length6);
def atr6 = MovingAverage(averageType, TrueRange(high, close, low), length6);
def tmp_H6 = (Log(hh6 - ll6) - Log(atr6)) / (Log(length6));

plot H6;
if tmp_H6 > 1
then {
    H6 = 1;
} else if tmp_H6 < 0 {
    H6 = 0;
} else {
    H6 = tmp_H6;
}

def ll7 = Lowest(low, length7);
def hh7 = Highest(high, length7);
def atr7 = MovingAverage(averageType, TrueRange(high, close, low), length7);
def tmp_H7 = (Log(hh7 - ll7) - Log(atr7)) / (Log(length7));

plot H7;
if tmp_H7 > 1
then {
    H7 = 1;
} else if tmp_H7 < 0 {
    H7 = 0;
} else {
    H7 = tmp_H7;
}
h2.SetDefaultColor(Color.light_red);
h3.SetDefaultColor(Color.red);
h4.SetDefaultColor(Color.orange);
h5.SetDefaultColor(Color.plum);
h6.SetDefaultColor(Color.violet);
h7.SetDefaultColor(Color.blue);

plot high = .6;
plot low = .4;
#Inputs:
input nfe1 = 1;
input nfe2 = 2;
input nfe3 = 3;
input nfe4 = 4;
input nfe5 = 5;
input nfe6 = 6;
input nfe7 = 7;
input nfe8 = 8;
input nfe9 = 9;
input nfe10 = 10;
input nfe11 = 11;
input nfe12 = 12;
input nfe13 = 13;
input nfe14 = 14;
input nfe15 = 15;
input nfe16 = 16;
input nfe17 = 17;
input nfe18 = 18;
input nfe19 = 19;
input nfe20 = 20;
input length = 10;
input smoothingLength = 5;



#hint nFE: length for Fractal Energy calculation.
# Variables:
def o;
def h;
def l;
def c;

# Calculations
o = (open + close[1]) / 2;
h = Max(high, close[1]);
l = Min(low, close[1]);
c = (o + h + l + close) / 4;

# Gamma Function
script gammax {
    input nFEi = 12;
    def FE =  Log(Sum((Max(high, close[1]) - Min(low, close[1])), nFEi) /
        (Highest(high, nFEi) - Lowest(low, nFEi)))
            / Log(nFEi);
    plot gamma = FE + .8;
}


plot gamma = gammax(nfe1);
gamma.SetDefaultColor(Color.CYAN);
plot gamma2 = gammax(nfe2);
gamma2.SetDefaultColor(Color.YELLOW);
gamma2.SetLineWeight(2);
plot gamma3 = gammax(nfe3);
gamma3.SetDefaultColor(Color.YELLOW);
gamma3.SetLineWeight(2);
plot gamma4 = gammax(nfe4);
gamma4.SetDefaultColor(Color.YELLOW);
gamma4.SetLineWeight(2);
plot gamma5 = gammax(nfe5);
gamma5.SetDefaultColor(Color.YELLOW);
gamma5.SetLineWeight(2);
plot gamma6 = gammax(nfe6);
gamma6.SetDefaultColor(Color.GREEN);
plot gamma7 = gammax(nfe7);
gamma7.SetDefaultColor(Color.GREEN);
plot gamma8 = gammax(nfe8);
gamma8.SetDefaultColor(Color.GREEN);
plot gamma9 = gammax(nfe9);
gamma9.SetDefaultColor(Color.GREEN);
plot gamma10 = gammax(nfe10);
gamma10.SetDefaultColor(Color.GREEN);
plot gamma11 = gammax(nfe11);
gamma11.SetDefaultColor(Color.CYAN);
plot gamma12 = gammax(nfe12);
gamma12.SetDefaultColor(Color.CYAN);
plot gamma13 = gammax(nfe13);
gamma13.SetDefaultColor(Color.CYAN);
plot gamma14 = gammax(nfe14);
gamma14.SetDefaultColor(Color.CYAN);
plot gamma15 = gammax(nfe15);
gamma15.SetDefaultColor(Color.CYAN);
plot gamma16 = gammax(nfe16);
gamma16.SetDefaultColor(Color.VIOLET);
plot gamma17 = gammax(nfe17);
gamma17.SetDefaultColor(Color.VIOLET);
plot gamma18 = gammax(nfe18);
gamma18.SetDefaultColor(Color.VIOLET);
plot gamma19 = gammax(nfe19);
gamma19.SetDefaultColor(Color.VIOLET);
plot gamma20 = gammax(nfe20);
gamma20.SetDefaultColor(Color.VIOLET);

def gammasector1 = (gamma2 + gamma3 + gamma4 + gamma5) / 4;
def gammasector2 = (gamma6 + gamma7 + gamma8 + gamma9 + gamma10) / 5;
def gammasector3 = (gamma11 + gamma12 + gamma13 + gamma14 + gamma15) / 5;
def gammasector4 = (gamma16 + gamma17 + gamma18 + gamma19 + gamma20) / 5;
def gammasectorcombo = (gammasector3 + gammasector4) / 2;


def gammasector22 = ((gammasector2 - gammasector4) *(gammasector2 - gammasector4)) * 1000;



#plot feblast = gammasector1[1] > gammasector1 and gammasector2[1] > gammasector2 and gammasectorcombo[1] > gammasectorcombo and close > trueqb2;
@mashume @diazlaz @horserider @markos @BenTen
 
Last edited by a moderator:
@YungTraderFromMontana
Here's a screen grab. Rough. Very. Code below.

The white boxes match the times you showed above. :)

1JziFyM.png


Here's the code, to add to the end of your original indicator -- no colors, nothing fancy

Code:
input slopelength = 2;
def sg1 = linearRegressionSlope(price = gamma1, length = slopeLength);
def sg2 = linearRegressionSlope(price = gamma2, length = slopeLength);
def sg3 = linearRegressionSlope(price = gamma3, length = slopeLength);
def sg4 = linearRegressionSlope(price = gamma4, length = slopeLength);
def sg5 = linearRegressionSlope(price = gamma5, length = slopeLength);
def sg6 = linearRegressionSlope(price = gamma6, length = slopeLength);
def sg7 = linearRegressionSlope(price = gamma7, length = slopeLength);
def sg8 = linearRegressionSlope(price = gamma8, length = slopeLength);
def sg9 = linearRegressionSlope(price = gamma9, length = slopeLength);
def sg10 = linearRegressionSlope(price = gamma10, length = slopeLength);
def sg11 = linearRegressionSlope(price = gamma11, length = slopeLength);
def sg12 = linearRegressionSlope(price = gamma12, length = slopeLength);
def sg13 = linearRegressionSlope(price = gamma13, length = slopeLength);
def sg14 = linearRegressionSlope(price = gamma14, length = slopeLength);
def sg15 = linearRegressionSlope(price = gamma15, length = slopeLength);
def sg16 = linearRegressionSlope(price = gamma16, length = slopeLength);
def sg17 = linearRegressionSlope(price = gamma17, length = slopeLength);
def sg18 = linearRegressionSlope(price = gamma18, length = slopeLength);
def sg19 = linearRegressionSlope(price = gamma19, length = slopeLength);
def sg20 = linearRegressionSlope(price = gamma20, length = slopeLength);

def g1 = (sg2 + sg3 + sg4 + sg5) / 4;
def g2 = (sg6 + sg7 + sg8 + sg9 + sg10) / 5;
def g3 = (sg11 + sg12 + sg13 + sg14 + sg15) / 5;
def g4 = (sg16 + sg17 + sg18 + sg19 + sg20) / 5;

def avg_slope = (sg1 + sg2 + sg3 + sg4 + sg5 +
                   sg6 + sg7 + sg8 + sg9 + sg10 +
                 sg11 + sg12 + sg13 + sg14 + sg15 +
                 sg16 + sg17 + sg18 + sg19 + sg20 ) / 20  ;


plot group1 = Covariance ( g1, gamma20, length = 2 );
plot group2 = Covariance ( g2, gamma20, length = 2 );
plot group3 = Covariance ( g3, gamma20, length = 2 );
plot group4 = Covariance ( g4, gamma20, length = 2 );
And I had to change this line:
Code:
def gamma1 = gammax(nfe1); # was def gamma = ...
-mashume
 
Last edited:
@mashume just so I can understand this better when I'm testing out different inputs what exactly was the approach here? It seems to work pretty well but I need to know why to know what to experiment with. Just from simple knowledge are you using linear regression slopes and looking for synchronized changes?
 
@YungTraderFromMontana
Yes. I was looking for a way to determine the degree of synchronization, and the covariance (built in function saved tons of code) seems to fit the bill.
Yet to be done:
1. the set or amalgamation of slopes to measure
2. the bar to measure against -- here I have set it to the longest #20
3. whether to look at the range of slopes (slope_max - slope_min), which was a part of my effort that didn't bear immediate fruit but may be worth revisiting
4. determine a threshold above / below which there is sufficient synchronization

This may be a good start at something workable, but I'm afraid there's a long way to go. Thanks for the challenge and the feedback.

-mashume
 
Here's the full code of what I have so far...
Code:
# EXPERIMENTAL CODE, NOT FOR TRADING YET.
# STATISTICAL EXPLORATION OF MULTIPLE FE LENGTH CORROLATED MOVEMENT
# BASED ON BUT NOT TheoTrade RSI in Laguerre Time Self Adjusting With Fractal Energy
# Mobius
# V03.06.15.2016
# Both Fractal Energy and RSI are plotted. RSI in cyan and FE in yellow. Look for trend exhaustion in the FE and a reversal of RSI or Price compression in FE and an RSI reversal.


declare lower;

input length69 = 4;
def factor = .869;
input mode = {default Range, ATR};

def range;
switch (mode) {
case Range:
    range = Highest(high, length69) - Lowest(low, length69);

case ATR:
    range = reference ATR();
}

plot RangeRatio = (range / range[length69])/20;
plot RangeFactor = factor/20;

RangeRatio.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RangeRatio.DefineColor("Consolidation", GetColor(4));
RangeRatio.DefineColor("Non-consolidation", GetColor(1));

RangeRatio.AssignValueColor( if (RangeRatio < RangeFactor) then RangeRatio.Color("Consolidation") else RangeRatio.Color("Non-consolidation"));
RangeFactor.SetDefaultColor(GetColor(7));

input length2 = 5;
input length3 = 7;
input length4 = 9;
input length5 = 11;
input length6 = 13;
input length7 = 17;


input averageType = AverageType.EXPONENTIAL;
input lengthave =2;

def ll2 = Lowest(low, length2);
def hh2 = Highest(high, length2);
def atr2 = MovingAverage(averageType, TrueRange(high, close, low), length2);
def tmp_H2 = (Log(hh2 - ll2) - Log(atr2)) / (Log(length2));

plot H2;
if tmp_H2 > 1
then {
    H2 = 1;
} else if tmp_H2 < 0 {
    H2 = 0;
} else {
    H2 = tmp_H2;
}
def ll3 = Lowest(low, length3);
def hh3 = Highest(high, length3);
def atr3 = MovingAverage(averageType, TrueRange(high, close, low), length3);
def tmp_H3 = (Log(hh3 - ll3) - Log(atr3)) / (Log(length3));

plot H3;
if tmp_H3 > 1
then {
    H3 = 1;
} else if tmp_H3 < 0 {
    H3 = 0;
} else {
    H3 = tmp_H3;
}

def ll4 = Lowest(low, length4);
def hh4 = Highest(high, length4);
def atr4 = MovingAverage(averageType, TrueRange(high, close, low), length4);
def tmp_H4 = (Log(hh4 - ll4) - Log(atr4)) / (Log(length4));

plot H4;
if tmp_H4 > 1
then {
    H4 = 1;
} else if tmp_H4 < 0 {
    H4 = 0;
} else {
    H4 = tmp_H4;
}

def ll5 = Lowest(low, length5);
def hh5 = Highest(high, length5);
def atr5 = MovingAverage(averageType, TrueRange(high, close, low), length5);
def tmp_H5 = (Log(hh5 - ll5) - Log(atr5)) / (Log(length5));

plot H5;
if tmp_H5 > 1
then {
    H5 = 1;
} else if tmp_H5 < 0 {
    H5 = 0;
} else {
    H5 = tmp_H5;
}

def ll6 = Lowest(low, length6);
def hh6 = Highest(high, length6);
def atr6 = MovingAverage(averageType, TrueRange(high, close, low), length6);
def tmp_H6 = (Log(hh6 - ll6) - Log(atr6)) / (Log(length6));

plot H6;
if tmp_H6 > 1
then {
    H6 = 1;
} else if tmp_H6 < 0 {
    H6 = 0;
} else {
    H6 = tmp_H6;
}

def ll7 = Lowest(low, length7);
def hh7 = Highest(high, length7);
def atr7 = MovingAverage(averageType, TrueRange(high, close, low), length7);
def tmp_H7 = (Log(hh7 - ll7) - Log(atr7)) / (Log(length7));

plot H7;
if tmp_H7 > 1
then {
    H7 = 1;
} else if tmp_H7 < 0 {
    H7 = 0;
} else {
    H7 = tmp_H7;
}
h2.SetDefaultColor(Color.light_red);
h3.SetDefaultColor(Color.red);
h4.SetDefaultColor(Color.orange);
h5.SetDefaultColor(Color.plum);
h6.SetDefaultColor(Color.violet);
h7.SetDefaultColor(Color.blue);

plot high = .6;
plot low = .4;
#Inputs:
input nfe1 = 1;
input nfe2 = 2;
input nfe3 = 3;
input nfe4 = 4;
input nfe5 = 5;
input nfe6 = 6;
input nfe7 = 7;
input nfe8 = 8;
input nfe9 = 9;
input nfe10 = 10;
input nfe11 = 11;
input nfe12 = 12;
input nfe13 = 13;
input nfe14 = 14;
input nfe15 = 15;
input nfe16 = 16;
input nfe17 = 17;
input nfe18 = 18;
input nfe19 = 19;
input nfe20 = 20;
input length = 10;
input smoothingLength = 5;



#hint nFE: length for Fractal Energy calculation.
# Variables:
def o;
def h;
def l;
def c;

# Calculations
o = (open + close[1]) / 2;
h = Max(high, close[1]);
l = Min(low, close[1]);
c = (o + h + l + close) / 4;

# Gamma Function
script gammax {
    input nFEi = 12;
    def FE =  Log(Sum((Max(high, close[1]) - Min(low, close[1])), nFEi) /
        (Highest(high, nFEi) - Lowest(low, nFEi)))
            / Log(nFEi);
    plot gamma = FE + .8;
}


def gamma1 = gammax(nfe1);
#gamma.SetDefaultColor(Color.CYAN);
def gamma2 = gammax(nfe2);
#gamma2.SetDefaultColor(Color.YELLOW);
#gamma2.SetLineWeight(2);
def gamma3 = gammax(nfe3);
#gamma3.SetDefaultColor(Color.YELLOW);
#gamma3.SetLineWeight(2);
def gamma4 = gammax(nfe4);
#gamma4.SetDefaultColor(Color.YELLOW);
#gamma4.SetLineWeight(2);
def gamma5 = gammax(nfe5);
#gamma5.SetDefaultColor(Color.YELLOW);
#gamma5.SetLineWeight(2);
def gamma6 = gammax(nfe6);
#gamma6.SetDefaultColor(Color.GREEN);
def gamma7 = gammax(nfe7);
#gamma7.SetDefaultColor(Color.GREEN);
def gamma8 = gammax(nfe8);
#gamma8.SetDefaultColor(Color.GREEN);
def gamma9 = gammax(nfe9);
#gamma9.SetDefaultColor(Color.GREEN);
def gamma10 = gammax(nfe10);
#gamma10.SetDefaultColor(Color.GREEN);
def gamma11 = gammax(nfe11);
#gamma11.SetDefaultColor(Color.CYAN);
def gamma12 = gammax(nfe12);
#gamma12.SetDefaultColor(Color.CYAN);
def gamma13 = gammax(nfe13);
#gamma13.SetDefaultColor(Color.CYAN);
def gamma14 = gammax(nfe14);
#gamma14.SetDefaultColor(Color.CYAN);
def gamma15 = gammax(nfe15);
#gamma15.SetDefaultColor(Color.CYAN);
def gamma16 = gammax(nfe16);
#gamma16.SetDefaultColor(Color.VIOLET);
def gamma17 = gammax(nfe17);
#gamma17.SetDefaultColor(Color.VIOLET);
def gamma18 = gammax(nfe18);
#gamma18.SetDefaultColor(Color.VIOLET);
def gamma19 = gammax(nfe19);
#gamma19.SetDefaultColor(Color.VIOLET);
def gamma20 = gammax(nfe20);
#gamma20.SetDefaultColor(Color.VIOLET);

def gammasector1 = (gamma2 + gamma3 + gamma4 + gamma5) / 4;
def gammasector2 = (gamma6 + gamma7 + gamma8 + gamma9 + gamma10) / 5;
def gammasector3 = (gamma11 + gamma12 + gamma13 + gamma14 + gamma15) / 5;
def gammasector4 = (gamma16 + gamma17 + gamma18 + gamma19 + gamma20) / 5;
def gammasectorcombo = (gammasector3 + gammasector4) / 2;


def gammasector22 = ((gammasector2 - gammasector4) *(gammasector2 - gammasector4)) * 1000;

input slopelength = 2;
def sg1 = linearRegressionSlope(price = gamma1, length = slopeLength);
def sg2 = linearRegressionSlope(price = gamma2, length = slopeLength);
def sg3 = linearRegressionSlope(price = gamma3, length = slopeLength);
def sg4 = linearRegressionSlope(price = gamma4, length = slopeLength);
def sg5 = linearRegressionSlope(price = gamma5, length = slopeLength);
def sg6 = linearRegressionSlope(price = gamma6, length = slopeLength);
def sg7 = linearRegressionSlope(price = gamma7, length = slopeLength);
def sg8 = linearRegressionSlope(price = gamma8, length = slopeLength);
def sg9 = linearRegressionSlope(price = gamma9, length = slopeLength);
def sg10 = linearRegressionSlope(price = gamma10, length = slopeLength);
def sg11 = linearRegressionSlope(price = gamma11, length = slopeLength);
def sg12 = linearRegressionSlope(price = gamma12, length = slopeLength);
def sg13 = linearRegressionSlope(price = gamma13, length = slopeLength);
def sg14 = linearRegressionSlope(price = gamma14, length = slopeLength);
def sg15 = linearRegressionSlope(price = gamma15, length = slopeLength);
def sg16 = linearRegressionSlope(price = gamma16, length = slopeLength);
def sg17 = linearRegressionSlope(price = gamma17, length = slopeLength);
def sg18 = linearRegressionSlope(price = gamma18, length = slopeLength);
def sg19 = linearRegressionSlope(price = gamma19, length = slopeLength);
def sg20 = linearRegressionSlope(price = gamma20, length = slopeLength);

def g1 = (sg2 + sg3 + sg4 + sg5) / 4;
def g2 = (sg6 + sg7 + sg8 + sg9 + sg10) / 5;
def g3 = (sg11 + sg12 + sg13 + sg14 + sg15) / 5;
def g4 = (sg16 + sg17 + sg18 + sg19 + sg20) / 5;

def avg_slope = (sg1 + sg2 + sg3 + sg4 + sg5 +
                   sg6 + sg7 + sg8 + sg9 + sg10 +
                 sg11 + sg12 + sg13 + sg14 + sg15 +
                 sg16 + sg17 + sg18 + sg19 + sg20 ) / 20  ;


plot group1 = Covariance ( g1, gamma20, length = 2 );
plot group2 = Covariance ( g2, gamma20, length = 2 );
plot group3 = Covariance ( g3, gamma20, length = 2 );
plot group4 = Covariance ( g4, gamma20, length = 2 );

def sgroup1 = Covariance ( group1, group2, length = 2 );
def sgroup2 = Covariance ( group3, group4, length = 2 );
def COV = Covariance ( sgroup1, sgroup2, length = 2 );


#plot feblast = gammasector1[1] > gammasector1 and gammasector2[1] > gammasector2 and gammasectorcombo[1] > gammasectorcombo and close > trueqb2;

There is certainly a bunch of stuff in there that doesn't need to be, and some threads of ideas that didn't go anywhere. But it's yours to play with.

-mashume
 
Last edited:
@YungTraderFromMontana
Yes. I was looking for a way to determine the degree of synchronization, and the covariance (built in function saved tons of code) seems to fit the bill.
Yet to be done:
1. the set or amalgamation of slopes to measure
2. the bar to measure against -- here I have set it to the longest #20
3. whether to look at the range of slopes (slope_max - slope_min), which was a part of my effort that didn't bear immediate fruit but may be worth revisiting
4. determine a threshold above / below which there is sufficient synchronization

This may be a good start at something workable, but I'm afraid there's a long way to go. Thanks for the challenge and the feedback.

-mashume
@mashume Is there a way for you to find the correlation between more then 2 variables at once? If you could find a way to do that we could simply plug in all the variables and get the cleanest results. The issue with finding the correlation between averages or averaging multiple correlations between two variables is that It messes with the results a little bit.
 
Last edited:
We can! It doesn't seem the signals are any clearer, though you may be the judge.

Here's the full code once again, with a couple of extras to plot
Code:
# EXPERIMENTAL CODE, NOT FOR TRADING YET.
# STATISTICAL EXPLORATION OF MULTIPLE FE LENGTH CORROLATED MOVEMENT
# BASED ON BUT NOT TheoTrade RSI in Laguerre Time Self Adjusting With Fractal Energy
# Mobius
# V03.06.15.2016
# Both Fractal Energy and RSI are plotted. RSI in cyan and FE in yellow. Look for trend exhaustion in the FE and a reversal of RSI or Price compression in FE and an RSI reversal.


declare lower;

assignBackgroundColor(color.gray);

input length69 = 4;
def factor = .869;
input mode = {default Range, ATR};

def range;
switch (mode) {
case Range:
    range = Highest(high, length69) - Lowest(low, length69);

case ATR:
    range = reference ATR();
}

plot RangeRatio = (range / range[length69])/20;
plot RangeFactor = factor/20;

RangeRatio.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RangeRatio.DefineColor("Consolidation", GetColor(4));
RangeRatio.DefineColor("Non-consolidation", GetColor(1));

RangeRatio.AssignValueColor( if (RangeRatio < RangeFactor) then RangeRatio.Color("Consolidation") else RangeRatio.Color("Non-consolidation"));
RangeFactor.SetDefaultColor(GetColor(7));

input length2 = 5;
input length3 = 7;
input length4 = 9;
input length5 = 11;
input length6 = 13;
input length7 = 17;


input averageType = AverageType.EXPONENTIAL;
input lengthave =2;

def ll2 = Lowest(low, length2);
def hh2 = Highest(high, length2);
def atr2 = MovingAverage(averageType, TrueRange(high, close, low), length2);
def tmp_H2 = (Log(hh2 - ll2) - Log(atr2)) / (Log(length2));

plot H2;
if tmp_H2 > 1
then {
    H2 = 1;
} else if tmp_H2 < 0 {
    H2 = 0;
} else {
    H2 = tmp_H2;
}
def ll3 = Lowest(low, length3);
def hh3 = Highest(high, length3);
def atr3 = MovingAverage(averageType, TrueRange(high, close, low), length3);
def tmp_H3 = (Log(hh3 - ll3) - Log(atr3)) / (Log(length3));

plot H3;
if tmp_H3 > 1
then {
    H3 = 1;
} else if tmp_H3 < 0 {
    H3 = 0;
} else {
    H3 = tmp_H3;
}

def ll4 = Lowest(low, length4);
def hh4 = Highest(high, length4);
def atr4 = MovingAverage(averageType, TrueRange(high, close, low), length4);
def tmp_H4 = (Log(hh4 - ll4) - Log(atr4)) / (Log(length4));

plot H4;
if tmp_H4 > 1
then {
    H4 = 1;
} else if tmp_H4 < 0 {
    H4 = 0;
} else {
    H4 = tmp_H4;
}

def ll5 = Lowest(low, length5);
def hh5 = Highest(high, length5);
def atr5 = MovingAverage(averageType, TrueRange(high, close, low), length5);
def tmp_H5 = (Log(hh5 - ll5) - Log(atr5)) / (Log(length5));

plot H5;
if tmp_H5 > 1
then {
    H5 = 1;
} else if tmp_H5 < 0 {
    H5 = 0;
} else {
    H5 = tmp_H5;
}

def ll6 = Lowest(low, length6);
def hh6 = Highest(high, length6);
def atr6 = MovingAverage(averageType, TrueRange(high, close, low), length6);
def tmp_H6 = (Log(hh6 - ll6) - Log(atr6)) / (Log(length6));

plot H6;
if tmp_H6 > 1
then {
    H6 = 1;
} else if tmp_H6 < 0 {
    H6 = 0;
} else {
    H6 = tmp_H6;
}

def ll7 = Lowest(low, length7);
def hh7 = Highest(high, length7);
def atr7 = MovingAverage(averageType, TrueRange(high, close, low), length7);
def tmp_H7 = (Log(hh7 - ll7) - Log(atr7)) / (Log(length7));

plot H7;
if tmp_H7 > 1
then {
    H7 = 1;
} else if tmp_H7 < 0 {
    H7 = 0;
} else {
    H7 = tmp_H7;
}
h2.SetDefaultColor(Color.light_red);
h3.SetDefaultColor(Color.red);
h4.SetDefaultColor(Color.orange);
h5.SetDefaultColor(Color.plum);
h6.SetDefaultColor(Color.violet);
h7.SetDefaultColor(Color.blue);

plot high = .6;
plot low = .4;
#Inputs:
input nfe1 = 1;
input nfe2 = 2;
input nfe3 = 3;
input nfe4 = 4;
input nfe5 = 5;
input nfe6 = 6;
input nfe7 = 7;
input nfe8 = 8;
input nfe9 = 9;
input nfe10 = 10;
input nfe11 = 11;
input nfe12 = 12;
input nfe13 = 13;
input nfe14 = 14;
input nfe15 = 15;
input nfe16 = 16;
input nfe17 = 17;
input nfe18 = 18;
input nfe19 = 19;
input nfe20 = 20;
input length = 10;
input smoothingLength = 5;



#hint nFE: length for Fractal Energy calculation.
# Variables:
def o;
def h;
def l;
def c;

# Calculations
o = (open + close[1]) / 2;
h = Max(high, close[1]);
l = Min(low, close[1]);
c = (o + h + l + close) / 4;

# Gamma Function
script gammax {
    input nFEi = 12;
    def FE =  Log(Sum((Max(high, close[1]) - Min(low, close[1])), nFEi) /
        (Highest(high, nFEi) - Lowest(low, nFEi)))
            / Log(nFEi);
    plot gamma = FE + .8;
}


def gamma1 = gammax(nfe1);
#gamma.SetDefaultColor(Color.CYAN);
def gamma2 = gammax(nfe2);
#gamma2.SetDefaultColor(Color.YELLOW);
#gamma2.SetLineWeight(2);
def gamma3 = gammax(nfe3);
#gamma3.SetDefaultColor(Color.YELLOW);
#gamma3.SetLineWeight(2);
def gamma4 = gammax(nfe4);
#gamma4.SetDefaultColor(Color.YELLOW);
#gamma4.SetLineWeight(2);
def gamma5 = gammax(nfe5);
#gamma5.SetDefaultColor(Color.YELLOW);
#gamma5.SetLineWeight(2);
def gamma6 = gammax(nfe6);
#gamma6.SetDefaultColor(Color.GREEN);
def gamma7 = gammax(nfe7);
#gamma7.SetDefaultColor(Color.GREEN);
def gamma8 = gammax(nfe8);
#gamma8.SetDefaultColor(Color.GREEN);
def gamma9 = gammax(nfe9);
#gamma9.SetDefaultColor(Color.GREEN);
def gamma10 = gammax(nfe10);
#gamma10.SetDefaultColor(Color.GREEN);
def gamma11 = gammax(nfe11);
#gamma11.SetDefaultColor(Color.CYAN);
def gamma12 = gammax(nfe12);
#gamma12.SetDefaultColor(Color.CYAN);
def gamma13 = gammax(nfe13);
#gamma13.SetDefaultColor(Color.CYAN);
def gamma14 = gammax(nfe14);
#gamma14.SetDefaultColor(Color.CYAN);
def gamma15 = gammax(nfe15);
#gamma15.SetDefaultColor(Color.CYAN);
def gamma16 = gammax(nfe16);
#gamma16.SetDefaultColor(Color.VIOLET);
def gamma17 = gammax(nfe17);
#gamma17.SetDefaultColor(Color.VIOLET);
def gamma18 = gammax(nfe18);
#gamma18.SetDefaultColor(Color.VIOLET);
def gamma19 = gammax(nfe19);
#gamma19.SetDefaultColor(Color.VIOLET);
def gamma20 = gammax(nfe20);
#gamma20.SetDefaultColor(Color.VIOLET);

def gammasector1 = (gamma2 + gamma3 + gamma4 + gamma5) / 4;
def gammasector2 = (gamma6 + gamma7 + gamma8 + gamma9 + gamma10) / 5;
def gammasector3 = (gamma11 + gamma12 + gamma13 + gamma14 + gamma15) / 5;
def gammasector4 = (gamma16 + gamma17 + gamma18 + gamma19 + gamma20) / 5;
def gammasectorcombo = (gammasector3 + gammasector4) / 2;


def gammasector22 = ((gammasector2 - gammasector4) *(gammasector2 - gammasector4)) * 1000;

input slopelength = 2;
def sg1 =  ( gamma1   - gamma1[1] );
def sg2 =  ( gamma2   - gamma2[1] );
def sg3 =  ( gamma3   - gamma3[1] );
def sg4 =  ( gamma4   - gamma4[1] );
def sg5 =  ( gamma5   - gamma5[1] );
def sg6 =  ( gamma6   - gamma6[1] );
def sg7 =  ( gamma7   - gamma7[1] );
def sg8 =  ( gamma8   - gamma8[1] );
def sg9 =  ( gamma9   - gamma9[1] );
def sg10 = ( gamma10 - gamma10[1] );
def sg11 = ( gamma11 - gamma11[1] );
def sg12 = ( gamma12 - gamma12[1] );
def sg13 = ( gamma13 - gamma13[1] );
def sg14 = ( gamma14 - gamma14[1] );
def sg15 = ( gamma15 - gamma15[1] );
def sg16 = ( gamma16 - gamma16[1] );
def sg17 = ( gamma17 - gamma17[1] );
def sg18 = ( gamma18 - gamma18[1] );
def sg19 = ( gamma19 - gamma19[1] );
def sg20 = ( gamma20 - gamma20[1] );

def g1 = (sg2 + sg3 + sg4 + sg5) / 4;
def g2 = (sg6 + sg7 + sg8 + sg9 + sg10) / 5;
def g3 = (sg11 + sg12 + sg13 + sg14 + sg15) / 5;
def g4 = (sg16 + sg17 + sg18 + sg19 + sg20) / 5;

def avg_slope = ( sg2 + sg3 + sg4 + sg5 +
                  sg6 + sg7 + sg8 + sg9 + sg10 +
                 sg11 + sg12 + sg13 + sg14 + sg15 +
                 sg16 + sg17 + sg18 + sg19 + sg20 ) / 19  ;

def max_slope_s1 = max(sg2, max(sg3, max(sg4, sg5)));
def max_slope_s2 = max(sg6, max(sg7, max(sg8, max(sg9, sg10))));
def max_slope_s3 = max(sg11, max(sg12, max(sg13, max(sg14, sg15))));
def max_slope_s4 = max(sg16, max(sg17, max(sg18, max(sg19, sg20))));
def max_slope = max(max_slope_s1, max(max_slope_s2, max(max_slope_s3, max_slope_s4)));

def min_slope_s1 = min(sg2, min(sg3, min(sg4, sg5)));
def min_slope_s2 = min(sg6, min(sg7, min(sg8, min(sg9, sg10))));
def min_slope_s3 = min(sg11, min(sg12, min(sg13, min(sg14, sg15))));
def min_slope_s4 = min(sg16, min(sg17, min(sg18, min(sg19, sg20))));
def min_slope = min(min_slope_s1, min(min_slope_s2, min(min_slope_s3, min_slope_s4)));



plot Var_X = (
#        sqr( gamma1   - avg_slope ) +
        sqr( gamma2   - avg_slope ) +
        sqr( gamma3   - avg_slope ) +
        sqr( gamma4   - avg_slope ) +
        sqr( gamma5   - avg_slope ) +
        sqr( gamma6   - avg_slope ) +
        sqr( gamma7   - avg_slope ) +
        sqr( gamma8   - avg_slope ) +
        sqr( gamma9   - avg_slope ) +
        sqr( gamma10  - avg_slope ) +
        sqr( gamma11  - avg_slope ) +
        sqr( gamma12  - avg_slope ) +
        sqr( gamma13  - avg_slope ) +
        sqr( gamma14  - avg_slope ) +
        sqr( gamma15  - avg_slope ) +
        sqr( gamma16  - avg_slope ) +
        sqr( gamma17  - avg_slope ) +
        sqr( gamma18  - avg_slope ) +
        sqr( gamma19  - avg_slope ) +
        sqr( gamma20  - avg_slope )
    ) / 19;

# plot Omega = Var_X / slope_range;
# Omega.SetDefaultColor(COLOR.RED);
# Omega.SetLineWeight(3);

Var_X.SetDefaultColor(COLOR.WHITE);
Var_X.SetLineWeight(3);
Var_X.EnableApproximation();

plot Var_X_Delta = Var_X - Var_X[1];
Var_X_Delta.SetPaintingStrategy(PAINtingStrategy.HISTOGRAM);

plot slope_range = max_slope - min_slope;
slope_range.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
# def sgroup1 = Covariance ( group1, group2, length = 2 );
# def sgroup2 = Covariance ( group3, group4, length = 2 );
# def COV = Covariance ( sgroup1, sgroup2, length = 2 );


#plot feblast = gammasector1[1] > gammasector1 and gammasector2[1] > gammasector2 and gammasectorcombo[1] > gammasectorcombo and close > trueqb2;
 
Last edited:
@mashume I have one idea that I think would top anything we've done so far without getting all statistical. Would you be able to create bands that plot the highest of all gammas and lowest of all gammas? If you could do that I have an idea I'm sure would work. I know how to do this with one gamma but not with all of them.
 
@mashume I have one idea that I think would top anything we've done so far without getting all statistical. Would you be able to create bands that plot the highest of all gammas and lowest of all gammas? If you could do that I have an idea I'm sure would work. I know how to do this with one gamma but not with all of them.
Hi, Please change the header with your information and say "base code started w RSIlg by Mobius. That will help people from not using the study as the Theo Study. I look forward to see what you have created. ☺
 
@mashume I have one idea that I think would top anything we've done so far without getting all statistical. Would you be able to create bands that plot the highest of all gammas and lowest of all gammas? If you could do that I have an idea I'm sure would work. I know how to do this with one gamma but not with all of them.
Code:
plot gamma_max = max(gamma1, max(gamma2, max(gamma3, max(gamma4, max(gamma5,
    max(gamma6, max(gamma7, max(gamma8, max(gamma9, max(gamma10,
    max(gamma11, max(gamma12, max(gamma13, max(gamma14, max(gamma15,
        max(gamma16, max(gamma17, max(gamma18, max(gamma19, gamma20)))))))))))))))))));

plot gamma_min = min(gamma1, min(gamma2, min(gamma3, min(gamma4, min(gamma5,
    min(gamma6, min(gamma7, min(gamma8, min(gamma9, min(gamma10,
    min(gamma11, min(gamma12, min(gamma13, min(gamma14, min(gamma15,
    min(gamma16, min(gamma17, min(gamma18, min(gamma19, gamma20)))))))))))))))))));

Note that these have "gamma1" instead of "gamma" as I copied them out of something I had written previously

-mashume
 
@mashume this is perfect, one last question what could you do mathematically to make a study's highs its lows or flip its results upside down. Anything simple?
Code:
# Original

plot f = some function

# New Inverted (good for functions that are centered around zreo

def f = some function
plot f_prime = f * -1

Your numbers will just be reflected about the zero line.

If you want to invert a plot and make the highs the lows and the lows the highs while keeping the sign the same perhaps something along the lines of this:
Code:
# Original

plot f = some function

# New Inverted re-shifted (good for data that is all above zero)

def f = some function
plot f_prime = (f * -1) + highestall(f)
# or perhaps
plot f_prime = (f * -1) + highestall(f) + lowestall(f)

or something like that.

-mashume
 
Last edited:
@mashume this request is the most important of all of them so far. For this study it is essential to have a scan and the newer version has gotten way to complex to scan. I'm not asking for you to make a scan for me but can you try your best to consolidate the code? I noticed you used a cool trick when I asked for the max of multiple length gammes that enabled you to reuse one gamma formula on every single length saving lots of lines and I assume computation power in a scan. I was wondering if you could repeat as well as do the same thing for he. I think that would bring the community one step closer to getting a scan.
Here's the code I hope you can simplify. I commented the gamma function you used previously for reference, the one if you could reuse on the gamma as well as replicate on the he I think would get us one step closer to a scan.
Code:
#script gammax {
#    input nFEi = 12;
 #   def FE =  Log(Sum((Max(high, close[1]) - Min(low, close[1])), nFEi) /
 #       (Highest(high, nFEi) - Lowest(low, nFEi)))
 #           / Log(nFEi);
 #   plot gamma = FE + .8;
#}
input nFE1 = 1;
input nfe2 = 2;
input nfe3 = 3;
input nfe4 = 4;
input nfe5 = 5;
input nfe6 = 6;
input nfe7 = 7;
input nfe8 = 8;
input nfe9 = 9;
input nfe10 = 10;
input nfe11 = 11;
input nfe12 = 12;
input nfe13 = 13;
input nfe14 = 14;
input nfe15 = 15;
input nfe16 = 16;
input nfe17 = 17;
input nfe18 = 18;
input nfe19 = 19;
input nfe20 = 20;


# Calculations
def gamma = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nFE1) /
        (Highest(high, nFE1) - Lowest(low, nFE1)))
            / Log(nFE1);
def gamma2 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe2) /
        (Highest(high, nfe2) - Lowest(low, nfe2)))
            / Log(nfe2);
def gamma3 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe3) /
        (Highest(high, nfe3) - Lowest(low, nfe3)))
            / Log(nfe3);
def gamma4 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe4) /
        (Highest(high, nfe4) - Lowest(low, nfe4)))
            / Log(nfe4);
def gamma5 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe5) /
        (Highest(high, nfe5) - Lowest(low, nfe5)))
            / Log(nfe5);
def gamma6 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe6) /
        (Highest(high, nfe6) - Lowest(low, nfe6)))
            / Log(nfe6);
def gamma7 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe7) /
        (Highest(high, nfe7) - Lowest(low, nfe7)))
            / Log(nfe7);
def gamma8 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe8) /
        (Highest(high, nfe8) - Lowest(low, nfe8)))
            / Log(nfe8);
def gamma9 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe9) /
        (Highest(high, nfe9) - Lowest(low, nfe9)))
            / Log(nfe9);
def gamma10 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe10) /
        (Highest(high, nfe10) - Lowest(low, nfe10)))
            / Log(nfe10);
def gamma11 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe11) /
        (Highest(high, nfe11) - Lowest(low, nfe11)))
            / Log(nfe11);
def gamma12 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe12) /
        (Highest(high, nfe12) - Lowest(low, nfe12)))
            / Log(nfe12);
def gamma13 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe13) /
        (Highest(high, nfe13) - Lowest(low, nfe13)))
            / Log(nfe13);
def gamma14 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe14) /
        (Highest(high, nfe14) - Lowest(low, nfe14)))
            / Log(nfe14);
def gamma15 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe15) /
        (Highest(high, nfe15) - Lowest(low, nfe15)))
            / Log(nfe15);
def gamma16 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe16) /
        (Highest(high, nfe16) - Lowest(low, nfe16)))
            / Log(nfe16);
def gamma17 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe17) /
        (Highest(high, nfe17) - Lowest(low, nfe17)))
            / Log(nfe17);
def gamma18 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe18) /
        (Highest(high, nfe18) - Lowest(low, nfe18)))
            / Log(nfe18);
def gamma19 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe19) /
        (Highest(high, nfe19) - Lowest(low, nfe19)))
            / Log(nfe19);
def gamma20 = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nfe20) /
        (Highest(high, nfe20) - Lowest(low, nfe20)))
            / Log(nfe20);

def gamma_max = Max(gamma4, Max(gamma5,
    Max(gamma6, Max(gamma7, Max(gamma8, Max(gamma9, Max(gamma10,
    Max(gamma11, Max(gamma12, Max(gamma13, Max(gamma14, gamma15)))))))))));

def gamma_min = Min(gamma4, Min(gamma5,
    Min(gamma6, Min(gamma7, Min(gamma8, Min(gamma9, Min(gamma10,
    Min(gamma11, Min(gamma12, Min(gamma13, Min(gamma14, gamma15)))))))))));


def length6969 = 5;
input length13 = 16;
input length1 = 4;
input length2 = 5;
input length3 = 6;
input length4 = 7;
input length5 = 8;
input length6 = 9;
input length7 = 10;
input length8 = 11;
input length9 = 12;
input length10 = 13;
input length11 = 14;
input length12 = 15;

input averageType = AverageType.EXPONENTIAL;
input lengthave = 2;



def ll = Lowest(low, length1);
def hh = Highest(high, length1);
def atr1 = MovingAverage(averageType, TrueRange(high, close, low), length1);
def tmp_H = (Log(hh - ll) - Log(atr1)) / (Log(length1));

def H;
if tmp_H > 1
then {
    H = 1;
} else if tmp_H < 0 {
    H = 0;
} else {
    H = tmp_H;
}
def ll2 = Lowest(low, length2);
def hh2 = Highest(high, length2);
def atr2 = MovingAverage(averageType, TrueRange(high, close, low), length2);
def tmp_H2 = (Log(hh2 - ll2) - Log(atr2)) / (Log(length2));

def H2;
if tmp_H2 > 1
then {
    H2 = 1;
} else if tmp_H2 < 0 {
    H2 = 0;
} else {
    H2 = tmp_H2;
}
def ll3 = Lowest(low, length3);
def hh3 = Highest(high, length3);
def atr3 = MovingAverage(averageType, TrueRange(high, close, low), length3);
def tmp_H3 = (Log(hh3 - ll3) - Log(atr3)) / (Log(length3));

def H3;
if tmp_H3 > 1
then {
    H3 = 1;
} else if tmp_H3 < 0 {
    H3 = 0;
} else {
    H3 = tmp_H3;
}

def ll4 = Lowest(low, length4);
def hh4 = Highest(high, length4);
def atr4 = MovingAverage(averageType, TrueRange(high, close, low), length4);
def tmp_H4 = (Log(hh4 - ll4) - Log(atr4)) / (Log(length4));

def H4;
if tmp_H4 > 1
then {
    H4 = 1;
} else if tmp_H4 < 0 {
    H4 = 0;
} else {
    H4 = tmp_H4;
}

def ll5 = Lowest(low, length5);
def hh5 = Highest(high, length5);
def atr5 = MovingAverage(averageType, TrueRange(high, close, low), length5);
def tmp_H5 = (Log(hh5 - ll5) - Log(atr5)) / (Log(length5));

def H5;
if tmp_H5 > 1
then {
    H5 = 1;
} else if tmp_H5 < 0 {
    H5 = 0;
} else {
    H5 = tmp_H5;
}

def ll6 = Lowest(low, length6);
def hh6 = Highest(high, length6);
def atr6 = MovingAverage(averageType, TrueRange(high, close, low), length6);
def tmp_H6 = (Log(hh6 - ll6) - Log(atr6)) / (Log(length6));

def H6;
if tmp_H6 > 1
then {
    H6 = 1;
} else if tmp_H6 < 0 {
    H6 = 0;
} else {
    H6 = tmp_H6;
}

def ll7 = Lowest(low, length7);
def hh7 = Highest(high, length7);
def atr7 = MovingAverage(averageType, TrueRange(high, close, low), length7);
def tmp_H7 = (Log(hh7 - ll7) - Log(atr7)) / (Log(length7));

def H7;
if tmp_H7 > 1
then {
    H7 = 1;
} else if tmp_H7 < 0 {
    H7 = 0;
} else {
    H7 = tmp_H7;
}

def ll8 = Lowest(low, length8);
def hh8 = Highest(high, length8);
def atr8 = MovingAverage(averageType, TrueRange(high, close, low), length8);
def tmp_h8 = (Log(hh8 - ll8) - Log(atr8)) / (Log(length8));

def H8;
if tmp_h8 > 1
then {
    H8 = 1;
} else if tmp_h8 < 0 {
    H8 = 0;
} else {
    H8 = tmp_h8;
}

def ll9 = Lowest(low, length9);
def hh9 = Highest(high, length9);
def atr9 = MovingAverage(averageType, TrueRange(high, close, low), length9);
def tmp_H9 = (Log(hh9 - ll9) - Log(atr9)) / (Log(length9));

def H9;
if tmp_H9 > 1
then {
    H9 = 1;
} else if tmp_H9 < 0 {
    H9 = 0;
} else {
    H9 = tmp_H9;
}

def ll10 = Lowest(low, length10);
def hh10 = Highest(high, length10);
def atr10 = MovingAverage(averageType, TrueRange(high, close, low), length10);
def tmp_H10 = (Log(hh10 - ll10) - Log(atr10)) / (Log(length10));

def H10;
if tmp_H10 > 1
then {
    H10 = 1;
} else if tmp_H10 < 0 {
    H10 = 0;
} else {
    H10 = tmp_H10;
}

def ll11 = Lowest(low, length11);
def hh11 = Highest(high, length11);
def atr11 = MovingAverage(averageType, TrueRange(high, close, low), length11);
def tmp_H11 = (Log(hh11 - ll11) - Log(atr11)) / (Log(length11));

def H11;
if tmp_H11 > 1
then {
    H11 = 1;
} else if tmp_H11 < 0 {
    H11 = 0;
} else {
    H11 = tmp_H11;
}

def ll12 = Lowest(low, length12);
def hh12 = Highest(high, length12);
def atr12 = MovingAverage(averageType, TrueRange(high, close, low), length12);
def tmp_H12 = (Log(hh12 - ll12) - Log(atr12)) / (Log(length12));

def H12;
if tmp_H12 > 1
then {
    H12 = 1;
} else if tmp_H12 < 0 {
    H12 = 0;
} else {
    H12 = tmp_H12;
}

def ll13 = Lowest(low, length13);
def hh13 = Highest(high, length13);
def atr13 = MovingAverage(averageType, TrueRange(high, close, low), length13);
def tmp_H13 = (Log(hh13 - ll13) - Log(atr13)) / (Log(length13));

def H13;
if tmp_H13 > 1
then {
    H13 = 1;
} else if tmp_H13 < 0 {
    H13 = 0;
} else {
    H13 = tmp_H13;
}


def he_max = max(h, max(h2, max(h3,
    max(h4, max(h5, max(h6, max(h7, max(h8,
    max(h9, max(h10, max(h11, h12)))))))))));

def he_min = min(h, min(h2, min(h3,
    min(h4, min(h5, min(h6, min(h7, min(h8,
    min(h9, min(h10, min(h11, h12)))))))))));
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
472 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top