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?
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.
And for what its worth here is the script I use on the 5 min chart to identify the agreement
Thanks in advance!
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?
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!