TraderRich
New member
- Platform
-
- Thinkorswim
@barbaros would it be possible to add the areas of possible support/resistance to the B4 indicator? I've been using both indicators, but using both is a bit redundant and the only reason I use the EMADRange is to see where there are areas of potential S/R
#EMAD_Range Created by Christopher84 01/05/2022
declare lower;
input length8 = 10;
input length9 = 35;
input length10 = 12;
input show_ema_cloud = yes;
input price1 = close;
input coloredCandlesOn = yes;
def showBreakoutSignals = no;
def displace = 0;
def AvgExp8 = ExpAverage(price1[-displace], length8);
def UPD = AvgExp8[1] < AvgExp8;
#AvgExp8.SetStyle(Curve.SHORT_DASH);
#AvgExp8.SetLineWeight(1);
def AvgExp9 = ExpAverage(price1[-displace], length9);
def UPW = AvgExp9[1] < AvgExp9;
#AvgExp9.SetStyle(Curve.SHORT_DASH);
#AvgExp9.SetLineWeight(1);
def Below = AvgExp8 < AvgExp9;
def Spark = UPD + UPW + Below;
def UPEMA = AvgExp8[1] < AvgExp8;
def DOWNEMA = AvgExp8[1] > AvgExp8;
#AvgExp8.AssignValueColor(if UPEMA then Color.LIGHT_GREEN else if DOWNEMA then Color.RED else Color.YELLOW);
def UPEMA2 = AvgExp9[1] < AvgExp9;
def DOWNEMA2 = AvgExp9[1] > AvgExp9;
#AvgExp9.AssignValueColor(if UPEMA2 then Color.LIGHT_GREEN else if DOWNEMA2 then Color.RED else Color.YELLOW);
def EMAD = (price1 - AvgExp8);
def UPEMAD = EMAD >= EMAD[1];
def DOWNEMAD = EMAD < EMAD[1];
#EMAD.AssignValueColor(if UPEMAD then Color.LIGHT_GREEN else if DOWNEMAD then Color.RED else Color.GRAY);
def EMAD2 = (price1 - AvgExp9);
def UPEMAD2 = EMAD2 >= EMAD2[1];
def DOWNEMAD2 = EMAD2 < EMAD2[1];
#EMAD2.AssignValueColor(if UPEMAD2 then Color.White else if DOWNEMAD2 then Color.BLUE else Color.GRAY);
def EMADAvg = (EMAD + EMAD2) / 2;
def UPEMADAvg = EMADAvg >= EMADAvg[1];
def DOWNEMADAvg = EMADAvg < EMADAvg[1];
#EMADAvg.AssignValueColor(if UPEMADAvg then Color.LIGHT_GREEN else if DOWNEMADAvg then Color.RED else Color.GRAY);
plot EMADSmooth = ExpAverage(EMADAvg[-displace], length10);
#########################################
input length = 14;
input averageType = AverageType.WILDERS;
def price = EMADSmooth;
#def bottom = Min(close[1], low);
input agperiod1 = AggregationPeriod.DAY;
def o = (EMADSmooth + EMADSmooth[1]) / 2;
def h = Max(EMADSmooth, EMADSmooth[1]);
def l = Min(EMADSmooth, EMADSmooth[1]);
def c = EMADSmooth;
#def open = open(period = agperiod1);
#def high = high(period = agperiod1);
#def low = low(period = agperiod1);
#def close = close(period = agperiod1);
def bottom = Min(c[1], l);
def tr = TrueRange(h, c, l);
def ptr = tr / (bottom + tr / 2);
def APTR = MovingAverage(averageType, ptr, length);
#APTR.SetDefaultColor(GetColor(8));
def UpperBand = c[1] + (APTR * o);
#UpperBand.SetDefaultColor(Color.GRAY);
def LowerBand = c[1] - (APTR * o);
#LowerBand.SetDefaultColor(Color.GRAY);
plot MidBand = (UpperBand + LowerBand) / 2;
MidBand.AssignValueColor(if (MidBand > EMADSmooth) then Color.RED else if (MidBand < EMADSmooth) then Color.GREEN else Color.GRAY);
EMADSmooth.AssignValueColor(if (MidBand > EMADSmooth) then Color.RED else if (MidBand < EMADSmooth) then Color.GREEN else Color.GRAY);
AddCloud(if show_ema_cloud and (MidBand > EMADSmooth) then MidBand else Double.NaN, EMADSmooth, Color.RED, Color.CURRENT);
AddCloud(if show_ema_cloud and (EMADSmooth >= MidBand) then EMADSmooth else Double.NaN, MidBand, Color.GREEN, Color.CURRENT);
def BulgeLength = 100;
def SqueezeLength = 100;
def BulgeLength2 = 200;
def SqueezeLength2 = 200;
plot ZeroLine = 0;
ZeroLine.AssignValueColor(if (EMADSmooth > ZeroLine) then Color.GREEN else if (EMADSmooth < ZeroLine) then Color.RED else Color.YELLOW);
def EMADSUp = EMADSmooth > ZeroLine;
def EMADSDown = EMADSmooth < ZeroLine;
AssignPriceColor (if coloredCandlesOn and (MidBand > EMADSmooth) then Color.RED else if coloredCandlesOn and (MidBand < EMADSmooth) then Color.GREEN else Color.GRAY);
plot Bulge = Highest(MidBand, BulgeLength);
Bulge.SetDefaultColor(Color.WHITE);
plot Squeeze = Lowest(MidBand, SqueezeLength);
Squeeze.SetDefaultColor(Color.WHITE);
#EMAD_Range Created by Christopher84 01/05/2022
declare lower;
input length8 = 10;
input length9 = 35;
input length10 = 12;
input show_ema_cloud = yes;
input price1 = close;
input coloredCandlesOn = yes;
def showBreakoutSignals = no;
def displace = 0;
def AvgExp8 = ExpAverage(price1[-displace], length8);
def UPD = AvgExp8[1] < AvgExp8;
#AvgExp8.SetStyle(Curve.SHORT_DASH);
#AvgExp8.SetLineWeight(1);
def AvgExp9 = ExpAverage(price1[-displace], length9);
def UPW = AvgExp9[1] < AvgExp9;
#AvgExp9.SetStyle(Curve.SHORT_DASH);
#AvgExp9.SetLineWeight(1);
def Below = AvgExp8 < AvgExp9;
def Spark = UPD + UPW + Below;
def UPEMA = AvgExp8[1] < AvgExp8;
def DOWNEMA = AvgExp8[1] > AvgExp8;
#AvgExp8.AssignValueColor(if UPEMA then Color.LIGHT_GREEN else if DOWNEMA then Color.RED else Color.YELLOW);
def UPEMA2 = AvgExp9[1] < AvgExp9;
def DOWNEMA2 = AvgExp9[1] > AvgExp9;
#AvgExp9.AssignValueColor(if UPEMA2 then Color.LIGHT_GREEN else if DOWNEMA2 then Color.RED else Color.YELLOW);
def EMAD = (price1 - AvgExp8);
def UPEMAD = EMAD >= EMAD[1];
def DOWNEMAD = EMAD < EMAD[1];
#EMAD.AssignValueColor(if UPEMAD then Color.LIGHT_GREEN else if DOWNEMAD then Color.RED else Color.GRAY);
def EMAD2 = (price1 - AvgExp9);
def UPEMAD2 = EMAD2 >= EMAD2[1];
def DOWNEMAD2 = EMAD2 < EMAD2[1];
#EMAD2.AssignValueColor(if UPEMAD2 then Color.White else if DOWNEMAD2 then Color.BLUE else Color.GRAY);
def EMADAvg = (EMAD + EMAD2) / 2;
def UPEMADAvg = EMADAvg >= EMADAvg[1];
def DOWNEMADAvg = EMADAvg < EMADAvg[1];
#EMADAvg.AssignValueColor(if UPEMADAvg then Color.LIGHT_GREEN else if DOWNEMADAvg then Color.RED else Color.GRAY);
plot EMADSmooth = ExpAverage(EMADAvg[-displace], length10);
#########################################
input length = 14;
input averageType = AverageType.WILDERS;
def price = EMADSmooth;
#def bottom = Min(close[1], low);
input agperiod1 = AggregationPeriod.DAY;
def o = (EMADSmooth + EMADSmooth[1]) / 2;
def h = Max(EMADSmooth, EMADSmooth[1]);
def l = Min(EMADSmooth, EMADSmooth[1]);
def c = EMADSmooth;
#def open = open(period = agperiod1);
#def high = high(period = agperiod1);
#def low = low(period = agperiod1);
#def close = close(period = agperiod1);
def bottom = Min(c[1], l);
def tr = TrueRange(h, c, l);
def ptr = tr / (bottom + tr / 2);
def APTR = MovingAverage(averageType, ptr, length);
#APTR.SetDefaultColor(GetColor(8));
def UpperBand = c[1] + (APTR * o);
#UpperBand.SetDefaultColor(Color.GRAY);
def LowerBand = c[1] - (APTR * o);
#LowerBand.SetDefaultColor(Color.GRAY);
plot MidBand = (UpperBand + LowerBand) / 2;
MidBand.AssignValueColor(if (MidBand > EMADSmooth) then Color.RED else if (MidBand < EMADSmooth) then Color.GREEN else Color.GRAY);
EMADSmooth.AssignValueColor(if (MidBand > EMADSmooth) then Color.RED else if (MidBand < EMADSmooth) then Color.GREEN else Color.GRAY);
AddCloud(if show_ema_cloud and (MidBand > EMADSmooth) then MidBand else Double.NaN, EMADSmooth, Color.RED, Color.CURRENT);
AddCloud(if show_ema_cloud and (EMADSmooth >= MidBand) then EMADSmooth else Double.NaN, MidBand, Color.GREEN, Color.CURRENT);
def BulgeLength = 100;
def SqueezeLength = 100;
def BulgeLength2 = 200;
def SqueezeLength2 = 200;
plot ZeroLine = 0;
ZeroLine.AssignValueColor(if (EMADSmooth > ZeroLine) then Color.GREEN else if (EMADSmooth < ZeroLine) then Color.RED else Color.YELLOW);
def EMADSUp = EMADSmooth > ZeroLine;
def EMADSDown = EMADSmooth < ZeroLine;
AssignPriceColor (if coloredCandlesOn and (MidBand > EMADSmooth) then Color.RED else if coloredCandlesOn and (MidBand < EMADSmooth) then Color.GREEN else Color.GRAY);
plot Bulge = Highest(MidBand, BulgeLength);
Bulge.SetDefaultColor(Color.WHITE);
plot Squeeze = Lowest(MidBand, SqueezeLength);
Squeeze.SetDefaultColor(Color.WHITE);