@Christopher84 Thanks for splitting the indicators... Greatly appreciated...
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
what's the amm22 studies for ?!
That is Sprahty setup (not mine). I am sorry but I am not currently using AMM and can't answer the question.what's the amm22 studies for ?!
Wow, looks like you put in a lot of work! Here's v8 on the top and v9 on the bottom. The labels definitely describe price action better with v9. And the candle colors between 11am - 12pm stay aligned with the downtrend better with v9.Be sure to check them out on the first page of this thread!
This was just a version of Advanced Market Moves I was using. I'm sure you are aware of it in the premium indicator section. If there's anything I can help with, just let me knowwhat's the amm22 studies for ?!
Thank you for sharing this! It is a perfect illustration of how the changes are improving the code. Thank you so much for your feedback Trader Raider! It really helps me keep pushing to improve this indicator.Wow, looks like you put in a lot of work! Here's v8 on the top and v9 on the bottom. The labels definitely describe price action better with v9. And the candle colors between 11am - 12pm stay aligned with the downtrend better with v9.
I really appreciate this indicator. THANK YOU!
Thanks to your post I was able to see the cloud shadow in the background. Just revised and reposted. Thanks again!Wow, looks like you put in a lot of work! Here's v8 on the top and v9 on the bottom. The labels definitely describe price action better with v9. And the candle colors between 11am - 12pm stay aligned with the downtrend better with v9.
I really appreciate this indicator. THANK YOU!
I was able to see the cloud shadow in the background. Just revised and reposted.
Thank you to @Christopher84 as well! Your explanation in #130 in this thread was amazing and was truly very helpful! I've been studying the CC indicator since you released it and it's amazing seeing the evolution.THANK YOU! It's more clean and crisp now. I really appreciate how this indicator provides helpful info without cluttering the display. The cleaner my chart, the better I trade
@vhawkx, looks like the B4 is going premium. Probably best if you direct questions to them on their thread or discord. I no longer buy indicators so it'll likely come off my charts soon.I actually wanted to ask if I could pick your brain on how you use this indicator along with the B4 lower one?
Hey Trader Raider,@vhawkx, looks like the B4 is going premium. Probably best if you direct questions to them on their thread or discord. I no longer buy indicators so it'll likely come off my charts soon.
Best wishes and happy trading.
TksThis was just a version of Advanced Market Moves I was using. I'm sure you are aware of it in the premium indicator section. If there's anything I can help with, just let me know
Really helpful scripts. What is the MA cloud lower study? Is it available for sharing?Hey Trader Raider,
I had posted this in a different thread regarding identifying consolidation zones and then saw a potential signal of interest that appeared after the consolidation zone. So I set up a scan for it, and I am getting some interesting results and thought I would share. The averages on the chart are the 10 period ema on the day chart and the 10 period ema for the week shown on the day chart. When the day ema is below the week ema (red cloud shown between averages) and both averages are upward sloping (dashed lines are green when sloping upward) it seems to be signaling for nice breakouts. (see image below) Here's a share link for the scan https://tos.mx/SaCsQmG
I have both an upper and lower study for the MA Clouds. The lower study was created because I didn't always want the upper study on my main chart with my other indicators. It essentially replicates the chart for CC Candles indicator with price shown as a line instead of candles. Its excellent for seeing strong support and resistance levels. Here's the lower study. Enjoy!Really helpful scripts. What is the MA cloud lower study? Is it available for sharing?
#MTF Moving Average Lower Created by Christopher84 05/01/2021
declare lower;
#Keltner Channel
def displace = 0;
def factorK = 2.0;
def lengthK = 20;
def price = close;
input averageType = AverageType.SIMPLE;
def trueRangeAverageType = AverageType.SIMPLE;
def BulgeLengthK = 150;
def SqueezeLengthK = 150;
def BulgeLengthK2 = 40;
def SqueezeLengthK2 = 40;
def BulgeLengthPrice = 75;
def SqueezeLengthPrice = 75;
def BulgeLengthPrice2 = 20;
def SqueezeLengthPrice2 = 20;
def BulgeLengthCC = 40;
def SqueezeLengthCC = 40;
def BulgeLengthCC2 = 8;
def SqueezeLengthCC2 = 8;
def shift = factorK * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), lengthK);
def averageK = MovingAverage(averageType, price, lengthK);
def AvgK = averageK[-displace];
def Upper_BandK = averageK[-displace] + shift[-displace];
def Lower_BandK = averageK[-displace] - shift[-displace];
def conditionK1 = price >= Upper_BandK;
def conditionK2 = (Upper_BandK[1] < Upper_BandK) and (Lower_BandK[1] < Lower_BandK);
def conditionK3D = price < Lower_BandK;
def conditionK4D = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK);
def conditionK2L = (Upper_BandK[2] < Upper_BandK[1]) and (Lower_BandK[2] < Lower_BandK[1]);
def conditionK3L = (Upper_BandK[3] < Upper_BandK[2]) and (Lower_BandK[3] < Lower_BandK[2]);
def conditionK3 = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK);
def BandwidthK = (Upper_BandK - Lower_BandK) / AvgK * 100;
def condition_BWKUP = BandwidthK[1] < BandwidthK;
def condition_BWKDOWN = BandwidthK[1] > BandwidthK;
def BulgeK = Highest(BandwidthK, BulgeLengthK);
def SqueezeK = Lowest(BandwidthK, SqueezeLengthK);
def BulgeK2 = Highest(BandwidthK, BulgeLengthK2);
def SqueezeK2 = Lowest(BandwidthK, SqueezeLengthK2);
plot IntermResistance = Highest(price, BulgeLengthPrice);
IntermResistance.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);
plot IntermSupport = Lowest(price, SqueezeLengthPrice);
IntermSupport.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);
#MACD with Price
def fastLength = 12;
def slowLength = 26;
def MACDLength = 9;
input MACD_AverageType = {SMA, default EMA};
def MACDLevel = 0.0;
def fastEMA = ExpAverage(price, fastLength);
def slowEMA = ExpAverage(price, slowLength);
def Value;
def Avg;
switch (MACD_AverageType) {
case SMA:
Value = Average(price, fastLength) - Average(price, slowLength);
Avg = Average(Value, MACDLength);
case EMA:
Value = fastEMA - slowEMA;
Avg = ExpAverage(Value, MACDLength);
}
def Diff = Value - Avg;
def Level = MACDLevel;
def condition1 = Value[1] <= Value;
def condition1D = Value[1] > Value;
#RSI
def RSI_length = 14;
def RSI_AverageType = AverageType.WILDERS;
def RSI_OB = 70;
def RSI_OS = 30;
def NetChgAvg = MovingAverage(RSI_AverageType, price - price[1], RSI_length);
def TotChgAvg = MovingAverage(RSI_AverageType, AbsValue(price - price[1]), RSI_length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def condition2 = (RSI[3] < RSI) is true or (RSI >= 80) is true;
def condition2D = (RSI[3] > RSI) is true or (RSI < 20) is true;
def conditionOB1 = RSI > RSI_OB;
def conditionOS1 = RSI < RSI_OS;
#MFI
def MFI_Length = 14;
def MFIover_Sold = 20;
def MFIover_Bought = 80;
def movingAvgLength = 1;
def MoneyFlowIndex = Average(MoneyFlow(high, close, low, volume, MFI_Length), movingAvgLength);
def MFIOverBought = MFIover_Bought;
def MFIOverSold = MFIover_Sold;
def condition3 = (MoneyFlowIndex[2] < MoneyFlowIndex) is true or (MoneyFlowIndex > 85) is true;
def condition3D = (MoneyFlowIndex[2] > MoneyFlowIndex) is true or (MoneyFlowIndex < 20) is true;
def conditionOB2 = MoneyFlowIndex > MFIover_Bought;
def conditionOS2 = MoneyFlowIndex < MFIover_Sold;
#Forecast
def na = Double.NaN;
def MidLine = 50;
def Momentum = MarketForecast().Momentum;
def NearT = MarketForecast().NearTerm;
def Intermed = MarketForecast().Intermediate;
def FOB = 80;
def FOS = 20;
def upperLine = 110;
def condition4 = (Intermed[1] <= Intermed) or (NearT >= MidLine);
def condition4D = (Intermed[1] > Intermed) or (NearT < MidLine);
def conditionOB3 = Intermed > FOB;
def conditionOS3 = Intermed < FOS;
def conditionOB4 = NearT > FOB;
def conditionOS4 = NearT < FOS;
#Pivot Signals
def n = 20;
def ticks = 2.0;
def bnOK = BarNumber() > n;
def isHigher = fold i = 1 to n + 1 with p = 1 while p do high > GetValue(high, -i);
def HH = if bnOK and isHigher and high == Highest(high, n) then high else Double.NaN;
def isLower = fold j = 1 to n + 1 with q = 1 while q do low < GetValue(low, -j);
def LL = if bnOK and isLower and low == Lowest(low, n) then low else Double.NaN;
def PivH = if HH > 0 then HH else Double.NaN;
def PivL = if LL > 0 then LL else Double.NaN;
def UpPivotLow = !IsNaN(PivL);
def DownPivotHigh = !IsNaN(PivH);
def condition5 = !IsNaN(PivL);
def condition5D = !IsNaN(PivH);
#EMA_1
def EMA_length = 12;
def AvgExp = ExpAverage(price[-displace], EMA_length);
def condition6 = (price >= AvgExp) and (AvgExp[2] <= AvgExp);
def condition6D = (price < AvgExp) and (AvgExp[2] > AvgExp);
#EMA_2
def EMA_2length = 20;
def displace2 = 0;
def AvgExp2 = ExpAverage(price[-displace2], EMA_2length);
def condition7 = (price >= AvgExp2) and (AvgExp[2] <= AvgExp);
def condition7D = (price < AvgExp2) and (AvgExp[2] > AvgExp);
#DMI Oscillator
def DMI_length = 5;#Typically set to 10
input DMI_averageType = AverageType.WILDERS;
def diPlus = DMI(DMI_length, DMI_averageType)."DI+";
def diMinus = DMI(DMI_length, DMI_averageType)."DI-";
def Osc = diPlus - diMinus;
def Hist = Osc;
def ZeroLine = 0;
def condition8 = Osc >= ZeroLine;
def condition8D = Osc < ZeroLine;
#Trend_Periods
def TP_fastLength = 3;#Typically 7
def TP_slowLength = 4;#Typically 15
def Periods = Sign(ExpAverage(close, TP_fastLength) - ExpAverage(close, TP_slowLength));
def condition9 = Periods > 0;
def condition9D = Periods < 0;
#Polarized Fractal Efficiency
def PFE_length = 5;#Typically 10
def smoothingLength = 2.5;#Typically 5
def PFE_diff = close - close[PFE_length - 1];
def val = 100 * Sqrt(Sqr(PFE_diff) + Sqr(PFE_length)) / Sum(Sqrt(1 + Sqr(close - close[1])), PFE_length - 1);
def PFE = ExpAverage(if PFE_diff > 0 then val else -val, smoothingLength);
def UpperLevel = 50;
def LowerLevel = -50;
def condition10 = PFE > 0;
def condition10D = PFE < 0;
def conditionOB5 = PFE > UpperLevel;
def conditionOS5 = PFE < LowerLevel;
#Bollinger Bands PercentB
input BBPB_averageType = AverageType.SIMPLE;
def BBPB_length = 20;
def Num_Dev_Dn = -2.0;
def Num_Dev_up = 2.0;
def BBPB_OB = 100;
def BBPB_OS = 0;
def upperBand = BollingerBands(price, displace, BBPB_length, Num_Dev_Dn, Num_Dev_up, BBPB_averageType).UpperBand;
def lowerBand = BollingerBands(price, displace, BBPB_length, Num_Dev_Dn, Num_Dev_up, BBPB_averageType).LowerBand;
def PercentB = (price - lowerBand) / (upperBand - lowerBand) * 100;
def HalfLine = 50;
def UnitLine = 100;
def condition11 = PercentB > HalfLine;
def condition11D = PercentB < HalfLine;
def conditionOB6 = PercentB > BBPB_OB;
def conditionOS6 = PercentB < BBPB_OS;
#STARC Bands
def ATR_length = 15;
def SMA_lengthS = 6;
def multiplier_factor = 1.25;
def valS = Average(price, SMA_lengthS);
def average_true_range = Average(TrueRange(high, close, low), length = ATR_length);
def Upper_BandS = valS[-displace] + multiplier_factor * average_true_range[-displace];
def Middle_BandS = valS[-displace];
def Lower_BandS = valS[-displace] - multiplier_factor * average_true_range[-displace];
def condition12 = (Upper_BandS[1] <= Upper_BandS) and (Lower_BandS[1] <= Lower_BandS);
def condition12D = (Upper_BandS[1] > Upper_BandS) and (Lower_BandS[1] > Lower_BandS);
#Klinger Histogram
def Klinger_Length = 13;
def KVOsc = KlingerOscillator(Klinger_Length).KVOsc;
def KVOH = KVOsc - Average(KVOsc, Klinger_Length);
def condition13 = (KVOH > 0) and (KVOsc[1] <= KVOsc);
def condition13D = (KVOH < 0) and (KVOsc[1] > KVOsc);
#Projection Oscillator
def ProjectionOsc_length = 30;#Typically 10
def MaxBound = HighestWeighted(high, ProjectionOsc_length, LinearRegressionSlope(price = high, length = ProjectionOsc_length));
def MinBound = LowestWeighted(low, ProjectionOsc_length, LinearRegressionSlope(price = low, length = ProjectionOsc_length));
def ProjectionOsc_diff = MaxBound - MinBound;
def PROSC = if ProjectionOsc_diff != 0 then 100 * (close - MinBound) / ProjectionOsc_diff else 0;
def PROSC_OB = 80;
def PROSC_OS = 20;
def condition14 = PROSC > 50;
def condition14D = PROSC < 50;
def conditionOB7 = PROSC > PROSC_OB;
def conditionOS7 = PROSC < PROSC_OS;
#Trend Confirmation Calculator
#Confirmation_Factor range 1-15.
def coloredCandlesOn = no;
def Confirmation_Factor = 7;
#Use for testing conditions individually. Remove # from line below and change Confirmation_Factor to 1.
#def Agreement_Level = condition1;
def Agreement_LevelOB = 12;
def Agreement_LevelOS = 3;
def Agreement_Level = condition1 + condition2 + condition3 + condition4 + condition5 + condition6 + condition7 + condition8 + condition9 + condition10 + condition11 + condition12 + condition13 + condition14 + conditionK1 + conditionK2;
def Agreement_LevelD = (condition1D + condition2D + condition3D + condition4D + condition5D + condition6D + condition7D + condition8D + condition9D + condition10D + condition11D + condition12D + condition13D + condition14D + conditionK3D + conditionK4D);
def Consensus_Level = Agreement_Level - Agreement_LevelD;
def conditionChannel1 = Upper_BandK > price;
def conditionChannel2 = Lower_BandK < price;
def UP = Consensus_Level >= 0;
def DOWN = Consensus_Level < 0;
#EMA's
input length = 10;
input agperiod1 = {"1 min", "2 min", "5 min", "10 min", "15 min", "30 min", "60 min", "4 hours", default "Day", "Week"};
input agperiod2 = {"1 min", "2 min", "5 min", "10 min", "15 min", "30 min", "60 min", "4 hours", "Day", default "Week"};
plot avg1 = ExpAverage(close(period = agperiod1), length);
def height = avg - avg[length];
avg1.SetStyle(Curve.SHORT_DASH);
avg1.SetLineWeight(1);
def UP1 = avg1[1] < avg1;
def DOWN1 = avg1[1] > avg1;
Avg1.AssignValueColor(if UP1 then Color.LIGHT_GREEN else if DOWN1 then Color.RED else Color.YELLOW);
plot avg2 = ExpAverage(close(period = agperiod2), length);
def height2 = avg2 - avg2[length];
avg2.SetStyle(Curve.SHORT_DASH);
avg2.SetLineWeight(1);
def UP2 = avg2[1] < avg2;
def DOWN2 = avg2[1] > avg2;
Avg2.AssignValueColor(if UP2 then Color.LIGHT_GREEN else if DOWN2 then Color.RED else Color.YELLOW);
plot price1 = close;
def UP3 = price1[1] < price1;
def DOWN3 = price1[1] > price1;
price1.AssignValueColor(
if Consensus_Level > Consensus_Level[1] and Consensus_Level >= 0 then Color.LIGHT_GREEN
else if Consensus_Level < Consensus_Level[1] and Consensus_Level > 0 then Color.LIGHT_GREEN
else if Consensus_Level < Consensus_Level[1] and Consensus_Level < 0 then Color.RED else
if Consensus_Level > Consensus_Level[1] and Consensus_Level < 0 then Color.RED
else Color.GRAY);
AddCloud(avg2, avg1, Color.LIGHT_RED, Color.CURRENT);
AddCloud(avg1, avg2, Color.LIGHT_GREEN, Color.CURRENT);
The lower study is great! Tks for sharing! Happy trading at a chaotic timeI have both an upper and lower study for the MA Clouds. The lower study was created because I didn't always want the upper study on my main chart with my other indicators. It essentially replicates the chart for CC Candles indicator with price shown as a line instead of candles. Its excellent for seeing strong support and resistance levels. Here's the lower study. Enjoy!
Code:#MTF Moving Average Lower Created by Christopher84 05/01/2021 declare lower; #Keltner Channel def displace = 0; input factorK = 2.0; input lengthK = 20; def price = close; input averageType = AverageType.SIMPLE; def trueRangeAverageType = AverageType.SIMPLE; def BulgeLengthK = 150; def SqueezeLengthK = 150; def BulgeLengthK2 = 40; def SqueezeLengthK2 = 40; input BulgeLengthPrice = 75; input SqueezeLengthPrice = 75; input BulgeLengthPrice2 = 20; input SqueezeLengthPrice2 = 20; input BulgeLengthCC = 40; input SqueezeLengthCC = 40; input BulgeLengthCC2 = 8; input SqueezeLengthCC2 = 8; def shift = factorK * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), lengthK); def averageK = MovingAverage(averageType, price, lengthK); def AvgK = averageK[-displace]; def Upper_BandK = averageK[-displace] + shift[-displace]; def Lower_BandK = averageK[-displace] - shift[-displace]; def conditionK1 = price >= Upper_BandK; def conditionK2 = (Upper_BandK[1] < Upper_BandK) and (Lower_BandK[1] < Lower_BandK); def conditionK3D = price < Lower_BandK; def conditionK4D = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK); def conditionK2L = (Upper_BandK[2] < Upper_BandK[1]) and (Lower_BandK[2] < Lower_BandK[1]); def conditionK3L = (Upper_BandK[3] < Upper_BandK[2]) and (Lower_BandK[3] < Lower_BandK[2]); def conditionK3 = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK); def BandwidthK = (Upper_BandK - Lower_BandK) / AvgK * 100; def condition_BWKUP = BandwidthK[1] < BandwidthK; def condition_BWKDOWN = BandwidthK[1] > BandwidthK; def BulgeK = Highest(BandwidthK, BulgeLengthK); def SqueezeK = Lowest(BandwidthK, SqueezeLengthK); def BulgeK2 = Highest(BandwidthK, BulgeLengthK2); def SqueezeK2 = Lowest(BandwidthK, SqueezeLengthK2); plot BulgePrice = Highest(price, BulgeLengthPrice); BulgePrice.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); plot SqueezePrice = Lowest(price, SqueezeLengthPrice); SqueezePrice.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); #plot BulgePrice2 = Highest(price, BulgeLengthPrice2); #BulgePrice2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); #BulgePrice2.SetStyle(Curve.SHORT_DASH); #plot SqueezePrice2 = Lowest(price, SqueezeLengthPrice2); #SqueezePrice2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); #SqueezePrice2.SetStyle(Curve.SHORT_DASH); #MACD with Price def fastLength = 12; def slowLength = 26; def MACDLength = 9; input MACD_AverageType = {SMA, default EMA}; def MACDLevel = 0.0; def fastEMA = ExpAverage(price, fastLength); def slowEMA = ExpAverage(price, slowLength); def Value; def Avg; switch (MACD_AverageType) { case SMA: Value = Average(price, fastLength) - Average(price, slowLength); Avg = Average(Value, MACDLength); case EMA: Value = fastEMA - slowEMA; Avg = ExpAverage(Value, MACDLength); } def Diff = Value - Avg; def Level = MACDLevel; def condition1 = Value[1] <= Value; def condition1D = Value[1] > Value; #RSI def RSI_length = 14; def RSI_AverageType = AverageType.WILDERS; def RSI_OB = 70; def RSI_OS = 30; def NetChgAvg = MovingAverage(RSI_AverageType, price - price[1], RSI_length); def TotChgAvg = MovingAverage(RSI_AverageType, AbsValue(price - price[1]), RSI_length); def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0; def RSI = 50 * (ChgRatio + 1); def condition2 = (RSI[3] < RSI) is true or (RSI >= 80) is true; def condition2D = (RSI[3] > RSI) is true or (RSI < 20) is true; def conditionOB1 = RSI > RSI_OB; def conditionOS1 = RSI < RSI_OS; #MFI def MFI_Length = 14; def MFIover_Sold = 20; def MFIover_Bought = 80; def movingAvgLength = 1; def MoneyFlowIndex = Average(MoneyFlow(high, close, low, volume, MFI_Length), movingAvgLength); def MFIOverBought = MFIover_Bought; def MFIOverSold = MFIover_Sold; def condition3 = (MoneyFlowIndex[2] < MoneyFlowIndex) is true or (MoneyFlowIndex > 85) is true; def condition3D = (MoneyFlowIndex[2] > MoneyFlowIndex) is true or (MoneyFlowIndex < 20) is true; def conditionOB2 = MoneyFlowIndex > MFIover_Bought; def conditionOS2 = MoneyFlowIndex < MFIover_Sold; #Forecast def na = Double.NaN; def MidLine = 50; def Momentum = MarketForecast().Momentum; def NearT = MarketForecast().NearTerm; def Intermed = MarketForecast().Intermediate; def FOB = 80; def FOS = 20; def upperLine = 110; def condition4 = (Intermed[1] <= Intermed) and (NearT >= MidLine); def condition4D = (Intermed[1] > Intermed) and (NearT < MidLine); def conditionOB3 = Intermed > FOB; def conditionOS3 = Intermed < FOS; def conditionOB4 = NearT > FOB; def conditionOS4 = NearT < FOS; #Pivot Signals def n = 20; def ticks = 2.0; def bnOK = BarNumber() > n; def isHigher = fold i = 1 to n + 1 with p = 1 while p do high > GetValue(high, -i); def HH = if bnOK and isHigher and high == Highest(high, n) then high else Double.NaN; def isLower = fold j = 1 to n + 1 with q = 1 while q do low < GetValue(low, -j); def LL = if bnOK and isLower and low == Lowest(low, n) then low else Double.NaN; def PivH = if HH > 0 then HH else Double.NaN; def PivL = if LL > 0 then LL else Double.NaN; def UpPivotLow = !IsNaN(PivL); #UpPivotLow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); #UpPivotLow.SetLineWeight(4); #UpPivotLow.SetDefaultColor(Color.GREEN); def DownPivotHigh = !IsNaN(PivH); #DownPivotHigh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); #DownPivotHigh.SetLineWeight(4); #DownPivotHigh.SetDefaultColor(Color.RED); def condition5 = !IsNaN(PivL); def condition5D = !IsNaN(PivH); #EMA_1 def EMA_length = 12; def AvgExp = ExpAverage(price[-displace], EMA_length); def condition6 = (price >= AvgExp) and (AvgExp[2] <= AvgExp); def condition6D = (price < AvgExp) and (AvgExp[2] > AvgExp); #EMA_2 def EMA_2length = 20; def displace2 = 0; def AvgExp2 = ExpAverage(price[-displace2], EMA_2length); def condition7 = (price >= AvgExp2) and (AvgExp[2] <= AvgExp); def condition7D = (price < AvgExp2) and (AvgExp[2] > AvgExp); #DMI Oscillator def DMI_length = 5;#Typically set to 10 input DMI_averageType = AverageType.WILDERS; def diPlus = DMI(DMI_length, DMI_averageType)."DI+"; def diMinus = DMI(DMI_length, DMI_averageType)."DI-"; def Osc = diPlus - diMinus; def Hist = Osc; def ZeroLine = 0; def condition8 = Osc >= ZeroLine; def condition8D = Osc < ZeroLine; #Trend_Periods def TP_fastLength = 3;#Typically 7 def TP_slowLength = 4;#Typically 15 def Periods = Sign(ExpAverage(close, TP_fastLength) - ExpAverage(close, TP_slowLength)); def condition9 = Periods > 0; def condition9D = Periods < 0; #Polarized Fractal Efficiency def PFE_length = 5;#Typically 10 def smoothingLength = 2.5;#Typically 5 def PFE_diff = close - close[PFE_length - 1]; def val = 100 * Sqrt(Sqr(PFE_diff) + Sqr(PFE_length)) / Sum(Sqrt(1 + Sqr(close - close[1])), PFE_length - 1); def PFE = ExpAverage(if PFE_diff > 0 then val else -val, smoothingLength); def UpperLevel = 50; def LowerLevel = -50; def condition10 = PFE > 0; def condition10D = PFE < 0; def conditionOB5 = PFE > UpperLevel; def conditionOS5 = PFE < LowerLevel; #Bollinger Bands PercentB input BBPB_averageType = AverageType.SIMPLE; def BBPB_length = 20;#Typically 20 def Num_Dev_Dn = -2.0; def Num_Dev_up = 2.0; def BBPB_OB = 100; def BBPB_OS = 0; def upperBand = BollingerBands(price, displace, BBPB_length, Num_Dev_Dn, Num_Dev_up, BBPB_averageType).UpperBand; def lowerBand = BollingerBands(price, displace, BBPB_length, Num_Dev_Dn, Num_Dev_up, BBPB_averageType).LowerBand; def PercentB = (price - lowerBand) / (upperBand - lowerBand) * 100; def HalfLine = 50; def UnitLine = 100; def condition11 = PercentB > HalfLine; def condition11D = PercentB < HalfLine; def conditionOB6 = PercentB > BBPB_OB; def conditionOS6 = PercentB < BBPB_OS; #STARC Bands def ATR_length = 15; def SMA_lengthS = 6; def multiplier_factor = 1.5; def valS = Average(price, SMA_lengthS); def average_true_range = Average(TrueRange(high, close, low), length = ATR_length); def Upper_BandS = valS[-displace] + multiplier_factor * average_true_range[-displace]; def Middle_BandS = valS[-displace]; def Lower_BandS = valS[-displace] - multiplier_factor * average_true_range[-displace]; def condition12 = (Upper_BandS[1] <= Upper_BandS) and (Lower_BandS[1] <= Lower_BandS); def condition12D = (Upper_BandS[1] > Upper_BandS) and (Lower_BandS[1] > Lower_BandS); #Klinger Histogram def Klinger_Length = 13; def KVOsc = KlingerOscillator(Klinger_Length).KVOsc; def KVOH = KVOsc - Average(KVOsc, Klinger_Length); def condition13 = (KVOH > 0) and (KVOsc[1] <= KVOsc); def condition13D = (KVOH < 0) and (KVOsc[1] > KVOsc); #Projection Oscillator def ProjectionOsc_length = 30;#Typically 10 def MaxBound = HighestWeighted(high, ProjectionOsc_length, LinearRegressionSlope(price = high, length = ProjectionOsc_length)); def MinBound = LowestWeighted(low, ProjectionOsc_length, LinearRegressionSlope(price = low, length = ProjectionOsc_length)); def ProjectionOsc_diff = MaxBound - MinBound; def PROSC = if ProjectionOsc_diff != 0 then 100 * (close - MinBound) / ProjectionOsc_diff else 0; def PROSC_OB = 80; def PROSC_OS = 20; def condition14 = PROSC > 50; def condition14D = PROSC < 50; def conditionOB7 = PROSC > PROSC_OB; def conditionOS7 = PROSC < PROSC_OS; #Trend Confirmation Calculator #Confirmation_Factor range 1-15. input coloredCandlesOn = no; input Confirmation_Factor = 3; #Use for testing conditions individually. Remove # from line below and change Confirmation_Factor to 1. #def Agreement_Level = condition1; def Agreement_LevelOB = 12; def Agreement_LevelOS = 3; def Agreement_Level = condition1 + condition2 + condition3 + condition4 + condition5 + condition6 + condition7 + condition8 + condition9 + condition10 + condition11 + condition12 + condition13 + condition14 + conditionK1 + conditionK2; def Agreement_LevelD = (condition1D + condition2D + condition3D + condition4D + condition5D + condition6D + condition7D + condition8D + condition9D + condition10D + condition11D + condition12D + condition13D + condition14D + conditionK3D + conditionK4D); def Consensus_Level = Agreement_Level - Agreement_LevelD; def conditionChannel1 = Upper_BandK > price; def conditionChannel2 = Lower_BandK < price; def UP = Consensus_Level >= 0; def DOWN = Consensus_Level < 0; #EMA's input length = 10; input agperiod1 = {"1 min", "2 min", "5 min", "10 min", "15 min", "30 min", "60 min", "4 hours", default "Day", "Week"}; input agperiod2 = {"1 min", "2 min", "5 min", "10 min", "15 min", "30 min", "60 min", "4 hours", "Day", default "Week"}; plot avg1 = ExpAverage(close(period = agperiod1), length); def height = avg - avg[length]; avg1.SetStyle(Curve.SHORT_DASH); avg1.SetLineWeight(1); def UP1 = avg1[1] < avg1; def DOWN1 = avg1[1] > avg1; Avg1.AssignValueColor(if UP1 then Color.LIGHT_GREEN else if DOWN1 then Color.RED else Color.YELLOW); plot avg2 = ExpAverage(close(period = agperiod2), length); def height2 = avg2 - avg2[length]; avg2.SetStyle(Curve.SHORT_DASH); avg2.SetLineWeight(1); #avg.SetDefaultColor(Color.Gray); def UP2 = avg2[1] < avg2; def DOWN2 = avg2[1] > avg2; Avg2.AssignValueColor(if UP2 then Color.LIGHT_GREEN else if DOWN2 then Color.RED else Color.YELLOW); plot price1 = close; def UP3 = price1[1] < price1; def DOWN3 = price1[1] > price1; #price1.AssignValueColor(if UP3 then Color.LIGHT_GREEN else if DOWN3 then Color.RED else Color.GRAY); price1.AssignValueColor( if Consensus_Level > Consensus_Level[1] and Consensus_Level >= 0 then Color.LIGHT_GREEN else if Consensus_Level < Consensus_Level[1] and Consensus_Level > 0 then Color.LIGHT_GREEN else if Consensus_Level < Consensus_Level[1] and Consensus_Level < 0 then Color.RED else if Consensus_Level > Consensus_Level[1] and Consensus_Level < 0 then Color.RED else Color.GRAY); AddCloud(avg2, avg1, Color.LIGHT_RED, Color.CURRENT); AddCloud(avg1, avg2, Color.LIGHT_GREEN, Color.CURRENT);
I have both an upper and lower study for the MA Clouds. The lower study was created because I didn't always want the upper study on my main chart with my other indicators. It essentially replicates the chart for CC Candles indicator with price shown as a line instead of candles. Its excellent for seeing strong support and resistance levels. Here's the lower study. Enjoy!
Code:#MTF Moving Average Lower Created by Christopher84 05/01/2021 declare lower; #Keltner Channel def displace = 0; input factorK = 2.0; input lengthK = 20; def price = close; input averageType = AverageType.SIMPLE; def trueRangeAverageType = AverageType.SIMPLE; def BulgeLengthK = 150; def SqueezeLengthK = 150; def BulgeLengthK2 = 40; def SqueezeLengthK2 = 40; input BulgeLengthPrice = 75; input SqueezeLengthPrice = 75; input BulgeLengthPrice2 = 20; input SqueezeLengthPrice2 = 20; input BulgeLengthCC = 40; input SqueezeLengthCC = 40; input BulgeLengthCC2 = 8; input SqueezeLengthCC2 = 8; def shift = factorK * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), lengthK); def averageK = MovingAverage(averageType, price, lengthK); def AvgK = averageK[-displace]; def Upper_BandK = averageK[-displace] + shift[-displace]; def Lower_BandK = averageK[-displace] - shift[-displace]; def conditionK1 = price >= Upper_BandK; def conditionK2 = (Upper_BandK[1] < Upper_BandK) and (Lower_BandK[1] < Lower_BandK); def conditionK3D = price < Lower_BandK; def conditionK4D = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK); def conditionK2L = (Upper_BandK[2] < Upper_BandK[1]) and (Lower_BandK[2] < Lower_BandK[1]); def conditionK3L = (Upper_BandK[3] < Upper_BandK[2]) and (Lower_BandK[3] < Lower_BandK[2]); def conditionK3 = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK); def BandwidthK = (Upper_BandK - Lower_BandK) / AvgK * 100; def condition_BWKUP = BandwidthK[1] < BandwidthK; def condition_BWKDOWN = BandwidthK[1] > BandwidthK; def BulgeK = Highest(BandwidthK, BulgeLengthK); def SqueezeK = Lowest(BandwidthK, SqueezeLengthK); def BulgeK2 = Highest(BandwidthK, BulgeLengthK2); def SqueezeK2 = Lowest(BandwidthK, SqueezeLengthK2); plot BulgePrice = Highest(price, BulgeLengthPrice); BulgePrice.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); plot SqueezePrice = Lowest(price, SqueezeLengthPrice); SqueezePrice.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); #plot BulgePrice2 = Highest(price, BulgeLengthPrice2); #BulgePrice2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); #BulgePrice2.SetStyle(Curve.SHORT_DASH); #plot SqueezePrice2 = Lowest(price, SqueezeLengthPrice2); #SqueezePrice2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY); #SqueezePrice2.SetStyle(Curve.SHORT_DASH); #MACD with Price def fastLength = 12; def slowLength = 26; def MACDLength = 9; input MACD_AverageType = {SMA, default EMA}; def MACDLevel = 0.0; def fastEMA = ExpAverage(price, fastLength); def slowEMA = ExpAverage(price, slowLength); def Value; def Avg; switch (MACD_AverageType) { case SMA: Value = Average(price, fastLength) - Average(price, slowLength); Avg = Average(Value, MACDLength); case EMA: Value = fastEMA - slowEMA; Avg = ExpAverage(Value, MACDLength); } def Diff = Value - Avg; def Level = MACDLevel; def condition1 = Value[1] <= Value; def condition1D = Value[1] > Value; #RSI def RSI_length = 14; def RSI_AverageType = AverageType.WILDERS; def RSI_OB = 70; def RSI_OS = 30; def NetChgAvg = MovingAverage(RSI_AverageType, price - price[1], RSI_length); def TotChgAvg = MovingAverage(RSI_AverageType, AbsValue(price - price[1]), RSI_length); def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0; def RSI = 50 * (ChgRatio + 1); def condition2 = (RSI[3] < RSI) is true or (RSI >= 80) is true; def condition2D = (RSI[3] > RSI) is true or (RSI < 20) is true; def conditionOB1 = RSI > RSI_OB; def conditionOS1 = RSI < RSI_OS; #MFI def MFI_Length = 14; def MFIover_Sold = 20; def MFIover_Bought = 80; def movingAvgLength = 1; def MoneyFlowIndex = Average(MoneyFlow(high, close, low, volume, MFI_Length), movingAvgLength); def MFIOverBought = MFIover_Bought; def MFIOverSold = MFIover_Sold; def condition3 = (MoneyFlowIndex[2] < MoneyFlowIndex) is true or (MoneyFlowIndex > 85) is true; def condition3D = (MoneyFlowIndex[2] > MoneyFlowIndex) is true or (MoneyFlowIndex < 20) is true; def conditionOB2 = MoneyFlowIndex > MFIover_Bought; def conditionOS2 = MoneyFlowIndex < MFIover_Sold; #Forecast def na = Double.NaN; def MidLine = 50; def Momentum = MarketForecast().Momentum; def NearT = MarketForecast().NearTerm; def Intermed = MarketForecast().Intermediate; def FOB = 80; def FOS = 20; def upperLine = 110; def condition4 = (Intermed[1] <= Intermed) and (NearT >= MidLine); def condition4D = (Intermed[1] > Intermed) and (NearT < MidLine); def conditionOB3 = Intermed > FOB; def conditionOS3 = Intermed < FOS; def conditionOB4 = NearT > FOB; def conditionOS4 = NearT < FOS; #Pivot Signals def n = 20; def ticks = 2.0; def bnOK = BarNumber() > n; def isHigher = fold i = 1 to n + 1 with p = 1 while p do high > GetValue(high, -i); def HH = if bnOK and isHigher and high == Highest(high, n) then high else Double.NaN; def isLower = fold j = 1 to n + 1 with q = 1 while q do low < GetValue(low, -j); def LL = if bnOK and isLower and low == Lowest(low, n) then low else Double.NaN; def PivH = if HH > 0 then HH else Double.NaN; def PivL = if LL > 0 then LL else Double.NaN; def UpPivotLow = !IsNaN(PivL); #UpPivotLow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); #UpPivotLow.SetLineWeight(4); #UpPivotLow.SetDefaultColor(Color.GREEN); def DownPivotHigh = !IsNaN(PivH); #DownPivotHigh.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); #DownPivotHigh.SetLineWeight(4); #DownPivotHigh.SetDefaultColor(Color.RED); def condition5 = !IsNaN(PivL); def condition5D = !IsNaN(PivH); #EMA_1 def EMA_length = 12; def AvgExp = ExpAverage(price[-displace], EMA_length); def condition6 = (price >= AvgExp) and (AvgExp[2] <= AvgExp); def condition6D = (price < AvgExp) and (AvgExp[2] > AvgExp); #EMA_2 def EMA_2length = 20; def displace2 = 0; def AvgExp2 = ExpAverage(price[-displace2], EMA_2length); def condition7 = (price >= AvgExp2) and (AvgExp[2] <= AvgExp); def condition7D = (price < AvgExp2) and (AvgExp[2] > AvgExp); #DMI Oscillator def DMI_length = 5;#Typically set to 10 input DMI_averageType = AverageType.WILDERS; def diPlus = DMI(DMI_length, DMI_averageType)."DI+"; def diMinus = DMI(DMI_length, DMI_averageType)."DI-"; def Osc = diPlus - diMinus; def Hist = Osc; def ZeroLine = 0; def condition8 = Osc >= ZeroLine; def condition8D = Osc < ZeroLine; #Trend_Periods def TP_fastLength = 3;#Typically 7 def TP_slowLength = 4;#Typically 15 def Periods = Sign(ExpAverage(close, TP_fastLength) - ExpAverage(close, TP_slowLength)); def condition9 = Periods > 0; def condition9D = Periods < 0; #Polarized Fractal Efficiency def PFE_length = 5;#Typically 10 def smoothingLength = 2.5;#Typically 5 def PFE_diff = close - close[PFE_length - 1]; def val = 100 * Sqrt(Sqr(PFE_diff) + Sqr(PFE_length)) / Sum(Sqrt(1 + Sqr(close - close[1])), PFE_length - 1); def PFE = ExpAverage(if PFE_diff > 0 then val else -val, smoothingLength); def UpperLevel = 50; def LowerLevel = -50; def condition10 = PFE > 0; def condition10D = PFE < 0; def conditionOB5 = PFE > UpperLevel; def conditionOS5 = PFE < LowerLevel; #Bollinger Bands PercentB input BBPB_averageType = AverageType.SIMPLE; def BBPB_length = 20;#Typically 20 def Num_Dev_Dn = -2.0; def Num_Dev_up = 2.0; def BBPB_OB = 100; def BBPB_OS = 0; def upperBand = BollingerBands(price, displace, BBPB_length, Num_Dev_Dn, Num_Dev_up, BBPB_averageType).UpperBand; def lowerBand = BollingerBands(price, displace, BBPB_length, Num_Dev_Dn, Num_Dev_up, BBPB_averageType).LowerBand; def PercentB = (price - lowerBand) / (upperBand - lowerBand) * 100; def HalfLine = 50; def UnitLine = 100; def condition11 = PercentB > HalfLine; def condition11D = PercentB < HalfLine; def conditionOB6 = PercentB > BBPB_OB; def conditionOS6 = PercentB < BBPB_OS; #STARC Bands def ATR_length = 15; def SMA_lengthS = 6; def multiplier_factor = 1.5; def valS = Average(price, SMA_lengthS); def average_true_range = Average(TrueRange(high, close, low), length = ATR_length); def Upper_BandS = valS[-displace] + multiplier_factor * average_true_range[-displace]; def Middle_BandS = valS[-displace]; def Lower_BandS = valS[-displace] - multiplier_factor * average_true_range[-displace]; def condition12 = (Upper_BandS[1] <= Upper_BandS) and (Lower_BandS[1] <= Lower_BandS); def condition12D = (Upper_BandS[1] > Upper_BandS) and (Lower_BandS[1] > Lower_BandS); #Klinger Histogram def Klinger_Length = 13; def KVOsc = KlingerOscillator(Klinger_Length).KVOsc; def KVOH = KVOsc - Average(KVOsc, Klinger_Length); def condition13 = (KVOH > 0) and (KVOsc[1] <= KVOsc); def condition13D = (KVOH < 0) and (KVOsc[1] > KVOsc); #Projection Oscillator def ProjectionOsc_length = 30;#Typically 10 def MaxBound = HighestWeighted(high, ProjectionOsc_length, LinearRegressionSlope(price = high, length = ProjectionOsc_length)); def MinBound = LowestWeighted(low, ProjectionOsc_length, LinearRegressionSlope(price = low, length = ProjectionOsc_length)); def ProjectionOsc_diff = MaxBound - MinBound; def PROSC = if ProjectionOsc_diff != 0 then 100 * (close - MinBound) / ProjectionOsc_diff else 0; def PROSC_OB = 80; def PROSC_OS = 20; def condition14 = PROSC > 50; def condition14D = PROSC < 50; def conditionOB7 = PROSC > PROSC_OB; def conditionOS7 = PROSC < PROSC_OS; #Trend Confirmation Calculator #Confirmation_Factor range 1-15. input coloredCandlesOn = no; input Confirmation_Factor = 3; #Use for testing conditions individually. Remove # from line below and change Confirmation_Factor to 1. #def Agreement_Level = condition1; def Agreement_LevelOB = 12; def Agreement_LevelOS = 3; def Agreement_Level = condition1 + condition2 + condition3 + condition4 + condition5 + condition6 + condition7 + condition8 + condition9 + condition10 + condition11 + condition12 + condition13 + condition14 + conditionK1 + conditionK2; def Agreement_LevelD = (condition1D + condition2D + condition3D + condition4D + condition5D + condition6D + condition7D + condition8D + condition9D + condition10D + condition11D + condition12D + condition13D + condition14D + conditionK3D + conditionK4D); def Consensus_Level = Agreement_Level - Agreement_LevelD; def conditionChannel1 = Upper_BandK > price; def conditionChannel2 = Lower_BandK < price; def UP = Consensus_Level >= 0; def DOWN = Consensus_Level < 0; #EMA's input length = 10; input agperiod1 = {"1 min", "2 min", "5 min", "10 min", "15 min", "30 min", "60 min", "4 hours", default "Day", "Week"}; input agperiod2 = {"1 min", "2 min", "5 min", "10 min", "15 min", "30 min", "60 min", "4 hours", "Day", default "Week"}; plot avg1 = ExpAverage(close(period = agperiod1), length); def height = avg - avg[length]; avg1.SetStyle(Curve.SHORT_DASH); avg1.SetLineWeight(1); def UP1 = avg1[1] < avg1; def DOWN1 = avg1[1] > avg1; Avg1.AssignValueColor(if UP1 then Color.LIGHT_GREEN else if DOWN1 then Color.RED else Color.YELLOW); plot avg2 = ExpAverage(close(period = agperiod2), length); def height2 = avg2 - avg2[length]; avg2.SetStyle(Curve.SHORT_DASH); avg2.SetLineWeight(1); #avg.SetDefaultColor(Color.Gray); def UP2 = avg2[1] < avg2; def DOWN2 = avg2[1] > avg2; Avg2.AssignValueColor(if UP2 then Color.LIGHT_GREEN else if DOWN2 then Color.RED else Color.YELLOW); plot price1 = close; def UP3 = price1[1] < price1; def DOWN3 = price1[1] > price1; #price1.AssignValueColor(if UP3 then Color.LIGHT_GREEN else if DOWN3 then Color.RED else Color.GRAY); price1.AssignValueColor( if Consensus_Level > Consensus_Level[1] and Consensus_Level >= 0 then Color.LIGHT_GREEN else if Consensus_Level < Consensus_Level[1] and Consensus_Level > 0 then Color.LIGHT_GREEN else if Consensus_Level < Consensus_Level[1] and Consensus_Level < 0 then Color.RED else if Consensus_Level > Consensus_Level[1] and Consensus_Level < 0 then Color.RED else Color.GRAY); AddCloud(avg2, avg1, Color.LIGHT_RED, Color.CURRENT); AddCloud(avg1, avg2, Color.LIGHT_GREEN, Color.CURRENT);
Both agperiods will show on whatever time frame you are on, unless you go to a higher timeframe chart than your agperiod (ie agperiod of week won't show on a monthly chart). I'm going to clean up that code a bit. I will repost shortly.
for the MTF setting, if my main chart is on a Daily timeframe, How/where does the Weekly setting work?
Just edited my previous post with the new code. Let me know if you have any issues.
for the MTF setting, if my main chart is on a Daily timeframe, How/where does the Weekly setting work?
Start a new thread and receive assistance from our community.
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.
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.