Confirmation Candles Indicator For ThinkorSwim

Ive got 2 dumb questions but I'll go ahead and shoot my shot:
1.) On C3 Max...Can the OB/OS areas be turned off?
2.) How would you go about changing the arrow color from Dynamic to user defined? I'm having a hard time seeing arrows at times due to the EMA cloud or other indicators I am using
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Thanks, I do find Watchlist columns alert faster than scans.

I'll see what I can come up or if anyone else can come up with the code, that'd be great

Thanks, I do find Watchlist columns alert faster than scans.

I'll see what I can come up or if anyone else can come up with the code, that'd be great
Hi @RedToGreen!
Just posted the WL code for the arrows on pg.1 of the thread. I hope this helps. Happy trading!!
urBhX7D.png
 
@Christopher84, here is a screenshot of /ES from this morning.


Left: 5 min chart with Scalper, RSI candles, and Mobius Trend Pivots. Please note the colored C3 MF Line. After saving the layout, the line plots solid gray instead of colored. I have fiddled with every setting I can think of and removed and re-added indicators but cannot reproduce a colored C3 MF Line if another study is coloring candles. What am I doing wrong? Also, when setting Scalper's aggregation periods, is it advisable to set agperiod1 to match the timeframe of the chart? Or is agperiod1 the first higher timeframe?

Right: 15 min chart with C3_Max. It did a great job marking where price still had support on the way down.

Thank you again for sharing your indicators.
@Trader Raider Do u mind sharing the bottom MACD indicator you used in this chart? Thanks
 
Ive got 2 dumb questions but I'll go ahead and shoot my shot:
1.) On C3 Max...Can the OB/OS areas be turned off?
2.) How would you go about changing the arrow color from Dynamic to user defined? I'm having a hard time seeing arrows at times due to the EMA cloud or other indicators I am using
Hi @Trader_Rich!
If show cloud is turned off, the cloud in the OB and OS zones will disappear, but the levels will still plot. The plots for the levels can be turned off individually in the settings. I'll look into making changes to the painting of the arrows. I hope this helps!
 
Hi @netarchitech!
Thank you for sharing! I'll be sure to check these out. Just as a reminder, there are already codes for the WL columns for Confirmation Level and Super OB_OS on pg.1 of the thread. I have included one addition WL column this morning (on pg.1 of the thread), which indicates if an OB/OS cloud is present. Hope this is helpful!
VhkSdLb.png

Hi @Christopher84

I apologize for the additional WL columns. I will edit the post and remove the columns to avoid any confusion.

Nice addition with the Super OB_OS Cloud WL column! Definitely helpful :cool:
 
Do u mind sharing the bottom MACD indicator you used in this chart? Thanks
@Fluideng has provided the link to the MACD_BB plotted on that chart. All I did was get rid of the dots and change colors a bit.

Beneath it is MerryDay's VWAP Deviation Scaled Chande Trend Meter label.
https://usethinkscript.com/threads/vwap-deviation-scaled-chande-trend-meter-for-thinkorswim.9374/
It may look a little different because I added extra labels to remind me of the values to watch for.

Best wishes and happy trading!
 
I have a question about the confirmation level watchlist and was wondering if it indicates if the confirmation level is rising or falling or if it's just indicating bearish or bullish

Thank you
 
I have a question about the confirmation level watchlist and was wondering if it indicates if the confirmation level is rising or falling or if it's just indicating bearish or bullish

Thank you
Its indicating bullish(green) or bearish(red) levels. Readings of 1 or less are typically OS, and readings of 12 or higher tend to be in an OB condition. I typically sort my WL by the level. It makes it a little easier to see motion within my WL. Another note, I like to use this column twice in my WL (one on day and one on month). It makes it easier to see when there is weakness in a strong trend that may pose a buying opportunity. An example would be an asset that is showing green on the monthly WL column and OS conditions on the day Confirmation Level. When combined with Super OB_OS WL and Cloud Reversal WL column (both set to day), it can make for some excellent swing trades.
 
Nice call out by the Scalper to scalp short at the open on the /ES this morning.
z5WCoGx.png


Sometimes I get chopped up on 1 min charts. Today scalper was fantastic on higher timeframes. Look at the perfect premarket entry signal when price closed above the C3 line and VWAP on the RTY 12 min chart. At mid day, it threw off a short signal and price fell until closing. Doesn't get much better than that for a futures trader!


 
@Christopher84 I just wanted to clear up some things regarding the watchlist columns..

On page 1, I no longer see the Super_OB_OS WL, just the cloud reversal. Unless I missed it.



The confirmation WL isn't based on the consensus lvl, but on the original Confirmation candles study, correct?

Is there a way to create a Consensus watchlist?

Thanks and I think that's all for now

TY for your time and effort

Edit: Working on something
 
Last edited:
Hi @Trader Raider!
I think I have a solution for utilizing the C3_MF_Line in that configuration. To fix it, I separated it off into its own study. I did my best to duplicate the study sets you were using. I hope this helps out! :)
g0UqnER.png


Code:
#C3_MF_Line_v2 Created by Christopher84 03/06/2022   
# Based off of the Confirmation Candles Study. Main difference is that CC Candles weigh factors of positive
# and negative price movement to create the Consensus_Level. The Consensus_Level is considered positive if
# above zero and negative if below zero.

#Keltner Channel
declare upper;
def displace = 0;
def factorK = 2.0;
def lengthK = 20;
def price = close;
def price1 = open;
input averageType = AverageType.SIMPLE;
def trueRangeAverageType = AverageType.SIMPLE;
def BulgeLengthPrice = 100;
def SqueezeLengthPrice = 100;
def BulgeLengthPrice2 = 20;
def SqueezeLengthPrice2 = 20;
def BulgeLengthPrice3 = 12;
def SqueezeLengthPrice3 = 12;

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 conditionK1UP = price >= Upper_BandK;
def conditionK2UP = (Upper_BandK[1] < Upper_BandK) and (Lower_BandK[1] < Lower_BandK);
def conditionK3DN = (Upper_BandK[1] > Upper_BandK) and (Lower_BandK[1] > Lower_BandK);
def conditionK4DN = price < Lower_BandK;
def BandwidthK = (Upper_BandK - Lower_BandK) / AvgK * 100;

def IntermResistance = Highest(price, BulgeLengthPrice);
#IntermResistance.AssignValueColor(if (conditionK2UP) then Color.GREEN else if (conditionK3DN) then Color.RED else Color.GRAY);
def IntermSupport = Lowest(price, SqueezeLengthPrice);
#IntermSupport.AssignValueColor(if (conditionK2UP) then Color.GREEN else if (conditionK3DN) then Color.RED else Color.GRAY);

def NearTResistance = Highest(price, BulgeLengthPrice2);
#NearTResistance.AssignValueColor(if (conditionK2UP) then Color.GREEN else if (conditionK3DN) then Color.RED else Color.GRAY);
#NearTResistance.SetStyle(Curve.SHORT_DASH);
def NearTSupport = Lowest(price, SqueezeLengthPrice2);
#NearTSupport.AssignValueColor(if (conditionK2UP) then Color.GREEN else if (conditionK3DN) then Color.RED else Color.GRAY);
#NearTSupport.SetStyle(Curve.SHORT_DASH);

def NearTResistance1 = Highest(price, BulgeLengthPrice3);
def NearTSupport1 = Lowest(price, SqueezeLengthPrice3);

#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;

#Change in Price
def lengthCIP = 5;
def CIP = (price - price[1]);
def AvgCIP = ExpAverage(CIP[-displace], lengthCIP);
def CIP_UP = AvgCIP > AvgCIP[1];
def CIP_DOWN = AvgCIP < AvgCIP[1];

def condition5 = CIP_UP;
def condition5D = CIP_DOWN;

#EMA_1
def EMA_length = 8;
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 = 8;
def displace2 = 0;
def AvgExp2 = ExpAverage(price[-displace2], EMA_2length);

def condition7 = (price >= AvgExp2) and (AvgExp2[2] <= AvgExp);
def condition7D = (price < AvgExp2) and (AvgExp2[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.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);
def condition13D = (KVOH < 0);

#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 = yes;
input 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 = 10;
def Agreement_LevelOS = -10;

def Agreement_Level = condition1 + condition2 + condition3 + condition4 + condition5 + condition6 + condition7 + condition8 + condition9 + condition10 + condition11 + condition12 + condition13 + condition14 + conditionK1UP + conditionK2UP;

def Agreement_LevelD = (condition1D + condition2D + condition3D + condition4D + condition5D + condition6D + condition7D + condition8D + condition9D + condition10D + condition11D + condition12D + condition13D + condition14D + conditionK3DN + conditionK4DN);

def Consensus_Level = Agreement_Level - Agreement_LevelD;

def UP = Consensus_Level >= 6;
def DOWN = Consensus_Level < -6;

def priceColor = if UP then 1
                 else if DOWN then -1
                 else priceColor[1];

#Keltner #2
input showCloud = yes;
def factorK2 = 3.25;
def lengthK2 = 20;

def shiftK2 = factorK2 * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), lengthK2);
def averageK2 = MovingAverage(averageType, price, lengthK2);
def AvgK2 = averageK2[-displace];
def Upper_BandK2 = averageK2[-displace] + shiftK2[-displace];
def Lower_BandK2 = averageK2[-displace] - shiftK2[-displace];
def condition_BandRevDn = (Upper_BandS > Upper_BandK2);
def condition_BandRevUp = (Lower_BandS < Lower_BandK2);

#Consensus_Level.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);

def Zero_Line = 0;


#AddCloud(Consensus_Level, Agreement_LevelOB, Color.LIGHT_RED, Color.CURRENT);
#AddCloud(Consensus_Level, Agreement_LevelOS, Color.CURRENT, Color.LIGHT_GREEN);

#plot BulgeCC = Highest(Consensus_Level, BulgeLengthCC);
#BulgeCC.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);

#plot SqueezeCC = Lowest(Consensus_Level, SqueezeLengthCC);
#SqueezeCC.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);

#plot BulgeCC2 = Highest(Consensus_Level, BulgeLengthCC2);
#BulgeCC2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);
#BulgeCC2.SetStyle(Curve.SHORT_DASH);

#plot SqueezeCC2 = Lowest(Consensus_Level, SqueezeLengthCC2);
#SqueezeCC2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);
#SqueezeCC2.SetStyle(Curve.SHORT_DASH);
##########################################################################################################################

script WMA_Smooth {
    input price = hl2;
    plot smooth = (4 * price
+ 3 * price[1]
+ 2 * price[2]
+ price[3]) / 10;
}

script Phase_Accumulation {
# This is Ehler's Phase Accumulation code. It has a full cycle delay.
# However, it computes the correction factor to a very high degree.
#
    input price = hl2;

    rec Smooth;
    rec Detrender;
    rec Period;
    rec Q1;
    rec I1;
    rec I1p;
    rec Q1p;
    rec Phase1;
    rec Phase;
    rec DeltaPhase;
    rec DeltaPhase1;
    rec InstPeriod1;
    rec InstPeriod;
    def CorrectionFactor;

    if BarNumber() <= 5
    then {
        Period = 0;
        Smooth = 0;
        Detrender = 0;
        CorrectionFactor = 0;
        Q1 = 0;
        I1 = 0;
        Q1p = 0;
        I1p = 0;
        Phase = 0;
        Phase1 = 0;
        DeltaPhase1 = 0;
        DeltaPhase = 0;
        InstPeriod = 0;
        InstPeriod1 = 0;
    } else {
        CorrectionFactor = 0.075 * Period[1] + 0.54;

# Smooth and detrend my smoothed signal:
        Smooth = WMA_Smooth(price);
        Detrender = ( 0.0962 * Smooth
+ 0.5769 * Smooth[2]
- 0.5769 * Smooth[4]
- 0.0962 * Smooth[6] ) * CorrectionFactor;

# Compute Quadrature and Phase of Detrended signal:
        Q1p = ( 0.0962 * Detrender
+ 0.5769 * Detrender[2]
- 0.5769 * Detrender[4]
- 0.0962 * Detrender[6] ) * CorrectionFactor;
        I1p = Detrender[3];

# Smooth out Quadrature and Phase:
        I1 = 0.15 * I1p + 0.85 * I1p[1];
        Q1 = 0.15 * Q1p + 0.85 * Q1p[1];

# Determine Phase
        if I1 != 0
        then {
# Normally, ATAN gives results from -pi/2 to pi/2.
# We need to map this to circular coordinates 0 to 2pi

            if Q1 >= 0 and I1 > 0
            then { # Quarant 1
                Phase1 = ATan(AbsValue(Q1 / I1));
            } else if Q1 >= 0 and I1 < 0
            then { # Quadrant 2
                Phase1 = Double.Pi - ATan(AbsValue(Q1 / I1));
            } else if Q1 < 0 and I1 < 0
            then { # Quadrant 3
                Phase1 = Double.Pi + ATan(AbsValue(Q1 / I1));
            } else { # Quadrant 4
                Phase1 = 2 * Double.Pi - ATan(AbsValue(Q1 / I1));
            }
        } else if Q1 > 0
        then { # I1 == 0, Q1 is positive
            Phase1 = Double.Pi / 2;
        } else if Q1 < 0
        then { # I1 == 0, Q1 is negative
            Phase1 = 3 * Double.Pi / 2;
        } else { # I1 and Q1 == 0
            Phase1 = 0;
        }

# Convert phase to degrees
        Phase = Phase1 * 180 / Double.Pi;

        if Phase[1] < 90 and Phase > 270
        then {
# This occurs when there is a big jump from 360-0
            DeltaPhase1 = 360 + Phase[1] - Phase;
        } else {
            DeltaPhase1 = Phase[1] - Phase;
        }

# Limit our delta phases between 7 and 60
        if DeltaPhase1 < 7
        then {
            DeltaPhase = 7;
        } else if DeltaPhase1 > 60
        then {
            DeltaPhase = 60;
        } else {
            DeltaPhase = DeltaPhase1;
        }

# Determine Instantaneous period:
        InstPeriod1 =
-1 * (fold i = 0 to 40 with v=0 do
if v < 0 then
v
else if v > 360 then
-i
else
v + GetValue(DeltaPhase, i, 41)
);

        if InstPeriod1 <= 0
        then {
            InstPeriod = InstPeriod[1];
        } else {
            InstPeriod = InstPeriod1;
        }

        Period = 0.25 * InstPeriod + 0.75 * Period[1];
    }
    plot DC = Period;
}

script Ehler_MAMA {
    input price = hl2;
    input FastLimit = 0.5;
    input SlowLimit = 0.05;


    rec Period;
    rec Period_raw;
    rec Period_cap;
    rec Period_lim;

    rec Smooth;
    rec Detrender;
    rec I1;
    rec Q1;
    rec jI;
    rec jQ;
    rec I2;
    rec Q2;
    rec I2_raw;
    rec Q2_raw;

    rec Phase;
    rec DeltaPhase;
    rec DeltaPhase_raw;
    rec alpha;
    rec alpha_raw;

    rec Re;
    rec Im;
    rec Re_raw;
    rec Im_raw;

    rec SmoothPeriod;
    rec vmama;
    rec vfama;

    def CorrectionFactor = Phase_Accumulation(price).CorrectionFactor;

    if BarNumber() <= 5
    then {
        Smooth = 0;
        Detrender = 0;

        Period = 0;
        Period_raw = 0;
        Period_cap = 0;
        Period_lim = 0;
        I1 = 0;
        Q1 = 0;
        I2 = 0;
        Q2 = 0;
        jI = 0;
        jQ = 0;
        I2_raw = 0;
        Q2_raw = 0;
        Re = 0;
        Im = 0;
        Re_raw = 0;
        Im_raw = 0;
        SmoothPeriod = 0;
        Phase = 0;
        DeltaPhase = 0;
        DeltaPhase_raw = 0;
        alpha = 0;
        alpha_raw = 0;
        vmama = 0;
        vfama = 0;
    } else {
# Smooth and detrend my smoothed signal:
        Smooth = WMA_Smooth(price);
        Detrender = ( 0.0962 * Smooth
+ 0.5769 * Smooth[2]
- 0.5769 * Smooth[4]
- 0.0962 * Smooth[6] ) * CorrectionFactor;

        Q1 = ( 0.0962 * Detrender
+ 0.5769 * Detrender[2]
- 0.5769 * Detrender[4]
- 0.0962 * Detrender[6] ) * CorrectionFactor;
        I1 = Detrender[3];

        jI = ( 0.0962 * I1
+ 0.5769 * I1[2]
- 0.5769 * I1[4]
- 0.0962 * I1[6] ) * CorrectionFactor;

        jQ = ( 0.0962 * Q1
+ 0.5769 * Q1[2]
- 0.5769 * Q1[4]
- 0.0962 * Q1[6] ) * CorrectionFactor;

# This is the complex conjugate
        I2_raw = I1 - jQ;
        Q2_raw = Q1 + jI;

        I2 = 0.2 * I2_raw + 0.8 * I2_raw[1];
        Q2 = 0.2 * Q2_raw + 0.8 * Q2_raw[1];

        Re_raw = I2 * I2[1] + Q2 * Q2[1];
        Im_raw = I2 * Q2[1] - Q2 * I2[1];

        Re = 0.2 * Re_raw + 0.8 * Re_raw[1];
        Im = 0.2 * Im_raw + 0.8 * Im_raw[1];

# Compute the phase
        if Re != 0 and Im != 0
        then {
            Period_raw = 2 * Double.Pi / ATan(Im / Re);
        } else {
            Period_raw = 0;
        }

        if Period_raw > 1.5 * Period_raw[1]
        then {
            Period_cap = 1.5 * Period_raw[1];
        } else if Period_raw < 0.67 * Period_raw[1] {
            Period_cap = 0.67 * Period_raw[1];
        } else {
            Period_cap = Period_raw;
        }

        if Period_cap < 6
        then {
            Period_lim = 6;
        } else if Period_cap > 50
        then {
            Period_lim = 50;
        } else {
            Period_lim = Period_cap;
        }

        Period = 0.2 * Period_lim + 0.8 * Period_lim[1];
        SmoothPeriod = 0.33 * Period + 0.67 * SmoothPeriod[1];

        if I1 != 0
        then {
            Phase = ATan(Q1 / I1);
        } else if Q1 > 0
        then { # Quadrant 1:
            Phase = Double.Pi / 2;
        } else if Q1 < 0
        then { # Quadrant 4:
            Phase = -Double.Pi / 2;
        } else { # Both numerator and denominator are 0.
            Phase = 0;
        }

        DeltaPhase_raw = Phase[1] - Phase;
        if DeltaPhase_raw < 1
        then {
            DeltaPhase = 1;
        } else {
            DeltaPhase = DeltaPhase_raw;
        }

        alpha_raw = FastLimit / DeltaPhase;
        if alpha_raw < SlowLimit
        then {
            alpha = SlowLimit;
        } else {
            alpha = alpha_raw;
        }
        vmama = alpha * price + (1 - alpha) * vmama[1];
        vfama = 0.5 * alpha * vmama + (1 - 0.5 * alpha) * vfama[1];
    }

    plot MAMA = vmama;
    plot FAMA = vfama;
}


input price2 = hl2;
input FastLimit = 0.5;
input SlowLimit = 0.05;

def MAMA = Ehler_MAMA(price2, FastLimit, SlowLimit).MAMA;
def FAMA = Ehler_MAMA(price2, FastLimit, SlowLimit).FAMA;

def Crossing = Crosses((MAMA < FAMA), yes);
#Crossing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

def Crossing1 = Crosses((MAMA > FAMA), yes);
#Crossing1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

##################################
plot C3_MF_Line = (MAMA + FAMA) / 2;
C3_MF_Line.SetPaintingStrategy(PaintingStrategy.Line);
C3_MF_Line.SetLineWeight(3);
C3_MF_Line.AssignValueColor(if coloredCandlesOn and ((priceColor == 1) and (price1 > Upper_BandS) and (condition_BandRevDn)) then Color.YELLOW else if coloredCandlesOn and ((priceColor == -1) and (price1 < Lower_BandS) and (condition_BandRevUp)) then Color.YELLOW else if coloredCandlesOn and priceColor == -1 then Color.RED  else if coloredCandlesOn and (priceColor == 1) then Color.GREEN else Color.CURRENT);
I think this C3_MF_LINE alone is much cleaner to use. I like this RED, GREEN
BTW i noticed in line 138 after #EMA_2 the length of line is 8 (Same as ema1) it should be 20
FYI @Trader Raider too
 
@Christopher84 I just wanted to clear up some things regarding the watchlist columns..

On page 1, I no longer see the Super_OB_OS WL, just the cloud reversal. Unless I missed it.



The confirmation WL isn't based on the consensus lvl, but on the original Confirmation candles study, correct?

Is there a way to create a Consensus watchlist?

Thanks and I think that's all for now

TY for your time and effort

Edit: Working on something


Ok I took the Consensus lower, split it up into 2 different watchlists (if you have the space)

Here's what I came up with

9MdMxMA.png


1) Thumbs up/Down indicating if the consensus level is rising or falling.
2) How long (Bars, days) it's been going up or down
3) The Consensus level
If you add up the consensus levels, the majority of the time, it matches the CC Max chart label---I've only seen it off by +/- 1

Here are the codes:

Part 1
Code:
#Consensus WL Part 1
#CC Candles Lower V.2
#Created 04/28/2021 by Christopher84
#Modified to V.2 05/11/2021 - dialed in studies to give stronger signals. Included OB/OS Clouds and cleaned up code.
#Changed 05/20/2021 to V.3 - Removed Pivot Study and replaced with CIP.

#Keltner Channel
declare lower;
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);

#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;



#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.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);
def condition13D = (KVOH < 0);

#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;
def Confirmation_Factor = 0;
#Use for testing conditions individually. Remove # from line below and change Confirmation_Factor to 1.
#def Agreement_Level = condition1;
def Agreement_LevelOB = 10;
def Agreement_LevelOS = -10;

def Agreement_Level =     condition6 + condition7 + condition8 + condition9 + condition10 + condition11 + condition12 + condition13 + condition14 ;
#condition1 + condition2 +  conditionK1 + conditionK2 condition3 + condition4 + condition5 +


def Agreement_LevelD = (    condition6D + condition7D + condition8D + condition9D + condition10D + condition11D + condition12D + condition13D + condition14D );
#condition1D + condition2D + conditionK3D + conditionK4D condition3D + condition4D + condition5D +

plot Consensus_Level = Agreement_Level - Agreement_LevelD;
def ConsensusRise = Consensus_Level > consensus_Level[1];
def ConsensusFall = Consensus_Level < consensus_Level[1];

#assignBackgroundColor(if ConsensusRise then color.DARK_GREEN else if ConsensusFall then color.DARK_RED else color.BLACK);

# ============================
def BuylineDir  = if ConsensusRise then 1 else if ConsensusFall then 2 else 0;

def alertCount = if buylineDir[1] == 0 and buylineDir == 1 then 1 else if buylineDir == 1 then alertCount[1] + 1 else 0;
plot buylineCnt = alertCount;




#def Buyv = sellbuydiff5 > 0  and Buyline > zer0 or sellbuydiff5 > 0 and bv;
#def SellV = sellbuydiff5 < 0 and Buyline < zer0  or sellbuydiff5 < 0 and sv;



addlabel(yes, if ConsensusRise then "👍  " + buylineCnt + " (" + Consensus_Level + ")" else if ConsensusFall then "👎  " + buylineCnt + " (" + Consensus_Level + ")" else  "", if ConsensusRise then CreateColor(16,129,200) else if ConsensusFall then CreateColor(193,43,43) else color.BLACK);


#addlabel(yes, if ConsensusRise then "R" else if ConsensusFall then "F" else "_");
#def conditionChannel1 = Upper_BandK > price;
#def conditionChannel2 = Lower_BandK < price;

#def UP = Consensus_Level >= 0;
#def DOWN = Consensus_Level < 0;

#Consensus_Level.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);

#def Zero_Line = 0;

#AddCloud(Consensus_Level, Agreement_LevelOB, Color.LIGHT_RED, Color.CURRENT);
#AddCloud(Consensus_Level, Agreement_LevelOS, Color.CURRENT, Color.LIGHT_GREEN);

#plot BulgeCC = Highest(Consensus_Level, BulgeLengthCC);
#BulgeCC.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);

#plot SqueezeCC = Lowest(Consensus_Level, SqueezeLengthCC);
#SqueezeCC.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);

#plot BulgeCC2 = Highest(Consensus_Level, BulgeLengthCC2);
#BulgeCC2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);
#BulgeCC2.SetStyle(Curve.SHORT_DASH);

#plot SqueezeCC2 = Lowest(Consensus_Level, SqueezeLengthCC2);
#SqueezeCC2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);
#SqueezeCC2.SetStyle(Curve.SHORT_DASH);


Part 2 (second WL)

Code:
#CC Candles Lower V.2
#Created 04/28/2021 by Christopher84
#Modified to V.2 05/11/2021 - dialed in studies to give stronger signals. Included OB/OS Clouds and cleaned up code.
#Changed 05/20/2021 to V.3 - Removed Pivot Study and replaced with CIP.

#Keltner Channel
declare lower;
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);

#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;
# =================================================
#==================================================================
#================================================================================
#Change in Price
def lengthCIP = 5;
def CIP = (price - price[1]);
def AvgCIP = ExpAverage(CIP[-displace], lengthCIP);

def CIP_UP = AvgCIP > AvgCIP[1];
def CIP_DOWN = AvgCIP < AvgCIP[1];

def condition5 = CIP_UP;
def condition5D = CIP_DOWN;

#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.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);
#def condition13D = (KVOH < 0);

#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;
def Confirmation_Factor = 0;
#Use for testing conditions individually. Remove # from line below and change Confirmation_Factor to 1.
#def Agreement_Level = condition1;
def Agreement_LevelOB = 10;
def Agreement_LevelOS = -10;

def Agreement_Level =    condition1 + condition2 +  conditionK1 + conditionK2 + condition3 + condition4 + condition5 ;
# condition5 + condition6 + condition7 + condition8 + condition9 + condition10 + condition11 + condition12 + condition13 + condition14 +

def Agreement_LevelD = (    condition1D + condition2D + conditionK3D + conditionK4D + condition3D + condition4D + condition5D );
#condition5D + condition6D + condition7D + condition8D + condition9D + condition10D + condition11D + condition12D + condition13D + condition14D

plot Consensus_Level = Agreement_Level - Agreement_LevelD;
def ConsensusRise = Consensus_Level > consensus_Level[1];
def ConsensusFall = Consensus_Level < consensus_Level[1];

#assignBackgroundColor(if ConsensusRise then color.DARK_GREEN else if ConsensusFall then color.DARK_RED else color.BLACK);

# ============================
def BuylineDir  = if ConsensusRise then 1 else if ConsensusFall then 2 else 0;

def alertCount = if buylineDir[1] == 0 and buylineDir == 1 then 1 else if buylineDir == 1 then alertCount[1] + 1 else 0;
plot buylineCnt = alertCount;




#def Buyv = sellbuydiff5 > 0  and Buyline > zer0 or sellbuydiff5 > 0 and bv;
#def SellV = sellbuydiff5 < 0 and Buyline < zer0  or sellbuydiff5 < 0 and sv;



addlabel(yes, if ConsensusRise then "👍  " + buylineCnt + " (" + Consensus_Level + ")" else if ConsensusFall then "👎  " + buylineCnt + " (" + Consensus_Level + ")" else  "", if ConsensusRise then CreateColor(16,129,200) else if ConsensusFall then CreateColor(193,43,43) else color.BLACK);


# ==================================

#addlabel(yes, if ConsensusRise then "R" else if ConsensusFall then "F" else "_");
#def conditionChannel1 = Upper_BandK > price;
#def conditionChannel2 = Lower_BandK < price;

#def UP = Consensus_Level >= 0;
#def DOWN = Consensus_Level < 0;

#Consensus_Level.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);

#def Zero_Line = 0;

#AddCloud(Consensus_Level, Agreement_LevelOB, Color.LIGHT_RED, Color.CURRENT);
#AddCloud(Consensus_Level, Agreement_LevelOS, Color.CURRENT, Color.LIGHT_GREEN);

#plot BulgeCC = Highest(Consensus_Level, BulgeLengthCC);
#BulgeCC.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);

#plot SqueezeCC = Lowest(Consensus_Level, SqueezeLengthCC);
#SqueezeCC.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);

#plot BulgeCC2 = Highest(Consensus_Level, BulgeLengthCC2);
#BulgeCC2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);
#BulgeCC2.SetStyle(Curve.SHORT_DASH);

#plot SqueezeCC2 = Lowest(Consensus_Level, SqueezeLengthCC2);
#SqueezeCC2.AssignValueColor(if (conditionK2) then Color.GREEN else if (conditionK3) then Color.RED else Color.GRAY);
#SqueezeCC2.SetStyle(Curve.SHORT_DASH);

D4evE2F.png
 
Last edited:
@Christopher84
can scan be written for this, scan when green end or when red ends? thanks.
If you go thru earlier threads ... there are some scans written for this based on CONSENSUS_AGREEMENT or CONSENSUS_LEVEL .. you can use them. That's NOT 100% i.e. some studies like Bollinger band etc., can't be used in the scan so it's a compromise w/o those and scans came close.... so please look at them.

But I am not sure TOS will allow to write this much complicated (now that this version has added EHLERs stuff).
 
@Christopher84 or @Trader Raider or others..

1) How are you or anyone using just the C3_MF_LINE in scalping ( I just have that alone now) and want to see how anyone is using for scalping (5 mins) or even swing trading.

2) Also , can someone explain how the heck this Ehlers MAMA/VAMA is effective ( if i don't get an answer on Q1 .. i want to understand this to see how to use). Yep i googled and tried to read this... but it's above my head ( Yep , i am engineer... :) but can't interpret this)
 
Nice call out by the Scalper to scalp short at the open on the /ES this morning.
z5WCoGx.png
Actually, I found this scalper creative by you is really usually, I appreciate your work and share with US. As a user, I want to understand more details about this indicate, for example, what is that line between candles. I know green means bullish, red means opposite.

So I have few question about that theory behind them, hope you can explain to us a little.

Those are questions I want to ask you :

1. I noticed that candles bars also filled sometimes. After a lot of green candles, a green candle filled, what is what mean ?
And red candles sometimes also filled, what make the difference between filled and non-filled red candles?

2. Buy arrow and sell arrow shows very often during 1 min chart, what is an effective arrow when you consider from this scalper?

3. Long bias or short bias, those labels are interesting when they usually with a percentage, how do this scalper calculate that percentage?

My question might be looked a little basic, hope to get your answer.

Have a nice weekend with your family !
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
317 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top