RedK TrendBeads: 3 x MA Crossover Signal with Preset Templates for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
CzO6HYN.png

Author Message:

RedK TrendBeads is a super simple 3 x Moving Average Crossover Signal (Long/Short/Break) script that provides a simple and effective way for traders to identify potential trading opportunities. By combining three moving averages and only exposing a simple signal, the script helps filter out noise and focus on the trend and the trade execution.

Background
===========
A 3 x Moving Average Crossover strategy is a popular trading method in technical analysis . It uses the relationship between a fast, medium, and slow moving averages to generate buy or sell signals.

The approach usually utilizes three moving averages to track the average price of a financial instrument over different time periods. By comparing the fast, medium, and slow moving averages, we can generates a signal to trade long or short

If the fast moving average crosses above the medium moving average and the medium moving average is above the slow moving average, we have a probability of an up-trend forming, and we generate a signal to go long. Conversely, if the fast moving average crosses below the medium moving average and the medium moving average is below the slow moving average, we have a probability of a down-trend forming, and we generate a signal to go short. When the moving averages are not in the right order (above or below each other), we have a trend break, usually on consolidation or base forming.

in TrendBeads, the fastest MA is called "Price Proxy MA" and will be used with a relatively short length to represent the price itself - then there are the Fast MA, Slow MA and a Filter MA (usually with the longest/slowest length) which is the main line that will be used to plot the TrendBeads - So the TrendBeads will represent the state of the other 3 Moving Average lines (Proxy, Fast and Slow) and how they are aligned - and it will also be common to use the Filter / Beads line itself as a main filter, i.e., take long positions only when the price action is above the Filter MA, and short positions only when the price is below the Filter MA.

So what is different with TrendBeads:
=====================================

Simplicity, No Clutter: I put this together to provide a super simple mechanism to track trend on the price chart without so much noise as i also wanted to have other top-chart indicators (like LadderTrader) - so TrendBeads only shows the "beads" on the chart - they act like "traffic lights" with little distracting information - Simplicity here was deliberately part if the idea

Presets, What others are Watching: The other feature I needed was the ability to track price action against "different sets" of Moving Averages quickly - for example, when executing short-term trades, I needed to use Moving Averages with shorter length and want to utilize my RSS_WMA MA type - but when assessing big breakout opportunities, I need to analyze price action against a different set of MA's with (usually) longer length and mainly SMA's (hint, The Minervini template) - This is where the built-in Preset Templates become very useful.

Having these preset templates quickly available (thru the dropdown in indicator settings) provides time saving, convenience and the confidence that we're looking at what other traders are using in their analysis - so not missing out on key-level breakouts or reversals


TrendBeads v1.0 includes the following 5 preset MA templates
======================================================

Preset 1 : RedK_1: 8RSS / 15RSS / 21RSS / 30SMA
Preset 2 : RedK_2: 5WMA / 10SMA / 20SMA / 40SMA
Preset 3 : SWNG_1: 7EMA / 21EMA / 30EMA / 50SMA
Preset 4 : SWNG_2: 10EMA / 21EMA / 50SMA / 100SMA
Preset 5 : SWNG_3: 10EMA / 21EMA / 100SMA / 200SMA

CODE:

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © RedKTrader
#indicator('RedK TrendBeads', shorttitle='K-TrendBeads v1.0', overlay=true, timeframe='', timeframe_gaps=false)
#// 3 MA-Line Ribbon on a slow MA filter line.. just a super simple set-up
#// updated this version of LazyLine() to reflect a regular WMA for length < 5
# Converted and mode by Sam4Cok@Samer800 - 02/2023

input BarColor       = no;
input ShowTrendCloud = no;
input UsePresets = no;#(false, title = "Use Presets?", inline = 'presets', group = grp_p)
input PresetOptions = {Default "8RSS / 15RSS / 21RSS / 30SMA",
                               "5WMA / 10SMA / 20SMA / 40SMA",
                               "7EMA / 21EMA / 30EMA / 50SMA",
                               "10EMA / 21EMA / 50SMA / 100SMA",
                               "10EMA / 21EMA / 100SMA / 200SMA"};
input Proxy_Src = close;        # 'Proxy Source'
input Proxy_Type   = {Default RSS_WMA, WMA, EMA, SMA, HMA};
input Proxy_Length = 8;         # 'Length'

input FastMa_Src    = close;      # 'Fast MA Source'
input FastMa_Type   = {Default RSS_WMA, WMA, EMA, SMA, HMA};
input FastMa_Length = 15;         # 'Length'

input SlowMa_Src    = close;      # 'Slow MA Source'
input SlowMa_Type   = {Default RSS_WMA, WMA, EMA, SMA, HMA};
input SlowMa_Length = 21;         # 'Length'

input Filter_Src    = close;       # 'Filter Source'
input Filter_Type    = {RSS_WMA, WMA, EMA, Default SMA, HMA};
input Filter_Length = 40;          # 'Length'

def na = Double.NaN;
#f_LazyLine(_data, _length) =>
script f_LazyLine {
    input _data = close;
    input _length = 10;
    def w1;
    def w2;
    def w3;
    def L1;
    def L2;
    def L3;
    def na = Double.NaN;
    def w = _length / 3;
    if _length > 4 {
        w2 = Round(w, 0);
        w1 = Round((_length - w2) / 2, 0);
        w3 = Floor((_length - w2) / 2);
        L1 = WMA(_data, w1);
        L2 = WMA(L1, w2);
        L3 = WMA(L2, w3);
    } else {
        w2 = na;
        w1 = na;
        w3 = na;
        L1 = na;
        L2 = na;
        L3 = WMA(_data, _length);
    }
    plot return = L3;
}
#f_getMA(source, length, type) =>
script f_getMA {
input source = close;
input length = 10;
input type = 5;
    def ma = if type == 1 then Average(source, length) else
             if type == 2 then ExpAverage(source, length) else
             if type == 3 then wma(source, length) else
             if type == 4 then HullMovingAvg(source, length) else f_LazyLine(source, length);
    plot return = ma;
}

#//f_UsePreset() =>   //function

def pset = if PresetOptions==PresetOptions."8RSS / 15RSS / 21RSS / 30SMA" then 1 else
           if PresetOptions==PresetOptions."5WMA / 10SMA / 20SMA / 40SMA" then 2 else
           if PresetOptions==PresetOptions."7EMA / 21EMA / 30EMA / 50SMA" then 3 else
           if PresetOptions==PresetOptions."10EMA / 21EMA / 50SMA / 100SMA" then 4 else 5;
def ProxyType = if Proxy_Type == Proxy_Type.SMA then 1 else
                if Proxy_Type == Proxy_Type.EMA then 2 else
                if Proxy_Type == Proxy_Type.WMA then 3 else
                if Proxy_Type == Proxy_Type.HMA then 4 else 5;

def FastType = if FastMa_Type == FastMa_Type.SMA then 1 else
               if FastMa_Type == FastMa_Type.EMA then 2 else
               if FastMa_Type == FastMa_Type.WMA then 3 else
               if FastMa_Type == FastMa_Type.HMA then 4 else 5;

def SlowType = if SlowMa_Type == SlowMa_Type.SMA then 1 else
               if SlowMa_Type == SlowMa_Type.EMA then 2 else
               if SlowMA_Type == SlowMa_Type.WMA then 3 else
               if SlowMA_Type == SlowMa_Type.HMA then 4 else 5;

def FilType = if Filter_Type == Filter_Type.SMA then 1 else
              if Filter_Type == Filter_Type.EMA then 2 else
              if Filter_Type == Filter_Type.WMA then 3 else
              if Filter_Type == Filter_Type.HMA then 4 else 5;

def iProxy_Src;
def iProxy_Length;
def iProxy_Type;
def iFast_Src;
def iFast_Length;
def iFast_Type;
def iSlow_Src;
def iSlow_Length;
def iSlow_Type;
def iFil_Src;
def iFil_Length;
def iFil_Type;

if UsePresets {
    if pset == 1 {
        iProxy_Src  = close;
        iProxy_Length = 8;
        iProxy_Type  = 5;
        iFast_Src   = close;
        iFast_Length  = 15;
        iFast_Type   = 5;
        iSlow_Src   = close;
        iSlow_Length  = 21;
        iSlow_Type   = 5;
        iFil_Src    = close;
        iFil_Length   = 30;
        iFil_Type    = 1;
    } else if pset == 2 {
        iProxy_Src  = close;
        iProxy_Length = 5 ;
        iProxy_Type  = 3;
        iFast_Src   = close;
        iFast_Length  = 10;
        iFast_Type   = 1;
        iSlow_Src   = close;
        iSlow_Length  = 20;
        iSlow_Type   = 1;
        iFil_Src    = close;
        iFil_Length   = 40;
        iFil_Type    = 1;
    } else if pset == 3 {
        iProxy_Src  = close;
        iProxy_Length = 7;
        iProxy_Type  = 2;
        iFast_Src   = close;
        iFast_Length  = 21;
        iFast_Type   = 2;
        iSlow_Src   = close;
        iSlow_Length  = 30;
        iSlow_Type   = 2;
        iFil_Src    = close;
        iFil_Length   = 50;
        iFil_Type    = 1;
    } else if pset == 4 {
        iProxy_Src  = close;
        iProxy_Length = 10;
        iProxy_Type  = 2;
        iFast_Src   = close;
        iFast_Length  = 21;
        iFast_Type   = 2;
        iSlow_Src   = close;
        iSlow_Length  = 50;
        iSlow_Type   = 1;
        iFil_Src    = close;
        iFil_Length   = 100;
        iFil_Type   = 1;
    } else {
        iProxy_Src  = close;
        iProxy_Length = 10;
        iProxy_Type  = 2;
        iFast_Src   = close;
        iFast_Length  = 21;
        iFast_Type   = 2;
        iSlow_Src   = close;
        iSlow_Length  = 100;
        iSlow_Type  = 1;
        iFil_Src    = close;
        iFil_Length   = 200;
        iFil_Type   = 1;}
    } else {
        iProxy_Src   = Proxy_Src;
        iProxy_Length= Proxy_Length;
        iProxy_Type  = ProxyType;
        iFast_Src    = FastMa_Src;
        iFast_Length = FastMa_Length;
        iFast_Type   = FastType;
        iSlow_Src    = SlowMa_Src;
        iSlow_Length = SlowMa_Length;
        iSlow_Type   = SlowType;
        iFil_Src     = Filter_Src;
        iFil_Length  = Filter_Length;
        iFil_Type    = FilType;
}
#// Calculation
def LL1     = f_getMA(iProxy_Src, iProxy_Length, iProxy_Type);
def LL2     = f_getMA(iFast_Src, iFast_Length, iFast_Type);
def LL3     = f_getMA(iSlow_Src, iSlow_Length, iSlow_Type);
def Filter  = f_getMA(iFil_Src, iFil_Length, iFil_Type);

def ProxyLine = LL1;    # "Proxy Line"
def FastMA = LL2;       # "Fast MA"
def SlowMA = LL3;       # "Slow MA",

def Mode_Long   = LL1 > LL2 and LL2 > LL3;
def Mode_Short  = LL1 < LL2 and LL2 < LL3;


def c_Filter  = if Mode_Long then 1 else
                if Mode_Short then -1 else 0;

plot FilterMA  = Filter;    # "Filter MA"
FilterMA.SetStyle(Curve.POINTS);
FilterMA.AssignValueColor(if Mode_Long then CreateColor(0,188,212) else
                          if Mode_Short then CreateColor(255,152,0) else Color.GRAY);

AddCloud(if ShowTrendCloud then ProxyLine else na,SlowMA, Color.DARK_GREEN, Color.DARK_RED);
AddCloud(if ShowTrendCloud then ProxyLine else na,FastMA, Color.DARK_GREEN, Color.DARK_RED);

def ExtUp = Mode_Long and LL1>Filter;
def Up    = LL1>Filter and LL1>SlowMA;
def ExtDn = Mode_Short and LL1<Filter;
def Dn    = LL1<Filter and LL1<SlowMA;

AssignPriceColor(if !BarColor then Color.CURRENT else
                 if ExtUp then Color.GREEN else
                 if Up    then Color.DARK_GREEN else
                 if ExtDn then Color.RED else
                 if Dn    then Color.DARK_RED else Color.GRAY);



#--- END CODE
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
611 Online
Create Post

Similar threads

Similar threads

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