GERMANB1990
New member
I found a code for hurts channel
Code:
# Hurst_Channels
#
# www.trendxplorer.info
# [email protected]
#
# Build: July 25, 2012
# Rev 1: July 27, 2012: ExtrapolatedMA based on Kirills code
# Rev 2: July 29, 2012: FlowPrice value for better extremes
# Rev 3: Sept 9, 2012: Coloring for ExtrapolatedCMA added
#
#
# --- script begin ----
#
declare upper;
input price = hl2;
input length = 10;
input InnerValue = 1.6;
input OuterValue = 2.6;
input ExtremeValue = 4.2;
input showFlowPrice = NO;
input showPriceBar = YES;
input smooth = 1;
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]);
plot CenteredMA = if !IsNaN(dPrice) then CMA else Double.NaN;
CenteredMA.SetDefaultColor(GetColor(1));
CenteredMA.SetLineWeight(2);
plot ExtrapolatedMA = if !IsNaN(price) and IsNaN(dprice[-1]) then CMA else
Double.NaN;
ExtrapolatedMA.SetDefaultColor(GetColor(0));
ExtrapolatedMA.SetLineWeight(2);
ExtrapolatedMA.SetStyle(Curve.SHORT_DASH);
ExtrapolatedMA.DefineColor("Up", Color.Magenta);
ExtrapolatedMA.DefineColor("Down", Color.Yellow);
ExtrapolatedMA.AssignValueColor(if ExtrapolatedMA >= ExtrapolatedMA[1] then ExtrapolatedMA.color("Up") else ExtrapolatedMA.color("Down"));
def ExtremeBand = CMA * ExtremeValue / 100;;
def OuterBand = CMA * OuterValue / 100;
def InnerBand = CMA * InnerValue / 100;
plot UpperExtremeBand = if !IsNaN(price) then CMA + ExtremeBand else Double.Nan;
plot LowerExtremeBand = if !IsNaN(price) then CMA - ExtremeBand else Double.Nan;
plot UpperOuterBand = if !IsNaN(price) then CMA + OuterBand else Double.Nan;
plot LowerOuterBand = if !IsNaN(price) then CMA - OuterBand else Double.Nan;
plot UpperInnerBand = if !IsNaN(price) then CMA + InnerBand else Double.Nan;
plot LowerInnerBand = if !IsNaN(price) then CMA - InnerBand else Double.Nan;
UpperExtremeBand.SetDefaultColor(GetColor(4));
UpperExtremeBand.SetLineWeight(2);
LowerExtremeBand.SetDefaultColor(GetColor(4));
LowerExtremeBand.SetLineWeight(2);
UpperExtremeBand.hide();
LowerExtremeBand.hide();
UpperOuterBand.SetDefaultColor(GetColor(5));
UpperOuterBand.SetLineWeight(2);
LowerOuterBand.SetDefaultColor(GetColor(6));
LowerOuterBand.SetLineWeight(2);
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);
#Rev 2:
#def FlowValue = if close > close[1] then high else if close < close[1] then low else (high + low)/2;
def FlowValue =
if high >= high[1] and low <= low[1]
then
if close >= close[1] #or high >= high[2]
then high
else low
else
if high > high[1]
then high
else
if low < low[1]
then low
else
if close > close[1]
then high
else
if close < close[1]
then low
else (high + low) / 2;
plot FlowPrice = if showFlowPrice then Average(FlowValue, smooth) else double.nan;
FlowPrice.SetDefaultColor(GetColor(9));
FlowPrice.SetLineWeight(2);
hidePricePlot(!showPriceBar);
#
# --- script end ----
#