top of page

Thinkscript Library

Public·1 member

Multi-Period EMA Cloud — Trend Drop


The Multi-Period EMA Cloud stacks three EMA-pair clouds (fast, mid, macro) into one overlay so trend health is visible at a glance instead of cluttering the chart with raw moving averages. When all three clouds agree, you get an unambiguous "full bull" or "full bear" regime — when they disagree, you know to size down.


## What it does

- Plots four EMAs (default 8 / 21 / 55 / 200) and shades three clouds between them.

- Cloud color flips green/red on each pair's cross — fast = short-term momentum, mid = swing trend, macro = regime.

- Full-stack regime label in the corner shows FULL BULL / FULL BEAR / MIXED with the current EMA lengths.

- Optional background tint highlights bars where all three clouds agree.

- Alerts on full-stack flips and on the short-term (EMA1/EMA2) cross.


## Recommended settings

- EMA lengths: 8 / 21 / 55 / 200 (default)

- Source: close

- Show all three clouds: on

- Regime label: on

- Background tint: on

- Faster scalping variant: 5 / 13 / 34 / 89

- Slower swing variant: 10 / 30 / 100 / 200


## Ideal timeframe

Works on any timeframe; the default 8/21/55/200 stack is tuned for 15m–1D charts.


## How to use

Treat the clouds as a regime filter rather than a signal generator. When the macro (3-4) cloud is green and the mid (2-3) cloud is also green, only take long setups — let the fast (1-2) cloud time entries on pullbacks into it. Counter-trend trades become legitimate only when the macro cloud flips or when the mid cloud loses agreement. The full-stack alert is your "trend just confirmed in earnest" signal; the short-term flip alert is your early-warning that the underlying momentum is rotating.


## thinkScript code

```

# ─────────────────────────────────────────────

# │ MarketFragments.com | DNA & Market │

# │ info@marketfragments.com │

# │ www.marketfragments.com │

# ─────────────────────────────────────────────

# Time →

# │

# █ █ █│ █

# █ █ █ │ █ █

# █ █ █ │ █ █ █ ╭─╮

# █ █ █ │ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ █ █╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ ╰─────╯

# ──────┴──────────────────────────────────────────────────────────────

# T1 T2 T3 T4 T5 T6

#

# Multi-Period EMA Cloud

# Three stacked EMA-pair clouds (fast/mid/slow) give a layered, color-coded read

# on short, intermediate, and macro trend in a single overlay. Cloud color flips

# when the faster EMA crosses the slower one within the pair; full bull / full

# bear regime is signaled when ALL three pairs agree.

# Free for non-commercial use. (c) MarketFragments.com


declare upper;


input ema1Length = 8;

input ema2Length = 21;

input ema3Length = 55;

input ema4Length = 200;

input showCloud12 = yes;

input showCloud23 = yes;

input showCloud34 = yes;

input showLabel = yes;

input bgTint = yes;

input src = close;


def ema1 = ExpAverage(src, ema1Length);

def ema2 = ExpAverage(src, ema2Length);

def ema3 = ExpAverage(src, ema3Length);

def ema4 = ExpAverage(src, ema4Length);


plot EMA1 = ema1;

plot EMA2 = ema2;

plot EMA3 = ema3;

plot EMA4 = ema4;

EMA1.SetDefaultColor(Color.WHITE);

EMA2.SetDefaultColor(Color.YELLOW);

EMA3.SetDefaultColor(Color.ORANGE);

EMA4.SetDefaultColor(Color.MAGENTA);

EMA1.SetLineWeight(1);

EMA2.SetLineWeight(2);

EMA3.SetLineWeight(2);

EMA4.SetLineWeight(3);


def cloud12Bull = ema1 > ema2;

def cloud23Bull = ema2 > ema3;

def cloud34Bull = ema3 > ema4;


# Cloud 1-2 (fast)

AddCloud(if showCloud12 and cloud12Bull then ema1 else Double.NaN,

if showCloud12 and cloud12Bull then ema2 else Double.NaN,

CreateColor(0, 180, 60), CreateColor(0, 180, 60));

AddCloud(if showCloud12 and !cloud12Bull then ema2 else Double.NaN,

if showCloud12 and !cloud12Bull then ema1 else Double.NaN,

CreateColor(200, 40, 40), CreateColor(200, 40, 40));


# Cloud 2-3 (mid)

AddCloud(if showCloud23 and cloud23Bull then ema2 else Double.NaN,

if showCloud23 and cloud23Bull then ema3 else Double.NaN,

CreateColor(0, 120, 40), CreateColor(0, 120, 40));

AddCloud(if showCloud23 and !cloud23Bull then ema3 else Double.NaN,

if showCloud23 and !cloud23Bull then ema2 else Double.NaN,

CreateColor(150, 30, 30), CreateColor(150, 30, 30));


# Cloud 3-4 (macro)

AddCloud(if showCloud34 and cloud34Bull then ema3 else Double.NaN,

if showCloud34 and cloud34Bull then ema4 else Double.NaN,

CreateColor(0, 70, 25), CreateColor(0, 70, 25));

AddCloud(if showCloud34 and !cloud34Bull then ema4 else Double.NaN,

if showCloud34 and !cloud34Bull then ema3 else Double.NaN,

CreateColor(90, 20, 20), CreateColor(90, 20, 20));


def allBull = cloud12Bull and cloud23Bull and cloud34Bull;

def allBear = !cloud12Bull and !cloud23Bull and !cloud34Bull;

def regime = if allBull then 1 else if allBear then -1 else 0;

def regimePrev = regime[1];


AssignBackgroundColor(if bgTint and regime == 1 then CreateColor(0, 35, 15)

else if bgTint and regime == -1 then CreateColor(40, 10, 10)

else Color.CURRENT);


AddLabel(showLabel,

"EMA Cloud: " +

(if regime == 1 then "FULL BULL"

else if regime == -1 then "FULL BEAR"

else "MIXED") +

" [" + ema1Length + "/" + ema2Length + "/" + ema3Length + "/" + ema4Length + "]",

if regime == 1 then Color.GREEN

else if regime == -1 then Color.RED

else Color.GRAY);


Alert(regime == 1 and regimePrev != 1, "EMA Cloud: Full Bull Stack", Alert.BAR, Sound.Ding);

Alert(regime == -1 and regimePrev != -1, "EMA Cloud: Full Bear Stack", Alert.BAR, Sound.Bell);

Alert(cloud12Bull and !cloud12Bull[1], "EMA Cloud: Short-Term Bull Flip (EMA1 > EMA2)", Alert.BAR, Sound.Chimes);

Alert(!cloud12Bull and cloud12Bull[1], "EMA Cloud: Short-Term Bear Flip (EMA1 < EMA2)", Alert.BAR, Sound.Chimes);

```


Drop your tweaks, screenshots, and questions below — that's how the library gets better.


1 View
Brain with financial data analysis.

Inquiries at :

Important Risk Notice: Trading involves substantial risk of loss. This is educational content only—not advice. Full details here  ------------>  

Proceed only if you're prepared.

tel#: (843) 321-8514

bottom of page