Confirmation Candles Indicator For ThinkorSwim

Hi C84, I am very intrigued with these set of indicators and have been using the C3 indicator for the past couple of days. I have been reading this topic (not completed yet). I believe there was a mention to use the 10 min timeframe for scalping and that is what I am starting off with to use the C3 indicator. I understand your strategy for entering and exiting trades from your above explanation.
What about entering a short trade when there is a red candle with a red down arrow in a red channel? And vice versa?
Also, what if there is a red candle with a red down arrow but in a green channel?
Thanks.
Hi @tosman!
Seems like you have the right idea. You can take the rules used for going long and basically flip them around for short signals. Should work pretty well. Nice question!
 

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

Hi @Christopher84
I watched the YT vid tonight, I've read every thread entry (took around 18 hours :)), taken notes, screenshots, code saves, just Fantastic stuff you are sharing, so I wanted to give major THANK YOU to you!!!

Two questions,
1. Can you talk about the difference between the Wide band style colored S/R cloud found in C3_Max vs the Line style colored S/R found in C3_v6 please & CC_v10 and maybe others? Is the wide band giving you more S/R price range history information and the line type is the average of that range possibly?
Also, in C3_Max, with the wide colored band S/R there are also additional yellow and green horizontal lines, are those pre-market or opening day S/R lines?
Thanks.
Hi @macattacktos!
What a fantastic question! Sorry it’s taken me a while to get back to everyone. But let me give my thoughts on this.
In the original version of CC Candles and Confirmation Candles, the channels we’re basically price channels. The intermediate term channels were set to a 75 length the shorter term support and resistance channels were set a 20 length. They do a fair job of showing potential support and resistance especially if you back out on larger time frames. The color of the channels reflects agreement on the rise of the Keltner channels. if green the channels are pointing up, and red they are pointing down. The concept behind C3_Max is a bit different.
The OB/OS zones found in C3_Max are intended for two different purposes. Number one is to identify significant levels where price is heavily overbought or oversold. Sections where the bands flatten out tend to be significant support or resistance. The second thing the OB/OS zones can indicate is heavy trending states. This can be seen when the bands are actively wrapping price. This is especially true on lower time frames.
The yellow and green lines that you’re referring to, I call yellow candle (YC) levels. Yellow lines are extremely overbought levels and the lime green lines are extremely oversold levels. These levels may be some of the most significant price levels found on your chart. You will find that price tend to gravitate toward these levels use them as support and resistance as well as chop around these levels whenever it consolidates after a large move. Plot them on your chart, back out and look at how the price reacts at these levels. I think you’ll see what I’m saying. Thank you for such a great question and taking the time to look through the thread!! My apologies for my slow response (I’m currently in the hospital). I will be working on releasing more videos soon! Happy trading @macattacktos!
 
Hi @macattacktos!
What a fantastic question! Sorry it’s taken me a while to get back to everyone. But let me give my thoughts on this.
In the original version of CC Candles and Confirmation Candles, the channels we’re basically price channels. The intermediate term channels were set to a 75 length the shorter term support and resistance channels were set a 20 length. They do a fair job of showing potential support and resistance especially if you back out on larger time frames. The color of the channels reflects agreement on the rise of the Keltner channels. if green the channels are pointing up, and red they are pointing down. The concept behind C3_Max is a bit different.
The OB/OS zones found in C3_Max are intended for two different purposes. Number one is to identify significant levels where price is heavily overbought or oversold. Sections where the bands flatten out tend to be significant support or resistance. The second thing the OB/OS zones can indicate is heavy trending states. This can be seen when the bands are actively wrapping price. This is especially true on lower time frames.
The yellow and green lines that you’re referring to, I call yellow candle (YC) levels. Yellow lines are extremely overbought levels and the lime green lines are extremely oversold levels. These levels may be some of the most significant price levels found on your chart. You will find that price tend to gravitate toward these levels use them as support and resistance as well as chop around these levels whenever it consolidates after a large move. Plot them on your chart, back out and look at how the price reacts at these levels. I think you’ll see what I’m saying. Thank you for such a great question and taking the time to look through the thread!! My apologies for my slow response (I’m currently in the hospital). I will be working on releasing more videos soon! Happy trading @macattacktos!
@Christopher84 Hope you get better soon. Take care.
 
Hi @macattacktos!
What a fantastic question! Sorry it’s taken me a while to get back to everyone. But let me give my thoughts on this.
In the original version of CC Candles and Confirmation Candles, the channels we’re basically price channels. The intermediate term channels were set to a 75 length the shorter term support and resistance channels were set a 20 length. They do a fair job of showing potential support and resistance especially if you back out on larger time frames. The color of the channels reflects agreement on the rise of the Keltner channels. if green the channels are pointing up, and red they are pointing down. The concept behind C3_Max is a bit different.
The OB/OS zones found in C3_Max are intended for two different purposes. Number one is to identify significant levels where price is heavily overbought or oversold. Sections where the bands flatten out tend to be significant support or resistance. The second thing the OB/OS zones can indicate is heavy trending states. This can be seen when the bands are actively wrapping price. This is especially true on lower time frames.
The yellow and green lines that you’re referring to, I call yellow candle (YC) levels. Yellow lines are extremely overbought levels and the lime green lines are extremely oversold levels. These levels may be some of the most significant price levels found on your chart. You will find that price tend to gravitate toward these levels use them as support and resistance as well as chop around these levels whenever it consolidates after a large move. Plot them on your chart, back out and look at how the price reacts at these levels. I think you’ll see what I’m saying. Thank you for such a great question and taking the time to look through the thread!! My apologies for my slow response (I’m currently in the hospital). I will be working on releasing more videos soon! Happy trading @macattacktos!
@Christopher84 Thanks much for the great reply, get out of that hospital as quickly as you can! I'm sure you have a lot of watchers here wishing you the best in health and to get back home soon!!!
 
Christopher's clouds and candles strike again! On both the MNQ and MYM, price consolidated this morning, then dipped below the clouds hitting profit targets. Folks are probably tired of my pics, so I won't waste space posting them. At first, I was trading MTF clouds and confirmation candles on 5 min charts. The results were great, but when I switched to consensus candles and MTF clouds on 15 min charts, it was easier to find sweet spots for grabbing measured moves with fib targets.

Best wishes, happy trading, and happy weekend! And much gratitude🙏 to Christopher for sharing these indicators!
I have been using a similar setup for the past week - just started using Christopher's indicators and am catching up on this thread. I am using the 5 min and 15 min charts, but am not sure what values to set for "agperiod1" and "agperiod2". Suggestions on what values to set? Thanks.
 
I have been using a similar setup for the past week - just started using Christopher's indicators and am catching up on this thread. I am using the 5 min and 15 min charts, but am not sure what values to set for "agperiod1" and "agperiod2". Suggestions on what values to set? Thanks.
Depends what time frame you trade on.

I trade on 2 min and use
5m
10m
15m
30m
Hr
Different timeframes will give different signals
 
I have been using a similar setup for the past week - just started using Christopher's indicators and am catching up on this thread. I am using the 5 min and 15 min charts, but am not sure what values to set for "agperiod1" and "agperiod2". Suggestions on what values to set? Thanks.

Depends on the instrument and time of day. I typically analyze using a grid with several cells (such as 5 min, 15 min, 1 hour) and different aggregations in each cell. I want to see agreement across all three cells. For example, if the 5 min is showing a short but the hour is showing a long, I stay out until a good long entry comes up on the 5 min cell. I try to trade in the direction of the higher time frame trend, but that may not be on your trade plan.

My suggestion is that you plot a few cells with various aggregations. You can try what @RedToGreen suggests above and then plot different cells with different time frames and different aggregations. Or plot your 5 min grid with a variety of different aggregations. Then watch to see if there is significant difference in what is displayed. Watch whether one timeframe and aggregation seems more responsive to your needs than another. Go ahead and play around ... you won't break it.

Best wishes and happy trading!

PS- Christopher, if you're lurking, am still sending well wishes your way!
 
A couple charts today using my scalper settings...

As you can see here, not all but many times alerts start coming before the breakout.

Every so often they come after it's already run a bit but most of the time, I see good entries.

I also use the Hr B4

CC Max / Scalper one of the Best Indicators I've come across

glrTghI.png





8KA4ZZ0.png

where do you get the "CC Max / Scalper" indicator or is this what I am looking at?, thanks ahead
 
Depends on the instrument and time of day. I typically analyze using a grid with several cells (such as 5 min, 15 min, 1 hour) and different aggregations in each cell. I want to see agreement across all three cells. For example, if the 5 min is showing a short but the hour is showing a long, I stay out until a good long entry comes up on the 5 min cell. I try to trade in the direction of the higher time frame trend, but that may not be on your trade plan.

My suggestion is that you plot a few cells with various aggregations. You can try what @RedToGreen suggests above and then plot different cells with different time frames and different aggregations. Or plot your 5 min grid with a variety of different aggregations. Then watch to see if there is significant difference in what is displayed. Watch whether one timeframe and aggregation seems more responsive to your needs than another. Go ahead and play around ... you won't break it.

Best wishes and happy trading!

PS- Christopher, if you're lurking, am still sending well wishes your way!
Thanks for the detailed explanation @Trader Raider and @RedToGreen
Thank you @Christopher84 for the indicators
 
Last edited:
Hi has anybody tried making an oco order based on the v10 version of the confirmation candles? I am asking because I am in school when the market opens and I want to know if anybody can guide me through making one so I can trade with it.
 
Hi has anybody tried making an oco order based on the v10 version of the confirmation candles? I am asking because I am in school when the market opens and I want to know if anybody can guide me through making one so I can trade with it.
The ToS platform provides the ability to use conditional orders for the simplest of scripts. This study is too complex for the conditional order module.
 
On the SPX chart (5 min timeframe), I am seeing the "MTF_Moving_Average_Upper" study, but am not seeing the plot for "MTF_Moving_Average_Lower" study. I tried with different agperiods, but still no plot. Not sure whether there is a MTF_Moving_Average study targeting SPX?
 
On the SPX chart (5 min timeframe), I am seeing the "MTF_Moving_Average_Upper" study, but am not seeing the plot for "MTF_Moving_Average_Lower" study. I tried with different agperiods, but still no plot. Not sure whether there is a MTF_Moving_Average study targeting SPX?
Hi @tosman!
The lower version contains the full code (not just the moving averages) and certain studies within the code will not work on SPX. I should be able to come up with a reasonable fix pretty quickly. I’m hoping to get back into the office tomorrow all being well. I’ll keep you posted @tosman.

PS: thanks to everyone for the well wishes while I was down. It was much appreciated!
 
Here's the code I'm using..

5 agg periods instead of 6

You're right, does look like the % label is gone....:unsure:

There is no "X_ing" signal

You'll get continuous arrows as long as the conditions are true.

If the chart Bias is "Scalp Long", you'll never see a short signal and vice versa

The conditions may fade but the fuel has already been added, if you get my drift

I use the hour B4 to help stay out of bad setups

and yes, I changed the label colors...at least the "Green" ones

Code:
#Scalper Upper v2 Created 02/01/2022 by Christopher84
#Sound Alerts added by Barbaros

declare upper;

input price = close;
input length = 10;
input length2 = 35;
input agperiod1 = { "1 min", default "2 min", "3 min", "5 min", "10 min", "15 min", "30 min", "1 hour", "2 hours", "4 hours", "Day", "Week", "Month"};
input agperiod2 = {"1 min", "2 min", default "3 min", "5 min", "10 min", "15 min", "30 min", "1 hour", "2 hours", "4 hours", "Day", "Week", "Month"};
input agperiod3 = {"1 min", "2 min", "3 min", "5 min", default "10 min", "15 min", "30 min", "1 hour", "2 hours", "4 hours", "Day", "Week", "Month"};
input agperiod4 = {"1 min", "2 min", "3 min", "5 min", "10 min", "15 min", default "30 min", "1 hour", "2 hours", "4 hours", "Day", "Week", "Month"};
input agperiod5 = {"1 min", "2 min", "3 min", "5 min", "10 min", "15 min", "30 min", "1 hour", "2 hours", default "4 hours", "Day", "Week", "Month"};

def displace = 0;
input paintCandles = yes;
input show_ema_cloud = yes;

#Current Period
plot AvgExp = ExpAverage(price[-displace], length);
AvgExp.SetStyle(Curve.SHORT_DASH);
def UPC1 = AvgExp > AvgExp[1];
def DNC1 = AvgExp < AvgExp[1];

plot AvgExp2 = ExpAverage(price[-displace], length2);
AvgExp2.SetStyle(Curve.SHORT_DASH);
def UPC2 = AvgExp2 > AvgExp2[1];
def DNC2 = AvgExp2 < AvgExp2[1];

def Below = AvgExp < AvgExp2;
def Spark = UPC1 + UPC2 + Below;

def UPEMA = AvgExp[1] < AvgExp;
def DOWNEMA = AvgExp[1] > AvgExp;
AvgExp.AssignValueColor(if UPEMA then Color.LIGHT_GREEN else if DOWNEMA then Color.RED else Color.YELLOW);

def UPEMA2 = AvgExp2[1] < AvgExp2;
def DOWNEMA2 = AvgExp2[1] > AvgExp2;
AvgExp2.AssignValueColor(if UPEMA2 then Color.LIGHT_GREEN else if DOWNEMA2 then Color.RED else Color.YELLOW);

AddCloud(if show_ema_cloud and (AvgExp2 > AvgExp) then AvgExp2 else Double.NaN, AvgExp, Color.LIGHT_RED, Color.CURRENT);
AddCloud(if show_ema_cloud and (AvgExp > AvgExp2) then AvgExp else Double.NaN, AvgExp2, Color.LIGHT_GREEN, Color.CURRENT);

#Agperiod1
def avg = ExpAverage(close(period = agperiod1), length);
def height = avg - avg[length];

def avg2 = ExpAverage(close(period = agperiod1), length2);
def height2 = avg2 - avg2[length2];

def UP = avg > avg2;
def DOWN = avg < avg2;

def R1UP = avg > avg[1];
def R1DN = avg < avg[1];
def R2UP = avg2 > avg2[1];
def R2DN = avg2 < avg2[1];

#Agperiod2
def avg3 = ExpAverage(close(period = agperiod2), length);
def height3 = avg3 - avg3[length];

def avg4 = ExpAverage(close(period = agperiod2), length2);
def height4 = avg4 - avg4[length2];

def UP2 = avg3 > avg4;
def DOWN2 = avg3 < avg4;

def R3UP = avg3 > avg3[1];
def R3DN = avg3 < avg3[1];
def R4UP = avg4 > avg4[1];
def R4DN = avg4 < avg4[1];

#Agperiod3
def avg5 = ExpAverage(close(period = agperiod3), length);
def height5 = avg5 - avg5[length];

def avg6 = ExpAverage(close(period = agperiod3), length2);
def height6 = avg6 - avg6[length2];

def UP3 = avg5 > avg6;
def DOWN3 = avg5 < avg6;

def R5UP = avg5 > avg5[1];
def R5DN = avg5 < avg5[1];
def R6UP = avg6 > avg6[1];
def R6DN = avg6 < avg6[1];

#Agperiod4
def avg7 = ExpAverage(close(period = agperiod4), length);
def height7 = avg7 - avg7[length];

def avg8 = ExpAverage(close(period = agperiod4), length2);
def height8 = avg8 - avg8[length2];

def UP4 = avg7 > avg8;
def DOWN4 = avg7 < avg8;

def R7UP = avg7 > avg7[1];
def R7DN = avg7 < avg7[1];
def R8UP = avg8 > avg8[1];
def R8DN = avg8 < avg8[1];

#Agperiod5
def avg9 = ExpAverage(close(period = agperiod5), length);
def height9 = avg9 - avg9[length];

def avg10 = ExpAverage(close(period = agperiod5), length2);
def height10 = avg10 - avg10[length2];

def UP5 = avg9 > avg10;
def DOWN5 = avg9 < avg10;

def R9UP = avg9 > avg9[1];
def R9DN = avg9 < avg9[1];
def R10UP = avg10 > avg10[1];
def R10DN = avg10 < avg10[1];

def Long_Only = UP + UP2 + UP3 + UP4 + UP5;
def Short_Only = DOWN + DOWN2 + DOWN3 + DOWN4 + DOWN5;
def Consensus_Bias = Long_Only - Short_Only;

def RUP = UPC1 + UPC2 + R1UP + R2UP + R3UP + R4UP + R5UP + R6UP + R7UP + R8UP + R9UP + R10UP;
def RDN = DNC1 + DNC2 + R1DN + R2DN + R3DN + R4DN + R5DN + R6DN + R7DN + R8DN + R9DN + R10DN;
def ConsensusR = RUP - RDN;

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

AddLabel(yes, Concat("MAMA: ", Concat("",
if MAMA > FAMA then "Bull" else "Bear")),

if MAMA > FAMA then createColor(33,145,72) else Color.RED);

##################################
plot C3_MF_Line = (MAMA + FAMA) / 2;
C3_MF_Line.SetPaintingStrategy(PaintingStrategy.LINE);
C3_MF_Line.SetLineWeight(3);

def direction = if ConsensusR > Consensus_Bias then 1 else if ConsensusR < Consensus_Bias then -1 else 0;
C3_MF_Line.AssignValueColor(if paintCandles and ((direction == 1) and (price > C3_MF_Line)) then Color.GREEN else if paintCandles and ((direction == -1) and (price < C3_MF_Line)) then Color.RED else Color.GRAY);


# ====================MTF ===================
# ============================================================
def Price2Ag1 = hl2(period = agperiod1);
def Price2Ag2 = hl2(period = agperiod2);
def Price2Ag3 = hl2(period = agperiod3);
def Price2Ag4 = hl2(period = agperiod4);
def Price2Ag5 = hl2(period = agperiod5);


def MAMAagg1 = Ehler_MAMA(Price2Ag1, FastLimit, SlowLimit).MAMA;
def FAMAagg1 = Ehler_MAMA(Price2Ag1, FastLimit, SlowLimit).FAMA;
def MAMAagg2 = Ehler_MAMA(Price2Ag2, FastLimit, SlowLimit).MAMA;
def FAMAagg2 = Ehler_MAMA(Price2Ag2, FastLimit, SlowLimit).FAMA;
def MAMAagg3 = Ehler_MAMA(Price2Ag3, FastLimit, SlowLimit).MAMA;
def FAMAagg3 = Ehler_MAMA(Price2Ag3, FastLimit, SlowLimit).FAMA;
def MAMAagg4 = Ehler_MAMA(Price2Ag4, FastLimit, SlowLimit).MAMA;
def FAMAagg4 = Ehler_MAMA(Price2Ag4, FastLimit, SlowLimit).FAMA;
def MAMAagg5 = Ehler_MAMA(Price2Ag5, FastLimit, SlowLimit).MAMA;
def FAMAagg5 = Ehler_MAMA(Price2Ag5, FastLimit, SlowLimit).FAMA;



def C3_MF_LineAgg1 = (MAMAagg1 + FAMAagg1) / 2;
def C3_MF_LineAgg2 = (MAMAagg2 + FAMAagg2) / 2;
def C3_MF_LineAgg3 = (MAMAagg3 + FAMAagg3) / 2;
def C3_MF_LineAgg4 = (MAMAagg4 + FAMAagg4) / 2;
def C3_MF_LineAgg5 = (MAMAagg5 + FAMAagg5) / 2;


def C3_MF_UPAgg1 = C3_MF_LineAgg1 > C3_MF_LineAgg1[1];
def C3_MF_DNAgg1 = C3_MF_LineAgg1 < C3_MF_LineAgg1[1];
def C3_MF_UPAgg2 = C3_MF_LineAgg2 > C3_MF_LineAgg2[1];
def C3_MF_DNAgg2 = C3_MF_LineAgg2 < C3_MF_LineAgg2[1];
def C3_MF_UPAgg3 = C3_MF_LineAgg3 > C3_MF_LineAgg3[1];
def C3_MF_DNAgg3 = C3_MF_LineAgg3 < C3_MF_LineAgg3[1];
def C3_MF_UPAgg4 = C3_MF_LineAgg4 > C3_MF_LineAgg4[1];
def C3_MF_DNAgg4 = C3_MF_LineAgg4 < C3_MF_LineAgg4[1];
def C3_MF_UPAgg5 = C3_MF_LineAgg5 > C3_MF_LineAgg5[1];
def C3_MF_DNAgg5 = C3_MF_LineAgg5 < C3_MF_LineAgg5[1];

def MF_UP1 = FAMAagg1 < MAMAagg1;
def MF_DN1 = FAMAagg1 > MAMAagg1;
def MF_UP2 = FAMAagg2 < MAMAagg2;
def MF_DN2 = FAMAagg2 > MAMAagg2;
def MF_UP3 = FAMAagg3 < MAMAagg3;
def MF_DN3 = FAMAagg3 > MAMAagg3;
def MF_UP4 = FAMAagg4 < MAMAagg4;
def MF_DN4 = FAMAagg4 > MAMAagg4;
def MF_UP5 = FAMAagg5 < MAMAagg5;
def MF_DN5 = FAMAagg5 > MAMAagg5;


def MFUP = MF_UP1 and MF_UP2 and MF_UP3 and MF_UP4 and MF_UP5;
def MFDN = MF_DN1 and MF_DN2 and MF_DN3 and MF_DN4 and MF_DN5;

#EMA's
input length8 = 10;
input length9 = 35;


plot AvgExp8 = ExpAverage(price[-displace], length8);
plot AvgExp9 = ExpAverage(price[-displace], length9);

def UPD = AvgExp8[1] < AvgExp8;
AvgExp8.SetStyle(Curve.SHORT_DASH);
#AvgExp8.SetLineWeight(1);
def UPW = AvgExp9[1] < AvgExp9;
AvgExp9.SetStyle(Curve.SHORT_DASH);
#AvgExp9.SetLineWeight(1);


AvgExp8.AssignValueColor(if UPEMA then Color.LIGHT_GREEN else if DOWNEMA then Color.RED else Color.YELLOW);
AvgExp9.AssignValueColor(if UPEMA2 then Color.LIGHT_GREEN else if DOWNEMA2 then Color.RED else Color.YELLOW);

AddCloud(if show_ema_cloud and (AvgExp9 > AvgExp8) then AvgExp9 else Double.NaN, AvgExp8, Color.LIGHT_RED, Color.CURRENT);
AddCloud(if show_ema_cloud and (AvgExp8 > AvgExp9) then AvgExp8 else Double.NaN, AvgExp9, Color.LIGHT_GREEN, Color.CURRENT);

def UP8 = UPEMA and UPEMA2;
def DOWN8 = DOWNEMA and DOWNEMA2;
def priceColor8 = if UP8 then 1
                 else if DOWN8 then -1
                 else 0;

def MaxTimeAvg = ExpAverage(close(period = agperiod5), length8);
def MaxTimeUp = MaxTimeAvg > MaxTimeAvg[1];
def MaxTimeDown = MaxTimeAvg < MaxTimeAvg[1];

### MACDBB

input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_BandLength = 15;
input MACDBB_NumDev = 1.0;

def MACDBB_Data = MACD(fastLength = MACDBB_FastLength, slowLength = MACDBB_SlowLength, MACDLength = 5);

def MACDBB_Upper = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;

def MACDBB_Lower = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                             Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;


def MACDBB_Midline = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength,
                                               Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).MidLine;


def MACDBB_Line = MACDBB_Data;

def B4Long =  MACDBB_Line > MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper
    or MACDBB_Line < MACDBB_Line[1] and MACDBB_Line > MACDBB_Upper;

def B4Short =  MACDBB_Line < MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower
    or MACDBB_Line > MACDBB_Line[1] and MACDBB_Line < MACDBB_Lower;
# ===========================================================
# ===========================================================================
def Longarrow = Long_Only > Short_Only and RUP > RDN and  C3_MF_UPAgg1 and C3_MF_UPAgg2 and C3_MF_UPAgg3 and C3_MF_UPAgg4 and C3_MF_UPAgg5 and  MFUP > MFDN and ((UP5 == 1)) and (Consensus_Bias > 0) AND MaxTimeUp and B4Long;

def ShortArrow =  Long_Only < Short_Only and RUP < RDN and C3_MF_DNAgg1 and C3_MF_DNAgg2 and C3_MF_DNAgg3 and C3_MF_DNAgg4 and C3_MF_DNAgg5 and MFUP < MFDN and ((DOWN5) and (Consensus_Bias < 0) and MaxTimeDown and B4short);
# ========================================================
# =======================================================================
plot buySCA = Longarrow; #AvgExp crosses above AvgExp2 and RUP and MaxTimeUp and long_Only and C3_MF_UPAgg1 and C3_MF_UPAgg2 and C3_MF_UPAgg3 and C3_MF_UPAgg4 and C3_MF_UPAgg5 ; # and Mf_UP1 and MF_UP2 and MF_UP3 and MF_UP4 and MF_UP5 and MF_UP6 and((UP6 == 1) and (Consensus_Bias > 0)) and maxTimeUp ;#highest time expup #direction crosses above 0;
buySCA.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
buySCA.SetDefaultColor(CreateColor(56, 223, 153));
buySCA.SetLineWeight(3);

plot sellSCA = ShortArrow;
 #AvgExp crosses below AvgExp2 and RDN and MaxTimeDown and Short_Only and C3_MF_DNAgg1 and C3_MF_DNAgg2 and C3_MF_DNAgg3 and C3_MF_DNAgg4 and C3_MF_DNAgg5;# and MF_DN1 and MF_DN2 and MF_DN3 and MF_DN4 and MF_DN5 and MF_DN6 and ((DOWN6) and (Consensus_Bias < 0));  #HighestTime frame EMA down #direction crosses below 0;
sellSCA.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN );
sellSCA.setdefaultColor(color.RED);
sellSCA.setlineWeight(3);

AssignPriceColor(if paintCandles then if direction == 1 then Color.GREEN else if direction == -1 then Color.RED else Color.GRAY else Color.CURRENT);

AddLabel(yes, if (Spark == 3) then "SPARK UP = " + Round(Spark, 1) else if (Spark == 0) then  "SPARK DOWN = " + Round(Spark, 1) else "SPARK = " + Round(Spark, 1), if (Spark == 3) then Color.YELLOW else if ((Spark == 2) and (AvgExp > AvgExp2)) then createColor(33,145,72) else if (Spark == 0) then Color.RED else Color.GRAY);

AddLabel(yes, if ((UP5 == 1) and (Consensus_Bias > 0)) then " SCALP_LONG " else if ((DOWN5) and (Consensus_Bias < 0)) then " SCALP_SHORT " else " CHOP ", if ((Consensus_Bias > 0) and (UP5 == 1)) then createColor(33,145,72) else if ((Consensus_Bias < 0) and (DOWN5 == 1)) then Color.RED else Color.GRAY);

AddLabel(yes, if (ConsensusR > 0) then " LONG BIAS = %" + Round((ConsensusR / 14) * 100, 1) + " " else if (ConsensusR < 0) then  " SHORT BIAS = %" + Round(((ConsensusR * -1) / 14) * 100, 1) + " " else " CHOP =" + Round((ConsensusR / 14) * 100, 1) + " ", if (ConsensusR > 0) then createColor(33,145,72) else if (ConsensusR < 0) then Color.RED else Color.GRAY);

Alert(Longarrow, "long", Alert.BAR, Sound.DING);
Alert(ShortArrow, "short", Alert.BAR, Sound.DING);
Hi @RedToGreen I noticed in the code in post 1175 you modified you have a second set of AddCloud statements for separate Avg? compare statements and this causes the EMA clouds to be double painted and darker than just LIGHT_RED and LIGHT_GREEN, when both are true, is this something that matters and needs to be taken into account via different paint methods or is this just as expected that both will always be true? Here's the two sets of compares for you to view. I've viewed different tickers and different timeframes and so far have never seen a non-double paint view.
Thanks.

AddCloud(if show_ema_cloud and (AvgExp2 > AvgExp) then AvgExp2 else Double.NaN, AvgExp, Color.LIGHT_RED, Color.CURRENT);
AddCloud(if show_ema_cloud and (AvgExp > AvgExp2) then AvgExp else Double.NaN, AvgExp2, Color.LIGHT_GREEN, Color.CURRENT);

AddCloud(if show_ema_cloud and (AvgExp9 > AvgExp8) then AvgExp9 else Double.NaN, AvgExp8, Color.LIGHT_RED, Color.CURRENT);
AddCloud(if show_ema_cloud and (AvgExp8 > AvgExp9) then AvgExp8 else Double.NaN, AvgExp9, Color.LIGHT_GREEN, Color.CURRENT);
 
Hi @tosman!
The lower version contains the full code (not just the moving averages) and certain studies within the code will not work on SPX. I should be able to come up with a reasonable fix pretty quickly. I’m hoping to get back into the office tomorrow all being well. I’ll keep you posted @tosman.

PS: thanks to everyone for the well wishes while I was down. It was much appreciated!
Thanks @Christopher84 No hurry. Please take your time - get better first.
 
Hi @RedToGreen I noticed in the code in post 1175 you modified you have a second set of AddCloud statements for separate Avg? compare statements and this causes the EMA clouds to be double painted and darker than just LIGHT_RED and LIGHT_GREEN, when both are true, is this something that matters and needs to be taken into account via different paint methods or is this just as expected that both will always be true? Here's the two sets of compares for you to view. I've viewed different tickers and different timeframes and so far have never seen a non-double paint view.
Thanks.

AddCloud(if show_ema_cloud and (AvgExp2 > AvgExp) then AvgExp2 else Double.NaN, AvgExp, Color.LIGHT_RED, Color.CURRENT);
AddCloud(if show_ema_cloud and (AvgExp > AvgExp2) then AvgExp else Double.NaN, AvgExp2, Color.LIGHT_GREEN, Color.CURRENT);

AddCloud(if show_ema_cloud and (AvgExp9 > AvgExp8) then AvgExp9 else Double.NaN, AvgExp8, Color.LIGHT_RED, Color.CURRENT);
AddCloud(if show_ema_cloud and (AvgExp8 > AvgExp9) then AvgExp8 else Double.NaN, AvgExp9, Color.LIGHT_GREEN, Color.CURRENT);

Nice catch ;)

The code in post #1175 has been updated
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
368 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