#EMAD Range by @ Christopher84
#EMAD V1000 - added arrow conditions - histogram - and color conditions HODL
#DECLARATIONS
declare lower;
#USER INPUTS
input showHLLH = no;
input showHowToLabel = yes;
input ShowColorCodeLabel = no;
input showtestlabels = no;
input showEMACloud = yes;
input showBubbles = no;
input showTripleExh = yes;
input showehlers = no;
input showMAD = no;
input showverticalline = yes;
input bandLength = 100;
input bandLength2 = 100;
input ELlength = 34;
Input LengtH_MAD = 4;
input fastLength = 10;
input slowLength = 35;
input lengthBAD = 3;
input smoothLength = 12;
input smoothLength2 = 14;
input ATRPeriod = 5;
input ATRFactor = 2.0;
input length_3x = 1000;
input priceType = close;
input emadLineWeight = 2;
input averageType = AverageType.WILDERS;
input averageType_Sq = AverageType.SIMPLE;
input firstTrade_Sq = {default long, short};
input trailType = {default modified, unmodified};
input firstTrade = {default long, short};
input filterBounceArrows = 1;
input filter_3x = 50;
input Control_3x = 3;
input crossabovebelowzero = 20;
input bandlengthbottom2 = 3;
input Lookback = 20;
input cloudlinelook = 20;
input LHHL_Lookback = 1;
input Steplookback = 10;
input filterZeroline = 20;
input topbanddownlookback = 1;
input bottombanduplookback = 1;
input SqueezeLook = 5;
input alert4lookback = 21;
input PreviousStepsDown = 2;
input PreviousStepsUp = 2;
input alert4control = 2;
input tradeDaytimeOnly = yes; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
input OpenTime = 0730; #hint OpenTime: Opening time of market
input CloseTime = 1800; #hint CloseTime: Closing time of market
def bn = barnumber();
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
def isIntraDay = if GetAggregationPeriod() > 14400000 or GetAggregationPeriod() == 0 then 0 else 1;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else if tradeDaytimeOnly and isIntraDay and Begin > 0 and End > 0 then 1 else 0;
#GLOBAL COLOR DEFINITIONS
DefineGlobalColor("Green", CreateColor(0, 155, 0));
DefineGlobalColor("Red", CreateColor(225, 105, 105));
DefineGlobalColor("Gray", CreateColor(192, 192, 192));
DefineGlobalColor("Yellow", CreateColor(231, 190, 0));
## UPPER EMAD LINE
def fastExpAvg = ExpAverage(priceType, fastLength);
def slowExpAvg = ExpAverage(priceType, slowLength);
def EMAD = (priceType - fastExpAvg);
def EMAD2 = (priceType - slowExpAvg);
def EMADAvg = (EMAD + EMAD2) / 2;
def upperEMADLine = ExpAverage(EMADAvg, smoothLength);
## LOWER EMAD LINE
def emadOpen = (upperEMADLine + upperEMADLine[1]) / 2;
def emadHigh = Max(upperEMADLine, upperEMADLine[1]);
def emadLow = Min(upperEMADLine, upperEMADLine[1]);
def emadClose = upperEMADLine;
def bottom = Min(emadClose[1], emadLow);
def tr = TrueRange(emadHigh, emadClose, emadLow);
def ptr = tr / (bottom + tr / 2);
def APTR = MovingAverage(averageType, ptr, smoothLength2);
def upperBand = emadClose[1] + (APTR * emadOpen);
def lowerBand = emadClose[1] - (APTR * emadOpen);
def lowerEMADLine = (upperBand + lowerBand) / 2;
## TOP AND BOTTOM BANDS
def zeroLineData = if IsNaN(close) then Double.NaN else 0;
def EMADSUp = upperEMADLine > zeroLineData;
def EMADSDown = upperEMADLine < zeroLineData;
def EMADdown = (lowerEMADLine > upperEMADLine);
def EMADup = (upperEMADLine >= lowerEMADLine);
def topBand = Highest(lowerEMADLine, bandLength);
def bottomBand = Lowest(lowerEMADLine, bandLength);
def zerolinedatacondition = if (zerolinedata > topBand) then topBand else if (zerolinedata < bottomBand) then bottomBand else 0;
## Master
def masteremadline = (upperEMADLine + lowerEMADLine) / 2;
## BAND DIRECTION (USED ONLY FOR COLORING - NOT USED FOR PLOTS)
def topBandStepDown = if topBand < topBand[1] then 1 else 0;
def topBandStepUp = if topBand > topBand[1] then 1 else 0;
def bottomBandStepDown = if bottomBand < bottomBand[1] then 1 else 0;
def bottomBandStepUp = if bottomBand > bottomBand[1] then 1 else 0;
def bothBandsDown = bottomBandStepDown and topBandStepDown;
def bothBandsUp = bottomBandStepUp and topBandStepUp;
def bullBias = (bottomBand > zeroLineData);
def bearBias = (topBand < zeroLineData);
## BUBBLE CALCULATIONS (USED ONLY FOR BUBBLES)
def midBand = (upperBand + lowerBand) / 2;
def crossesUp = if (midBand[1] > upperEMADLine[1])and(midBand < upperEMADLine) then 1 else 0;
def crossesDown = if (upperEMADLine[1] > midBand[1])and(upperEMADLine < midBand) then 1 else 0;
def valueUp = if crossesUp then midBand else 0;
def valueDown = if crossesDown then midBand else 0;
def crossesUpline = if (valueUp - bottomBand) == 0 then 1 else 0;
def crossesDownline = if (valueDown - topBand) == 0 then 1 else 0;
def crossesUpline_filter = if crossesUpline and (crossesUpline[1] or crossesUpline[2] or crossesUpline[3] or crossesUpline[4])then 0 else 1;
def crossesDownline_filter = if crossesDownline and (crossesDownline[1] or crossesDownline[2] or crossesDownline[3] or crossesDownline[4])then 0 else 1;
def crossesUpZeroline = if (valueUp) == 0 then 1 else 0;
def crossesDownZeroline = if (valueDown) == 0 then 1 else 0;
def crossesUpBottomlinebn = if crossesUpline and !crossesUpline[1] then bn else crossesUpBottomlinebn[1];
def crossesDownToplinebn = if crossesDownline and !crossesDownline[1] then bn else crossesDownToplinebn[1];
def crossuplinewithin = if crossesUpBottomlinebn < bn then bn - crossesUpBottomlinebn else crossuplinewithin[1];
def crossdownlinewithin = if crossesDownToplinebn < bn then bn - crossesDownToplinebn else crossdownlinewithin[1];
def crosslinefirst = if crossuplinewithin < crossdownlinewithin then 1 else 0;
def crosslinelogic = crossesUpBottomlinebn > crossesDownToplinebn;
def HL = crossesUpline == 0 and crossesDownline == 0 and upperEMADLine crosses above lowerEMADLine; #Normal HL LH condition
def LH = crossesDownline == 0 and upperEMADLine crosses below lowerEMADLine; #Normal HL LH condition
def bounceUpOnce = crossesUpline <> crossesUpline[1]; #XUpBtm happened previous bar or on current bar
def bounceDnOnce = crossesDownline <> crossesDownline[1];
def trackCrUp = if bounceUpOnce then 0 else if HL then 1 else trackCrUp[1];
def trackCrDn = if bounceDnOnce then 0 else if LH then 1 else trackCrDn[1];
## SECOND HL AND LH
def HLalready = if trackCrUp and !trackCrUp[1] then 1 else 0;
def LHalready = if trackCrDn and !trackCrDn[1] then 1 else 0;
def HL2 = HLalready == 0 and upperEMADLine crosses above lowerEMADLine;
def LH2 = LHalready == 0 and upperEMADLine crosses below lowerEMADLine;
def crossedUpOnce = HLalready <> HLalready[1];
def crossedDnOnce = LHalready <> LHalready[1];
def trackCrUp2 = if crossedUpOnce then 0 else if HL2 then 1 else trackCrUp2[1];
def trackCrDn2 = if crossedDnOnce then 0 else if LH2 then 1 else trackCrDn2[1];
#####################################################
## ##
#####################################################
def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
def HRef = if low <= high[1]
then high - close[1]
else (high - close[1]) - 0.5 * (low - high[1]);
def LRef = if high >= low[1]
then close[1] - low
else (close[1] - low) - 0.5 * (low[1] - high);
def trueRange_Sq;
switch (trailType) {
case modified:
trueRange_Sq = Max(HiLo, Max(HRef, LRef));
case unmodified:
trueRange_Sq = TrueRange(high, close, low);
}
def loss_Sq = ATRFactor * MovingAverage(averageType_Sq, trueRange_Sq, ATRPeriod);
def state_Sq = {default init, long, short};
def trail_Sq;
switch (state_Sq[1]) {
case init:
if (!IsNaN(loss_Sq)) {
switch (firstTrade) {
case long:
state_Sq = state_Sq.long;
trail_Sq = close - loss_Sq;
case short:
state_Sq = state_Sq.short;
trail_Sq = close + loss_Sq;
}
} else {
state_Sq = state_Sq.init;
trail_Sq = Double.NaN;
}
case long:
if (close > trail_Sq[1]) {
state_Sq = state_Sq.long;
trail_Sq = Max(trail_Sq[1], close - loss_Sq);
} else {
state_Sq = state_Sq.short;
trail_Sq = close + loss_Sq;
}
case short:
if (close < trail_Sq[1]) {
state_Sq = state_Sq.short;
trail_Sq = Min(trail_Sq[1], close + loss_Sq);
} else {
state_Sq = state_Sq.long;
trail_Sq = close - loss_Sq;
}
}
def TrailingStop_Sq = trail_Sq;
def H = Highest(TrailingStop_Sq, 12);
def L = Lowest(TrailingStop_Sq, 12);
def BulgeLengthPrice = 100;
def SqueezeLengthPrice = 100;
def BandwidthC3 = (H - L);
def IntermResistance2 = Highest(BandwidthC3, BulgeLengthPrice);
def IntermSupport2 = Lowest(BandwidthC3, SqueezeLengthPrice);
def sqzTrigger = BandwidthC3 <= IntermSupport2;
def sqzLevel = if !sqzTrigger[1] and sqzTrigger then hl2 else if !sqzTrigger then Double.NaN else sqzLevel[1];
def Squeeze_Alert_1 = if sqzLevel then (upperEMADLine + lowerEMADLine) / 2 else (upperEMADLine + lowerEMADLine) / 2 ;
#####################################################
## ##
#####################################################
def over_bought_3x = 80;
def over_sold_3x = 20;
def KPeriod_3x = 10;
def DPeriod_3x = 10;
def priceH1 = high;
def priceL1 = low;
def priceC1 = close;
def priceO1 = close;
def priceH_3x = high;
def priceL_3x = low;
def priceC_3x = close;
def SlowK_3x = reference StochasticFull(over_bought_3x, over_sold_3x, KPeriod_3x, DPeriod_3x, priceH_3x, priceL_3x, priceC_3x, 3, if (averageType == 1) then AverageType.SIMPLE else AverageType.EXPONENTIAL).FullK;
def MACD_3x = reference MACD()."Value";
def priceMean_3x = Average(MACD_3x, length_3x);
def MACD_stdev_3x = (MACD_3x - priceMean_3x) / StDev(MACD_3x, length_3x);
def dPlus_3x = reference DMI()."DI+";
def dMinus_3x = reference DMI()."DI-";
def sellerRegular = SlowK_3x < 20 and MACD_stdev_3x < -1 and dPlus_3x < 15;
def sellerExtreme = SlowK_3x < 20 and MACD_stdev_3x < -2 and dPlus_3x < 15;
def buyerRegular = SlowK_3x > 80 and MACD_stdev_3x > 1 and dMinus_3x < 15;
def buyerExtreme = SlowK_3x > 80 and MACD_stdev_3x > 2 and dMinus_3x < 15;
def ExtremeBuy1 = if sellerExtreme[1] and !sellerExtreme then 1 else 0;
def ExtremeSell1 = if buyerExtreme[1] and !buyerExtreme then 1 else 0;
def RegularSell1 = if buyerRegular[1] and !buyerRegular then 1 else 0;
def RegularBuy1= if sellerRegular[1] and !sellerRegular then 1 else 0;
#####################################################
## ##
#####################################################
def priceE = (emadhigh + emadlow) / 2;
def coeff = ELlength * priceE * priceE - 2 * priceE * sum(priceE, ELlength)[1] + sum(priceE * priceE, ELlength)[1];
def Ehlers = sum(coeff * priceE, ELlength) / sum(coeff, ELlength);
#####################################################
## ##
#####################################################
def dataA = masterEMADLine;
def dataA1 =
fold aD = 0
to LengtH_MAD
with k = 0
do k + dataA[aD];
def MAEMAD = dataA1 / LengtH_MAD;
def MAD = MAEMAD;
def ElCrossDN = ehlers crosses above masterEMADline;
def ElCrossUP = ehlers crosses below masterEMADline;
def bullBias2 = (emadsup);
def bearBias2 = (emadsdown);
def MADehlers = (MAD - Ehlers)/2;
def Madebad = madehlers + ehlers;
def madebadavg = average(madebad, lengthBAD);
def crossmadeup = madebad > madebad[1];
def crossmadedn = madebad < madebad[1];
def crossmade2up = if (madebad < masterEMADLine) and crossmadeup and (bullBias2 > 0) then 1 else 0;
def crossmade2dn = if (madebad > masterEMADLine) and crossmadedn and (bearBias2 > 0) then 1 else 0;
def crossmade2 = if (madebad < masterEMADLine) and crossmadeup and (bullBias2 > 0) then 1 else if (madebad > masterEMADLine) and crossmadedn and (bearBias2 > 0) then -1 else 0;
def crossmade0 = if (!crossmade2[1] or !crossmade2[1]) and (crossmade2 == 0) then 1 else 0;
#####################################################
## ##
#####################################################
def pd = 22;
def bbl = 20;
def mult = 2.0;
def lb = 50;
def ph = 0.85;
def ltLB = 40;
def mtLB = 14;
def str = 3;
def wvf = ((Highest(close, pd) - low) / (Highest(close, pd))) * 100;
def sDev = mult * StDev(wvf, bbl);
def midLine1 = SimpleMovingAvg(wvf, bbl);
def lowerBand1 = midLine1 - sDev;
def upperBand1 = midLine1 + sDev;
def rangeHigh = (Highest(wvf, lb)) * ph;
def upRange = low > low[1] and close > high[1];
def upRange_Aggr = close > close[1] and close > open[1];
def filtered = ((wvf[1] >= upperBand1[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand1 and wvf < rangeHigh));
def filtered_Aggr = (wvf[1] >= upperBand1[1] or wvf[1] >= rangeHigh[1]);
def alert4 = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr;
def alert4close = if alert4 then close else 0;
def crossmade = if (madebad < masterEMADLine) and crossmadeup then 1 else if (madebad > masterEMADLine) and crossmadedn then -1 else 0;
def madedn = (madebad > masterEMADLine);
def madeup = (madebad < masterEMADLine);
def made2 = madebadavg;
def made3 = if !madedn and (made2 <= zerolinedata) then madebadavg else double.nan;
def made4 = if !madeup and (made2 >= zerolinedata) then madebadavg else double.nan;
def madecrossupavg = if made2 crosses below masterEMADLine then 1 else 0;
def madecrossdownavg = if made2 crosses above masterEMADLine then 1 else 0;
def crossmadelogicup = if madecrossupavg and !madecrossupavg[1] then 1 else 0;
def crossmadelogicdown = if madecrossdownavg and !madecrossdownavg[1] then 1 else 0;
def crossmademorelogicup = if crossmadelogicup and crosslinelogic and emadup[1] then 1 else 0;
def crossmademorelogicdown = if crossmadelogicdown and !crosslinelogic and emaddown[1] then 1 else 0;
def EmaPushStepUp = if topBandStepUp and EmadUp and (((upperEMADLine) - bottomband) == 0) then 1 else 0;;
def EmaPushStepDown = if bottomBandStepDown and EmadDown and (((lowerEMADLine) - bottomband) == 0) then 1 else 0;
def HLFilter = if HL[1] < HL then 1 else 0;
def LHFilter = if LH[1] > LH then 1 else 0;
def HLFilter2 = if HL[2] < HL[1] then 1 else 0;
def LHFilter2 = if LH[2] > LH[1] then 1 else 0;
#####################################################
## ##
#####################################################
def ValueUp_lookback = fold index1 = 1 to filterBounceArrows with x1 do x1 + absvalue(valueUp)[index1];
def ValueDown_lookback = fold index2 = 1 to filterBounceArrows with x2 do x2 + absvalue(valueDown)[index2];
def topBandStepDown_lookback = fold index3 = 1 to Steplookback with x3 do x3 + topBandStepDown[index3];
def topBandStepUp_lookback = fold index4 = 1 to Steplookback with x4 do x4 + topBandStepUp[index4];
def bottomBandStepDown_lookback = fold index5 = 1 to Steplookback with x5 do x5 + bottomBandStepDown[index5];
def bottomBandStepUp_lookback = fold index6 = 1 to Steplookback with x6 do x6 + bottomBandStepUp[index6];
def bothBandsDown_lookback = fold index7 = 1 to filterBounceArrows with x7 do x7 + bothBandsDown[index7];
def bothBandsUp_lookback = fold index8 = 1 to filterBounceArrows with x8 do x8 + bothBandsUp[index8];
def bullBias_lookback = fold index9 = 1 to filterBounceArrows with x9 do x9 + bullBias[index9];
def bearBias_lookback = fold index10 = 1 to filterBounceArrows with x10 do x10 + bearBias[index10];
def crossesUpZeroline_lookback = fold index11 = 1 to filterZeroline with x11 do x11 + crossesUpZeroline[index11];
def crossesDownZeroline_lookback = fold index12 = 1 to filterZeroline with x12 do x12 + crossesDownZeroline[index12];
def crossesUpBottomline_lookback = fold index13 = 1 to filterBounceArrows with x13 do x13 + crossesUpline[index13];
def crossesDownTopline_lookback = fold index14 = 1 to filterBounceArrows with x14 do x14 + crossesDownline[index14];
def CrossedUPaboveZero_lookback = fold index15 = 1 to crossabovebelowzero with x15 do x15 + crossesUpZeroline[index15];
def CrossedDOWNbelowZero_lookback = fold index16 = 1 to crossabovebelowzero with x16 do x16 + crossesDownZeroline[index16];
def HL_lookback = fold index17 = 1 to LHHL_Lookback with x17 do x17 + HL[index17];
def LH_lookback = fold index18 = 1 to LHHL_Lookback with x18 do x18 + LH[index18];
def upabovezero_lookback = fold index19 = 1 to crossabovebelowzero with x19 do x19 + HL[index19];
def downbelowzero_lookback = fold index20 = 1 to crossabovebelowzero with x20 do x20 + LH[index20];
def PriceMonitor = fold index21 = 1 to crossabovebelowzero with x21 do x21 + HL[index21];
def ExtremeBuy1_lookback = fold index24 = 1 to filter_3x with x24 do x24 + ExtremeBuy1[index24];
def ExtremeSell1_lookback = fold index25 = 1 to filter_3x with x25 do x25 + ExtremeSell1[index25];
def RegularSell1_lookback = fold index26 = 1 to filter_3x with x26 do x26 + RegularSell1[index26];
def RegularBuy1_lookback = fold index27 = 1 to filter_3x with x27 do x27 + RegularBuy1[index27];
def Squeeze_lookback = fold index28 = 1 to SqueezeLook with x28 do x28 + Squeeze_Alert_1[index28];
def ElCrossDN_lookback = fold index29 = 1 to filterBounceArrows with x29 do x29 + ElCrossDN[index29];
def ElCrossUP_lookback = fold index30 = 1 to filterBounceArrows with x30 do x30 + ElCrossUP[index30];
def bearBias2_lookback = fold index31 = 1 to filterBounceArrows with x31 do x31 + bearBias2[index31];
def bullBias2_lookback = fold index32 = 1 to filterBounceArrows with x32 do x32 + bullBias2[index32];
def crossmade0_lookback = fold index33 = 1 to cloudlinelook with x33 do x33 + crossmade0[index33];
def alert4_lookback = fold index34 = 1 to alert4lookback with x34 do x34 + alert4close[index34];
#####################################################
## ##
#####################################################
def bubblehidertopdown = topBandStepDown_lookback > PreviousStepsDown;
def bubblehidertopup = topBandStepup_lookback > PreviousStepsUp;
def bubblehiderbottomdown = bottomBandStepDown_lookback > PreviousStepsDown;
def bubblehiderbottomup = bottomBandStepup_lookback > PreviousStepsUp;
def UP1 = if marketopen and (!bubblehidertopdown or !bubblehiderbottomdown) and !EmaPushStepDown and crossmademorelogicup then midBand else double.nan;
def DOWN1 = if marketopen and (!bubblehidertopup or !bubblehiderbottomup) and !EmaPushStepUp and crossmademorelogicdown then midBand else double.nan;
#####################################################
## ##
#####################################################
plot zeroLine = zerolinedata;
plot Squeeze_Alert = if sqzLevel then (upperEMADLine + lowerEMADLine) / 2 else (upperEMADLine + lowerEMADLine) / 2 ;
plot ExtremeBuy = if showTripleExh and sellerExtreme[1] and !sellerExtreme then midband else Double.NaN;
plot ExtremeSell = if showTripleExh and buyerExtreme[1] and !buyerExtreme then midband else Double.NaN;
plot RegularSell = if showTripleExh and buyerRegular[1] and !buyerRegular then midband else Double.NaN;
plot RegularBuy = if showTripleExh and sellerRegular[1] and !sellerRegular then midband else Double.NaN;
plot topBandPlot = topBand;
plot bottomBandPlot = bottomBand;
plot upperEMADLinePlot = upperEMADLine;
plot lowerEMADLinePlot = lowerEMADLine;
plot masterEMADLinePlot2 = (upperEMADLine + lowerEMADLine) / 2;
plot masterEMADLinePlot = ((upperEMADLinePlot + lowerEMADLinePlot) / 2);
plot made1 = made4;
plot made = made3;
plot UP = UP1;
plot DOWN = DOWN1;
plot firstHL = if showHLLH and trackCrUp and !trackCrUp[1] then lowerEMADLine else double.nan;
plot firstLH = if showHLLH and trackCrDn and !trackCrDn[1] then lowerEMADLine else double.nan;
plot secondHL = if showHLLH and trackCrUp2 and !trackCrUp2[1] and !crossesUpline then lowerEMADLine else double.nan;
plot secondLH = if showHLLH and trackCrDn2 and !trackCrDn2[1] and !crossesDownline then lowerEMADLine else double.nan;
#####################################################
## ##
#####################################################
def firstHL2 = if trackCrUp and !trackCrUp[1] then 1 else 0;
def firstLH2 = if trackCrDn and !trackCrDn[1] then 1 else 0;
def HLBuy = if firstHL2 and regularsell1 or extremesell1 then 1 else 0;
def LHSell = if firstHL2 and regularbuy1 or extremebuy1 then 1 else 0;
#####################################################
## ##
#####################################################
UP.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UP.SetLineWeight(1);
UP.SetDefaultColor(Color.white);
UP.HideBubble();
UP.HideTitle();
#####################################################
## ##
#####################################################
DOWN.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DOWN.SetLineWeight(1);
DOWN.SetDefaultColor(Color.white);
DOWN.HideBubble();
DOWN.HideTitle();
#####################################################
## ##
#####################################################
made1.AssignValueColor(
if crossmade2 == 1 then color.dark_green
else if crossmade2 == -1 then color.dark_red
else if crossmade0_lookback > 1 and crosslinelogic then Color.gray
else color.dark_red);
#####################################################
## ##
#####################################################
made.AssignValueColor(
if crossmade2 == 1 then color.dark_green
else if crossmade2 == -1 then color.dark_red
else if crossmade0_lookback > 1 and crosslinelogic then Color.gray
else color.dark_red);
#####################################################
## ##
#####################################################
Squeeze_Alert.SetPaintingStrategy(PaintingStrategy.line);
Squeeze_Alert.SetLineWeight(2);
Squeeze_Alert.SetDefaultColor(Color.YELLOW);
#####################################################
## ##
#####################################################
RegularBuy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ExtremeBuy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
RegularSell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ExtremeSell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#####################################################
## ##
#####################################################
RegularBuy.SetLineWeight((1));
ExtremeBuy.SetLineWeight((1));
RegularSell.SetLineWeight((1));
ExtremeSell.SetLineWeight((1));
#####################################################
## ##
#####################################################
ExtremeSell.SetDefaultColor((Color.WHITE));
ExtremeBuy.SetDefaultColor((Color.WHITE));
RegularBuy.SetDefaultColor((Color.white));
RegularSell.SetDefaultColor((Color.white));
#####################################################
## ##
#####################################################
firstHL.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
firstHL.SetLineWeight(1);
firstHL.SetDefaultColor(Color.blue);
firstHL.HideBubble();
firstHL.HideTitle();
#####################################################
## ##
#####################################################
firstLH.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
firstLH.SetLineWeight(1);
firstLH.SetDefaultColor(Color.blue);
firstLH.HideBubble();
firstLH.HideTitle();
#####################################################
## ##
#####################################################
secondHL.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
secondHL.SetLineWeight(1);
secondHL.SetDefaultColor(Color.CYAN);
secondHL.HideBubble();
secondHL.HideTitle();
#####################################################
## ##
#####################################################
secondLH.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
secondLH.SetLineWeight(1);
secondLH.SetDefaultColor(Color.CYAN);
secondLH.HideBubble();
secondLH.HideTitle();
#####################################################
## ##
#####################################################
masterEMADLinePlot.SetPaintingStrategy(PaintingStrategy.histogram);
masterEMADLinePlot.HideBubble();
masterEMADLinePlot.SetLineWeight(1);
masterEMADLinePlot.AssignValueColor(
if alert4 then color.cyan
else if HLBuy then color.light_green
else if LHSell then color.light_red
else if crossmade2up then Color.dark_green
else if crossmade2dn then color.dark_red
else if crossmade0_lookback > 1 and crosslinelogic then Color.dark_gray
else color.dark_red
);
DefineGlobalColor("G0", CreateColor(0, 255, 0)); #Green
DefineGlobalColor("G1", CreateColor(0, 229, 0)); #Green
DefineGlobalColor("G2", CreateColor(0, 206, 0)); #Green
DefineGlobalColor("G3", CreateColor(0, 186, 0)); #Green
DefineGlobalColor("G4", CreateColor(0, 167, 0)); #Green
DefineGlobalColor("G5", CreateColor(0, 151, 0)); #Green
DefineGlobalColor("G6", CreateColor(0, 136, 0)); #Green
DefineGlobalColor("G7", CreateColor(0, 122, 0)); #Green
DefineGlobalColor("G8", CreateColor(0, 109, 0)); #Green
DefineGlobalColor("G9", CreateColor(0, 98, 0)); #Green
DefineGlobalColor("R0", CreateColor(255, 0, 0)); #Red
DefineGlobalColor("R1", CreateColor(224, 0, 0)); #Red
DefineGlobalColor("R2", CreateColor(197, 0, 0)); #Red
DefineGlobalColor("R3", CreateColor(174, 0, 0)); #Red
DefineGlobalColor("R4", CreateColor(153, 0, 0)); #Red
DefineGlobalColor("R5", CreateColor(135, 0, 0)); #Red
DefineGlobalColor("R6", CreateColor(118, 0, 0)); #Red
DefineGlobalColor("R7", CreateColor(104, 0, 0)); #Red
DefineGlobalColor("R8", CreateColor(92, 0, 0)); #Red
DefineGlobalColor("R9", CreateColor(81, 0, 0)); #Red
upperEMADLinePlot.HideTitle();
upperEMADLinePlot.HideBubble();
upperEMADLinePlot.AssignValueColor(
if (lowerEMADLinePlot > upperEMADLinePlot) then createcolor(153, 0, 0)
else if (lowerEMADLinePlot < upperEMADLinePlot) then createcolor(0, 167, 0)
else GlobalColor("Gray")
);
lowerEMADLinePlot.HideTitle();
lowerEMADLinePlot.HideBubble();
lowerEMADLinePlot.AssignValueColor(
if (lowerEMADLinePlot > upperEMADLinePlot) then Color.red
else if (lowerEMADLinePlot < upperEMADLinePlot) then Color.green
else GlobalColor("Gray")
);
masterEMADLinePlot2.HideTitle();
masterEMADLinePlot2.HideBubble();
masterEMADLinePlot2.SetLineWeight(emadLineWeight);
masterEMADLinePlot2.AssignValueColor(
if masterEMADLinePlot > masterEMADLinePlot[2] then createColor(0, 186, 0)
else if masterEMADLinePlot < masterEMADLinePlot[2] then createColor(174, 0, 0)
else GlobalColor("Gray")
);
zeroLine.HideTitle();
zeroLine.HideBubble();
zeroLine.AssignValueColor(
if (upperEMADLinePlot > zeroLine) then Color.green
else if (upperEMADLinePlot < zeroLine) then Color.red
else GlobalColor("Yellow")
);
topBandPlot.HideTitle();
topBandPlot.HideBubble();
topBandPlot.AssignValueColor(
if bothBandsDown then Color.dark_red
else if bothBandsUp then color.Dark_green
else if topBandStepUp then Color.green
else if topBandStepDown then Color.red
else if bearBias then Color.yellow
else GlobalColor("Gray")
);
bottomBandPlot.HideTitle();
bottomBandPlot.HideBubble();
bottomBandPlot.AssignValueColor(
if bothBandsDown then Color.dark_red
else if bothBandsUp then color.Dark_green
else if bottomBandStepUp then Color.green
else if bottomBandStepDown then Color.red
else if bullBias then Color.yellow
else GlobalColor("Gray")
);
AddLabel(yes, " EMAD RANGE V1000 ", color.WHITE);
AddLabel(ShowColorCodeLabel,
if showHowToLabel then " Bullish: Observe cloud prior to reversal " else " Bullish ", color.dark_green);
AddLabel(ShowColorCodeLabel,
if showHowToLabel then " Bearish: Observe cloud prior to reversal " else " Bearish ", color.dark_red);
AddLabel(ShowColorCodeLabel,
if showHowToLabel then " Vix Alert4: Bounce incoming " else " Vix Alert4 ", color.cyan);
AddLabel(ShowColorCodeLabel,
if showHowToLabel then " Seller Exhaustion: Watch for pullback / reversal when exhaustion ends " else " Seller Exhaustion ", color.light_red);
AddLabel(ShowColorCodeLabel,
if showHowToLabel then " Seller Exhaustion: Watch for pullback / reversal when exhaustion ends " else " Buyer Exhaustion ", color.light_green);
AddLabel(ShowColorCodeLabel,
if showHowToLabel then " Neutral: Direction not confirmed " else " Neutral ", color.gray);
AddLabel(ShowColorCodeLabel,
if showHowToLabel then " Squeeze: (non-directional) potential strong move incoming " else " Squeeze ", color.yellow);
#####################################################
## ##
#####################################################
AddCloud(if showEMACloud and (made1 > masterEMADLinePlot) then made1 else Double.NaN, masterEMADLinePlot, Color.dark_red, Color.gray);
AddCloud(if showEMACloud and (masterEMADLinePlot >= made) then masterEMADLinePlot else Double.NaN, made, Color.dark_green, Color.gray);
#####################################################
## ##
#####################################################
AddChartBubble(showBubbles and crossesUpline and crossesUpline_filter, midBand, "Wait for HL", GlobalColor("Green"), no);
AddChartBubble(showBubbles and crossesDownline and crossesDownline_filter, midBand,"Wait for LH" , GlobalColor("Red"), yes);
#####################################################
## ##
#####################################################
AddVerticalLine(showVerticalline and crossesUpline and crossesUpline_filter, "", GlobalColor("Green"), no);
AddVerticalLine(showVerticalline and crossesDownline and crossesDownline_filter,"" , GlobalColor("Red"), yes);