Help with Adding 5 min plots for this 2 minute Hull MA?

khpro59

Expert Trader
VIP
I need some help from the lovely folks at UTS,

I use this study below to scalp with, which @halcyonguy helped me implement keltner channels.

I use a 2 minute chart with this script which has a hull moving average, and I also place it on the 5 minute so I can watch for any "agreement" between the two. Its quite a powerful signal when both the 2 and 5 minute hull moving averages agree on a long or short signal. Could someone help me add in the option (an input to choose either 5 or 15 minute and turn off/on would be awesome but not mandatory) to print points (non-boolean) on the actual 2 minute hull line?

instead of only printing long or short (red/green) hull line when they are in agreement, is it possible to add a triangle, square, dot, etc on the 2 min hull line when the 5 minute agrees? And plot on the 2 min hull line?

Like this?

2024-03-05_16h51_09.png


I could go the route where it wont print long or short unless they both agree, but I would like to keep the 2 minute signals as they are since I do scalp with them, but have noticed when both 2 and 5 agree, its a bigger and more sustained move and thus would like to have both options.

you may notice a difference in the scripts from the 2 and the 5 minute. The 5 minute is just a "lite" version of the 2 minute version, I commented out a bunch of erroneous logic that only complicates it and added the functionality that it paints the candles so its easy to spot.

Here is the script with the hull moving average and keltner channels.

Code:
#keltner_mod_avg with modifications by khpro59

# khpro- Considering all Keltner channels have a middle moving average, I wanted to create a keltner Channel that uses an adaptive stytle Hull Moving Average.

#SPECIAL THANKS TO: Loxx and Sam4Cok@Samer800 as the below script is based of their code(s) and Halcyonguy for adding in the keltner channels

# 2-9-24 Added standard Keltner Channels with LOXX Adaptive Hull being the center moving average (Thanks to Halcyonguy for the help!)

# 3-1-24 khpro - implemented alerts for Hull Line Long and Short Signals

input src = close;#, "Source", group = "Basic Settings")
input Power = 1;#, "Power", group = "Basic Settings")
input PhaseAccumulationCycles = 1.0;#, "Phase Accumulation Cycles", group = "Basic Settings")
input PhaseAccumulationPower = 1.0;#, "Phase Accumulation Power", group = "Basic Settings")
input colorBars = yes;#(true, "Color bars", group= "UI Options")
input showSigs = yes;#(true, "Show signals", group= "UI Options")

def na = Double.NaN;

Script calcComp {
input src = close;
    def out = (
         (0.0962 * src +
         0.5769 * src[2] -
         0.5769 * src[4] -
         0.0962 * src[6]) * (0.075 * src[1] + 0.54));
    plot return = out;
}
#iLwmp(src, len, pow) =>
script iLwmp {
    input src = close;
    input len1 = 10;
    input pow = 1;
    def len = if len1 < 2 then 2 else len1;
    def sumw_ = Power(len, pow);
    def sum_ = sumw_ * src;
    def sum1 = fold i = 1 to len with q=sum_ do
               q + Power(len - i, pow) * GetValue(src, i);
    def sumw1 = fold k = 1 to len with p=sumw_ do
               p + Power(len - k, pow);
    def sum = sum1;
    def sumw = sumw1;
    def iLwmp = sum / sumw;
    plot out = if isNaN(iLwmp) then (sum_/sumw_) else iLwmp;
}
#export paa(float src, float mult, float filt)=>
script paa {
    input src = close;
    input mult = 1;
    input filt = 0;
    def bar_index = AbsValue(BarNumber());
    def pi = Double.Pi;
    def degree = 180.0 / pi;
    def filter = Max(filt, 1);
    def I1;
    def Q1;
    def Phase;
    def period;
    def Smooth = if bar_index > 5 then
                 (4 * src + 3 * src[1] + 2 * src[2] + src[3]) / 10 else Smooth[1];
    def ts = calcComp(Smooth);
    def Detrender = if bar_index > 5 then ts else Detrender[1];
    def qs = calcComp(Detrender);
    def Q1_ = if bar_index > 5 then qs else Q1[1];
    def I1_ = if bar_index > 5 then Detrender[3] else I1[1];
        I1 = 0.15 * I1_ + 0.85 * I1[1];
        Q1 = 0.15 * Q1_ + 0.85 * Q1[1];
    def Phase1 = Phase[1];
    def Phase2 = if AbsValue(I1) > 0 then degree * ATan(AbsValue(Q1 / I1)) else Phase1;
    def Phase3 = if I1 < 0 and Q1 > 0 then 180 - Phase2 else Phase2;
    def Phase4 = if I1 < 0 and Q1 < 0 then 180 + Phase3 else Phase3;
        Phase  = if I1 > 0 and Q1 < 0 then 360 - Phase4 else Phase4;
    def DeltaPhase1 = Phase[1] - Phase;
    def DeltaPhase2 = if Phase[1] < 90 and Phase > 270 then
                      360 + Phase[1] - Phase else DeltaPhase1;
    def DeltaPhase3 = Max(Min(DeltaPhase2, 60), 7);
    def DeltaPhase = DeltaPhase3;
    def PhaseSum;
    def preSum;
    def count;
    if (PhaseSum[1] < (mult * 360) and count[1] < 4500) {
        preSum = GetValue(DeltaPhase, count[1]);
        PhaseSum = PhaseSum[1] + (if isNaN(preSum) then 0 else preSum);
        count = count[1] + 1;
    } else {
        preSum = 0;
        PhaseSum = PhaseSum[1];
        count = 0;
    }
    def InstPeriod = if count > 0 then count else InstPeriod[1];
    def alpha = 2.0 / (1.0 + filter);
    def period1 = period[1] + alpha * (InstPeriod - period[1]);
        period = if Floor(period1) < 1 then 1 else Floor(period1);
    def paa = Floor(period);
    plot return = if isNaN(paa) then 1 else paa;
}
def paa_ = paa(src, PhaseAccumulationCycles, PhaseAccumulationPower);
def HmaLength = if paa_ < 2 then 2 else paa_;
def HalfPrd    = HmaLength / 2;
def HullPrd    = Sqrt(HmaLength);
def HalfPeriod = Floor(HalfPrd);
def HullPeriod = Floor(HullPrd);
def iLwmpHalf_ = iLwmp(src, HalfPeriod, Power);
def iLwmpHma_  = iLwmp(src, HmaLength, Power);
def iLwmpHalf  = iLwmpHalf_;
def iLwmpHma = iLwmpHma_;
def iLwmSrc  = (2.0 * iLwmpHalf) - iLwmpHma;
def hullout_ = iLwmp(iLwmSrc, HullPeriod, Power);
def hullout = hullout_;
def sig = hullout[1];
def colorout = hullout > sig;
def goLong  = Crosses(hullout, sig, CrossingDirection.ABOVE);
def goShort = Crosses(hullout, sig, CrossingDirection.BELOW);

AssignPriceColor(if !colorBars then Color.CURRENT else
                 if colorout then Color.GREEN else Color.RED);

plot hullLine = hullout;
hullLine.SetLineWeight(1);
hullLine.AssignValueColor(if colorout then Color.GREEN else Color.RED);

#Alerts

AddChartBubble(goLong, low, "L", Color.CYAN, no);
AddChartBubble(goShort, high, "S", GetColor(2));

Alert(goLong, "HULL LONG SIG", Alert.Bar, Sound.Chimes);
Alert(goShort, "HULL SHORT SIG", Alert.Bar, Sound.Chimes);

#End Alerts

######################
#END ADAPTIVE HULL
######################

######################
#Begin Keltner Channels
######################


#declare weak_volume_dependency;

input displace = 0;
input factor = 1.5;
input length = 20;
input price = close;
input averageType = AverageType.SIMPLE;
input trueRangeAverageType = AverageType.SIMPLE;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);


input show_keltner_lines = yes;

plot Upper_Band = if show_keltner_lines then (hullout + shift[-displace]) else na;
Upper_Band.SetDefaultColor(GetColor(8));
plot Lower_Band = if show_keltner_lines then (hullout - shift[-displace]) else na;
Lower_Band.SetDefaultColor(GetColor(8));

#

And for what its worth here is the script I use on the 5 min chart to identify the agreement


Code:
#khpro59  2/9 - special thanks to Loxx for this code

# This is a lite version of the Hull Moving Average Keltner. It is bare bones to save resources and leaving only Hull's long and sell signals

input src = close;#, "Source", group = "Basic Settings")
input Power = 1;#, "Power", group = "Basic Settings")
input PhaseAccumulationCycles = 1.0;#, "Phase Accumulation Cycles", group = "Basic Settings")
input PhaseAccumulationPower = 1.0;#, "Phase Accumulation Power", group = "Basic Settings")
input colorBars = yes;#(true, "Color bars", group= "UI Options")
input showSigs = yes;#(true, "Show signals", group= "UI Options")

def na = Double.NaN;

Script calcComp {
input src = close;
    def out = (
         (0.0962 * src +
         0.5769 * src[2] -
         0.5769 * src[4] -
         0.0962 * src[6]) * (0.075 * src[1] + 0.54));
    plot return = out;
}
#iLwmp(src, len, pow) =>
script iLwmp {
    input src = close;
    input len1 = 10;
    input pow = 1;
    def len = if len1 < 2 then 2 else len1;
    def sumw_ = Power(len, pow);
    def sum_ = sumw_ * src;
    def sum1 = fold i = 1 to len with q=sum_ do
               q + Power(len - i, pow) * GetValue(src, i);
    def sumw1 = fold k = 1 to len with p=sumw_ do
               p + Power(len - k, pow);
    def sum = sum1;
    def sumw = sumw1;
    def iLwmp = sum / sumw;
    plot out = if isNaN(iLwmp) then (sum_/sumw_) else iLwmp;
}
#export paa(float src, float mult, float filt)=>
script paa {
    input src = close;
    input mult = 1;
    input filt = 0;
    def bar_index = AbsValue(BarNumber());
    def pi = Double.Pi;
    def degree = 180.0 / pi;
    def filter = Max(filt, 1);
    def I1;
    def Q1;
    def Phase;
    def period;
    def Smooth = if bar_index > 5 then
                 (4 * src + 3 * src[1] + 2 * src[2] + src[3]) / 10 else Smooth[1];
    def ts = calcComp(Smooth);
    def Detrender = if bar_index > 5 then ts else Detrender[1];
    def qs = calcComp(Detrender);
    def Q1_ = if bar_index > 5 then qs else Q1[1];
    def I1_ = if bar_index > 5 then Detrender[3] else I1[1];
        I1 = 0.15 * I1_ + 0.85 * I1[1];
        Q1 = 0.15 * Q1_ + 0.85 * Q1[1];
    def Phase1 = Phase[1];
    def Phase2 = if AbsValue(I1) > 0 then degree * ATan(AbsValue(Q1 / I1)) else Phase1;
    def Phase3 = if I1 < 0 and Q1 > 0 then 180 - Phase2 else Phase2;
    def Phase4 = if I1 < 0 and Q1 < 0 then 180 + Phase3 else Phase3;
        Phase  = if I1 > 0 and Q1 < 0 then 360 - Phase4 else Phase4;
    def DeltaPhase1 = Phase[1] - Phase;
    def DeltaPhase2 = if Phase[1] < 90 and Phase > 270 then
                      360 + Phase[1] - Phase else DeltaPhase1;
    def DeltaPhase3 = Max(Min(DeltaPhase2, 60), 7);
    def DeltaPhase = DeltaPhase3;
    def PhaseSum;
    def preSum;
    def count;
    if (PhaseSum[1] < (mult * 360) and count[1] < 4500) {
        preSum = GetValue(DeltaPhase, count[1]);
        PhaseSum = PhaseSum[1] + (if isNaN(preSum) then 0 else preSum);
        count = count[1] + 1;
    } else {
        preSum = 0;
        PhaseSum = PhaseSum[1];
        count = 0;
    }
    def InstPeriod = if count > 0 then count else InstPeriod[1];
    def alpha = 2.0 / (1.0 + filter);
    def period1 = period[1] + alpha * (InstPeriod - period[1]);
        period = if Floor(period1) < 1 then 1 else Floor(period1);
    def paa = Floor(period);
    plot return = if isNaN(paa) then 1 else paa;
}
def paa_ = paa(src, PhaseAccumulationCycles, PhaseAccumulationPower);
def HmaLength = if paa_ < 2 then 2 else paa_;
def HalfPrd    = HmaLength / 2;
def HullPrd    = Sqrt(HmaLength);
def HalfPeriod = Floor(HalfPrd);
def HullPeriod = Floor(HullPrd);
def iLwmpHalf_ = iLwmp(src, HalfPeriod, Power);
def iLwmpHma_  = iLwmp(src, HmaLength, Power);
def iLwmpHalf  = iLwmpHalf_;
def iLwmpHma = iLwmpHma_;
def iLwmSrc  = (2.0 * iLwmpHalf) - iLwmpHma;
def hullout_ = iLwmp(iLwmSrc, HullPeriod, Power);
def hullout = hullout_;
def sig = hullout[1];
def colorout = hullout > sig;
def goLong  = Crosses(hullout, sig, CrossingDirection.ABOVE);
def goShort = Crosses(hullout, sig, CrossingDirection.BELOW);

AssignPriceColor(if !colorBars then Color.CURRENT else
                 if colorout then Color.GREEN else Color.RED);

plot hullLine = hullout;
hullLine.SetLineWeight(1);
hullLine.AssignValueColor(if colorout then Color.GREEN else Color.RED);

AddChartBubble(goLong, low, "L", Color.CYAN, no);
AddChartBubble(goShort, high, "S", GetColor(2));

######################
#END ADAPTIVE HULL
######################


Thanks in advance!
 
I need some help from the lovely folks at UTS,

I use this study below to scalp with, which @halcyonguy helped me implement keltner channels.

I use a 2 minute chart with this script which has a hull moving average, and I also place it on the 5 minute so I can watch for any "agreement" between the two. Its quite a powerful signal when both the 2 and 5 minute hull moving averages agree on a long or short signal. Could someone help me add in the option (an input to choose either 5 or 15 minute and turn off/on would be awesome but not mandatory) to print points (non-boolean) on the actual 2 minute hull line?

instead of only printing long or short (red/green) hull line when they are in agreement, is it possible to add a triangle, square, dot, etc on the 2 min hull line when the 5 minute agrees? And plot on the 2 min hull line?

Like this?

View attachment 21282

I could go the route where it wont print long or short unless they both agree, but I would like to keep the 2 minute signals as they are since I do scalp with them, but have noticed when both 2 and 5 agree, its a bigger and more sustained move and thus would like to have both options.

you may notice a difference in the scripts from the 2 and the 5 minute. The 5 minute is just a "lite" version of the 2 minute version, I commented out a bunch of erroneous logic that only complicates it and added the functionality that it paints the candles so its easy to spot.

Here is the script with the hull moving average and keltner channels.

Code:
#keltner_mod_avg with modifications by khpro59

# khpro- Considering all Keltner channels have a middle moving average, I wanted to create a keltner Channel that uses an adaptive stytle Hull Moving Average.

#SPECIAL THANKS TO: Loxx and Sam4Cok@Samer800 as the below script is based of their code(s) and Halcyonguy for adding in the keltner channels

# 2-9-24 Added standard Keltner Channels with LOXX Adaptive Hull being the center moving average (Thanks to Halcyonguy for the help!)

# 3-1-24 khpro - implemented alerts for Hull Line Long and Short Signals

input src = close;#, "Source", group = "Basic Settings")
input Power = 1;#, "Power", group = "Basic Settings")
input PhaseAccumulationCycles = 1.0;#, "Phase Accumulation Cycles", group = "Basic Settings")
input PhaseAccumulationPower = 1.0;#, "Phase Accumulation Power", group = "Basic Settings")
input colorBars = yes;#(true, "Color bars", group= "UI Options")
input showSigs = yes;#(true, "Show signals", group= "UI Options")

def na = Double.NaN;

Script calcComp {
input src = close;
    def out = (
         (0.0962 * src +
         0.5769 * src[2] -
         0.5769 * src[4] -
         0.0962 * src[6]) * (0.075 * src[1] + 0.54));
    plot return = out;
}
#iLwmp(src, len, pow) =>
script iLwmp {
    input src = close;
    input len1 = 10;
    input pow = 1;
    def len = if len1 < 2 then 2 else len1;
    def sumw_ = Power(len, pow);
    def sum_ = sumw_ * src;
    def sum1 = fold i = 1 to len with q=sum_ do
               q + Power(len - i, pow) * GetValue(src, i);
    def sumw1 = fold k = 1 to len with p=sumw_ do
               p + Power(len - k, pow);
    def sum = sum1;
    def sumw = sumw1;
    def iLwmp = sum / sumw;
    plot out = if isNaN(iLwmp) then (sum_/sumw_) else iLwmp;
}
#export paa(float src, float mult, float filt)=>
script paa {
    input src = close;
    input mult = 1;
    input filt = 0;
    def bar_index = AbsValue(BarNumber());
    def pi = Double.Pi;
    def degree = 180.0 / pi;
    def filter = Max(filt, 1);
    def I1;
    def Q1;
    def Phase;
    def period;
    def Smooth = if bar_index > 5 then
                 (4 * src + 3 * src[1] + 2 * src[2] + src[3]) / 10 else Smooth[1];
    def ts = calcComp(Smooth);
    def Detrender = if bar_index > 5 then ts else Detrender[1];
    def qs = calcComp(Detrender);
    def Q1_ = if bar_index > 5 then qs else Q1[1];
    def I1_ = if bar_index > 5 then Detrender[3] else I1[1];
        I1 = 0.15 * I1_ + 0.85 * I1[1];
        Q1 = 0.15 * Q1_ + 0.85 * Q1[1];
    def Phase1 = Phase[1];
    def Phase2 = if AbsValue(I1) > 0 then degree * ATan(AbsValue(Q1 / I1)) else Phase1;
    def Phase3 = if I1 < 0 and Q1 > 0 then 180 - Phase2 else Phase2;
    def Phase4 = if I1 < 0 and Q1 < 0 then 180 + Phase3 else Phase3;
        Phase  = if I1 > 0 and Q1 < 0 then 360 - Phase4 else Phase4;
    def DeltaPhase1 = Phase[1] - Phase;
    def DeltaPhase2 = if Phase[1] < 90 and Phase > 270 then
                      360 + Phase[1] - Phase else DeltaPhase1;
    def DeltaPhase3 = Max(Min(DeltaPhase2, 60), 7);
    def DeltaPhase = DeltaPhase3;
    def PhaseSum;
    def preSum;
    def count;
    if (PhaseSum[1] < (mult * 360) and count[1] < 4500) {
        preSum = GetValue(DeltaPhase, count[1]);
        PhaseSum = PhaseSum[1] + (if isNaN(preSum) then 0 else preSum);
        count = count[1] + 1;
    } else {
        preSum = 0;
        PhaseSum = PhaseSum[1];
        count = 0;
    }
    def InstPeriod = if count > 0 then count else InstPeriod[1];
    def alpha = 2.0 / (1.0 + filter);
    def period1 = period[1] + alpha * (InstPeriod - period[1]);
        period = if Floor(period1) < 1 then 1 else Floor(period1);
    def paa = Floor(period);
    plot return = if isNaN(paa) then 1 else paa;
}
def paa_ = paa(src, PhaseAccumulationCycles, PhaseAccumulationPower);
def HmaLength = if paa_ < 2 then 2 else paa_;
def HalfPrd    = HmaLength / 2;
def HullPrd    = Sqrt(HmaLength);
def HalfPeriod = Floor(HalfPrd);
def HullPeriod = Floor(HullPrd);
def iLwmpHalf_ = iLwmp(src, HalfPeriod, Power);
def iLwmpHma_  = iLwmp(src, HmaLength, Power);
def iLwmpHalf  = iLwmpHalf_;
def iLwmpHma = iLwmpHma_;
def iLwmSrc  = (2.0 * iLwmpHalf) - iLwmpHma;
def hullout_ = iLwmp(iLwmSrc, HullPeriod, Power);
def hullout = hullout_;
def sig = hullout[1];
def colorout = hullout > sig;
def goLong  = Crosses(hullout, sig, CrossingDirection.ABOVE);
def goShort = Crosses(hullout, sig, CrossingDirection.BELOW);

AssignPriceColor(if !colorBars then Color.CURRENT else
                 if colorout then Color.GREEN else Color.RED);

plot hullLine = hullout;
hullLine.SetLineWeight(1);
hullLine.AssignValueColor(if colorout then Color.GREEN else Color.RED);

#Alerts

AddChartBubble(goLong, low, "L", Color.CYAN, no);
AddChartBubble(goShort, high, "S", GetColor(2));

Alert(goLong, "HULL LONG SIG", Alert.Bar, Sound.Chimes);
Alert(goShort, "HULL SHORT SIG", Alert.Bar, Sound.Chimes);

#End Alerts

######################
#END ADAPTIVE HULL
######################

######################
#Begin Keltner Channels
######################


#declare weak_volume_dependency;

input displace = 0;
input factor = 1.5;
input length = 20;
input price = close;
input averageType = AverageType.SIMPLE;
input trueRangeAverageType = AverageType.SIMPLE;

def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length);
def average = MovingAverage(averageType, price, length);


input show_keltner_lines = yes;

plot Upper_Band = if show_keltner_lines then (hullout + shift[-displace]) else na;
Upper_Band.SetDefaultColor(GetColor(8));
plot Lower_Band = if show_keltner_lines then (hullout - shift[-displace]) else na;
Lower_Band.SetDefaultColor(GetColor(8));

#

And for what its worth here is the script I use on the 5 min chart to identify the agreement


Code:
#khpro59  2/9 - special thanks to Loxx for this code

# This is a lite version of the Hull Moving Average Keltner. It is bare bones to save resources and leaving only Hull's long and sell signals

input src = close;#, "Source", group = "Basic Settings")
input Power = 1;#, "Power", group = "Basic Settings")
input PhaseAccumulationCycles = 1.0;#, "Phase Accumulation Cycles", group = "Basic Settings")
input PhaseAccumulationPower = 1.0;#, "Phase Accumulation Power", group = "Basic Settings")
input colorBars = yes;#(true, "Color bars", group= "UI Options")
input showSigs = yes;#(true, "Show signals", group= "UI Options")

def na = Double.NaN;

Script calcComp {
input src = close;
    def out = (
         (0.0962 * src +
         0.5769 * src[2] -
         0.5769 * src[4] -
         0.0962 * src[6]) * (0.075 * src[1] + 0.54));
    plot return = out;
}
#iLwmp(src, len, pow) =>
script iLwmp {
    input src = close;
    input len1 = 10;
    input pow = 1;
    def len = if len1 < 2 then 2 else len1;
    def sumw_ = Power(len, pow);
    def sum_ = sumw_ * src;
    def sum1 = fold i = 1 to len with q=sum_ do
               q + Power(len - i, pow) * GetValue(src, i);
    def sumw1 = fold k = 1 to len with p=sumw_ do
               p + Power(len - k, pow);
    def sum = sum1;
    def sumw = sumw1;
    def iLwmp = sum / sumw;
    plot out = if isNaN(iLwmp) then (sum_/sumw_) else iLwmp;
}
#export paa(float src, float mult, float filt)=>
script paa {
    input src = close;
    input mult = 1;
    input filt = 0;
    def bar_index = AbsValue(BarNumber());
    def pi = Double.Pi;
    def degree = 180.0 / pi;
    def filter = Max(filt, 1);
    def I1;
    def Q1;
    def Phase;
    def period;
    def Smooth = if bar_index > 5 then
                 (4 * src + 3 * src[1] + 2 * src[2] + src[3]) / 10 else Smooth[1];
    def ts = calcComp(Smooth);
    def Detrender = if bar_index > 5 then ts else Detrender[1];
    def qs = calcComp(Detrender);
    def Q1_ = if bar_index > 5 then qs else Q1[1];
    def I1_ = if bar_index > 5 then Detrender[3] else I1[1];
        I1 = 0.15 * I1_ + 0.85 * I1[1];
        Q1 = 0.15 * Q1_ + 0.85 * Q1[1];
    def Phase1 = Phase[1];
    def Phase2 = if AbsValue(I1) > 0 then degree * ATan(AbsValue(Q1 / I1)) else Phase1;
    def Phase3 = if I1 < 0 and Q1 > 0 then 180 - Phase2 else Phase2;
    def Phase4 = if I1 < 0 and Q1 < 0 then 180 + Phase3 else Phase3;
        Phase  = if I1 > 0 and Q1 < 0 then 360 - Phase4 else Phase4;
    def DeltaPhase1 = Phase[1] - Phase;
    def DeltaPhase2 = if Phase[1] < 90 and Phase > 270 then
                      360 + Phase[1] - Phase else DeltaPhase1;
    def DeltaPhase3 = Max(Min(DeltaPhase2, 60), 7);
    def DeltaPhase = DeltaPhase3;
    def PhaseSum;
    def preSum;
    def count;
    if (PhaseSum[1] < (mult * 360) and count[1] < 4500) {
        preSum = GetValue(DeltaPhase, count[1]);
        PhaseSum = PhaseSum[1] + (if isNaN(preSum) then 0 else preSum);
        count = count[1] + 1;
    } else {
        preSum = 0;
        PhaseSum = PhaseSum[1];
        count = 0;
    }
    def InstPeriod = if count > 0 then count else InstPeriod[1];
    def alpha = 2.0 / (1.0 + filter);
    def period1 = period[1] + alpha * (InstPeriod - period[1]);
        period = if Floor(period1) < 1 then 1 else Floor(period1);
    def paa = Floor(period);
    plot return = if isNaN(paa) then 1 else paa;
}
def paa_ = paa(src, PhaseAccumulationCycles, PhaseAccumulationPower);
def HmaLength = if paa_ < 2 then 2 else paa_;
def HalfPrd    = HmaLength / 2;
def HullPrd    = Sqrt(HmaLength);
def HalfPeriod = Floor(HalfPrd);
def HullPeriod = Floor(HullPrd);
def iLwmpHalf_ = iLwmp(src, HalfPeriod, Power);
def iLwmpHma_  = iLwmp(src, HmaLength, Power);
def iLwmpHalf  = iLwmpHalf_;
def iLwmpHma = iLwmpHma_;
def iLwmSrc  = (2.0 * iLwmpHalf) - iLwmpHma;
def hullout_ = iLwmp(iLwmSrc, HullPeriod, Power);
def hullout = hullout_;
def sig = hullout[1];
def colorout = hullout > sig;
def goLong  = Crosses(hullout, sig, CrossingDirection.ABOVE);
def goShort = Crosses(hullout, sig, CrossingDirection.BELOW);

AssignPriceColor(if !colorBars then Color.CURRENT else
                 if colorout then Color.GREEN else Color.RED);

plot hullLine = hullout;
hullLine.SetLineWeight(1);
hullLine.AssignValueColor(if colorout then Color.GREEN else Color.RED);

AddChartBubble(goLong, low, "L", Color.CYAN, no);
AddChartBubble(goShort, high, "S", GetColor(2));

######################
#END ADAPTIVE HULL
######################


Thanks in advance!

i don't think it can be done. the 2nd agg time ( 5min ) , should be a multiple of chart minutes ( 2min ) .
and it is not
 
i don't think it can be done. the 2nd agg time ( 5min ) , should be a multiple of chart minutes ( 2min ) .
and it is not
ahhhhh ok wow I never knew that. Could that be fixed by making it 1min and 5 min? Or at least 2min and 10minute?

Edit: Could you help me code it as 1m/5m? or 2m/6m?

Thank you for the help
 
Last edited:
Given what @halcyonguy has said, would anyone be willing to help complete this as a 1m/5m + 2m/6m? Unfortunately I wish I could be more definitive and say one or the other, but I would like to back test since I am not accustomed to trading the 1minute or 6minute chart variables.

Thank you! And thank you @mark.917 for the wisdom.
 

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
455 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