已更新
THE 4TH DESK

Watermark + ATR + 4 EMA
A three-in-one overlay indicator combining a chart watermark, an ATR-based stop-loss reference, and a four-line EMA ribbon — each independently configurable and toggleable.
Watermark
Displays the current symbol, exchange prefix, timeframe, and (optionally) percentage change in a customizable table anchored to any corner or edge of the chart. Includes an editable signature/branding field, adjustable text sizes, and a custom color with transparency support.
ATR Value Table
Calculates Average True Range (length and smoothing method both configurable — RMA, SMA, EMA, or WMA) multiplied by a user-defined multiplier, useful for setting stop-loss distances. Shown in its own bordered table, positioned and styled independently from the watermark.
4 EMA Ribbon
Plots four exponential moving averages (default periods: 13, 34, 55, 200) on the price chart, each with its own configurable length and color — useful for trend identification and dynamic support/resistance.
All three components have their own input group in the settings panel (Watermark / ATR / 4 EMA), so you can enable, disable, or restyle each piece independently without affecting the others.
A three-in-one overlay indicator combining a chart watermark, an ATR-based stop-loss reference, and a four-line EMA ribbon — each independently configurable and toggleable.
Watermark
Displays the current symbol, exchange prefix, timeframe, and (optionally) percentage change in a customizable table anchored to any corner or edge of the chart. Includes an editable signature/branding field, adjustable text sizes, and a custom color with transparency support.
ATR Value Table
Calculates Average True Range (length and smoothing method both configurable — RMA, SMA, EMA, or WMA) multiplied by a user-defined multiplier, useful for setting stop-loss distances. Shown in its own bordered table, positioned and styled independently from the watermark.
4 EMA Ribbon
Plots four exponential moving averages (default periods: 13, 34, 55, 200) on the price chart, each with its own configurable length and color — useful for trend identification and dynamic support/resistance.
All three components have their own input group in the settings panel (Watermark / ATR / 4 EMA), so you can enable, disable, or restyle each piece independently without affecting the others.
版本注释
What changed in this update:Added an individual on/off checkbox for each of the four EMA lines in the "4 EMA" settings group.
Four new inputs: showEma1, showEma2, showEma3, showEma4 — each a checkbox, defaulting to checked (visible).
Each checkbox sits on the same settings row as its corresponding EMA length input (using inline), so in the panel it reads as a compact [✓] EMA-1: 13 rather than two separate rows.
The four plot() calls at the bottom were updated from plotting the raw EMA values (pema1, pema2, etc.) to a conditional: showEmaN ? pemaN : na. Unchecking a box now hides just that line — the calculation still runs in the background, but nothing is drawn.
No changes to the watermark or ATR sections — they're untouched and independent of this.
版本注释
What changed in this update:Added three master on/off toggles — one for each major section of the indicator — in a new "Display" settings group at the top of the settings panel:
Show Watermark (showWatermark) — when checked, the watermark table populates normally. When unchecked, table.clear() wipes its cells instead, so the watermark disappears from the chart entirely.
Show ATR table (showATR) — the ATR table logic now always clears first on the last bar, then only redraws its cell if this toggle is on. Unchecked, the table stays empty.
Show EMAs (showEMAs) — added as an additional condition (showEMAs and showEmaN) alongside each EMA's existing individual checkbox, so it works as a master switch layered on top of the four per-line toggles you already had.
Each toggle is scoped only to its own section — turning off the watermark doesn't affect the ATR table or EMA lines, and so on. The individual EMA-1 through EMA-4 checkboxes still function as before whenever the "Show EMAs" master toggle is on.
No other logic (calculations, positions, colors, timeframe handling) was touched — this update only adds the three new checkboxes and the conditions that respect them.
版本注释
What changed in this update — converting the indicator into a strategy:indicator(...) → strategy(...), adding default_qty_type=strategy.percent_of_equity, default_qty_value=100 so each trade sizes using 100% of equity by default.
New "Strategy" settings group with 5 inputs:
Enable long entries / Enable short entries — independent toggles for each trade direction.
Use ATR-based stop loss / take profit — toggle for automatic exits.
Stop loss (x ATR) — default 1.5, multiplies your existing ATR value to set the stop distance.
Take profit (x ATR) — default 3.0, multiplies ATR to set the target distance.
New entry logic:
Longs open via strategy.entry("Long", strategy.long) whenever showCloseAbove fires — the same trend-filtered signal (close breaks above the selected EMA and price is above EMA-4) that already colors candles green.
Shorts open via strategy.entry("Short", strategy.short) on the mirrored showCloseBelow signal.
No separate flattening code was needed — Pine strategies automatically close/reverse a position when an opposite-direction entry fires.
New exit logic:
When the ATR toggle is on, strategy.exit() sets stop and limit prices as close ± atrVal × multiplier for both long and short positions, reusing the ATR calculation your indicator already had — no duplicate ATR logic was added.
版本注释
What changed in this update — converting the indicator into a strategy:indicator(...) → strategy(...), adding default_qty_type=strategy.percent_of_equity, default_qty_value=100 so each trade sizes using 100% of equity by default.
New "Strategy" settings group with 5 inputs:
Enable long entries / Enable short entries — independent toggles for each trade direction.
Use ATR-based stop loss / take profit — toggle for automatic exits.
Stop loss (x ATR) — default 1.5, multiplies your existing ATR value to set the stop distance.
Take profit (x ATR) — default 3.0, multiplies ATR to set the target distance.
New entry logic:
Longs open via strategy.entry("Long", strategy.long) whenever showCloseAbove fires — the same trend-filtered signal (close breaks above the selected EMA and price is above EMA-4) that already colors candles green.
Shorts open via strategy.entry("Short", strategy.short) on the mirrored showCloseBelow signal.
No separate flattening code was needed — Pine strategies automatically close/reverse a position when an opposite-direction entry fires.
New exit logic:
When the ATR toggle is on, strategy.exit() sets stop and limit prices as close ± atrVal × multiplier for both long and short positions, reusing the ATR calculation your indicator already had — no duplicate ATR logic was added.
版本注释
What changed in this update — converting the indicator into a strategy:indicator(...) → strategy(...), adding default_qty_type=strategy.percent_of_equity, default_qty_value=100 so each trade sizes using 100% of equity by default.
New "Strategy" settings group with 5 inputs:
Enable long entries / Enable short entries — independent toggles for each trade direction.
Use ATR-based stop loss / take profit — toggle for automatic exits.
Stop loss (x ATR) — default 1.5, multiplies your existing ATR value to set the stop distance.
Take profit (x ATR) — default 3.0, multiplies ATR to set the target distance.
New entry logic:
Longs open via strategy.entry("Long", strategy.long) whenever showCloseAbove fires — the same trend-filtered signal (close breaks above the selected EMA and price is above EMA-4) that already colors candles green.
Shorts open via strategy.entry("Short", strategy.short) on the mirrored showCloseBelow signal.
No separate flattening code was needed — Pine strategies automatically close/reverse a position when an opposite-direction entry fires.
New exit logic:
When the ATR toggle is on, strategy.exit() sets stop and limit prices as close ± atrVal × multiplier for both long and short positions, reusing the ATR calculation your indicator already had — no duplicate ATR logic was added.
版本注释
What changed in this update — converting the indicator into a strategy:indicator(...) → strategy(...), adding default_qty_type=strategy.percent_of_equity, default_qty_value=100 so each trade sizes using 100% of equity by default.
New "Strategy" settings group with 5 inputs:
Enable long entries / Enable short entries — independent toggles for each trade direction.
Use ATR-based stop loss / take profit — toggle for automatic exits.
Stop loss (x ATR) — default 1.5, multiplies your existing ATR value to set the stop distance.
Take profit (x ATR) — default 3.0, multiplies ATR to set the target distance.
New entry logic:
Longs open via strategy.entry("Long", strategy.long) whenever showCloseAbove fires — the same trend-filtered signal (close breaks above the selected EMA and price is above EMA-4) that already colors candles green.
Shorts open via strategy.entry("Short", strategy.short) on the mirrored showCloseBelow signal.
No separate flattening code was needed — Pine strategies automatically close/reverse a position when an opposite-direction entry fires.
New exit logic:
When the ATR toggle is on, strategy.exit() sets stop and limit prices as close ± atrVal × multiplier for both long and short positions, reusing the ATR calculation your indicator already had — no duplicate ATR logic was added.
版本注释
The changes add a custom timeframe filter specifically for the EMA-break candle colors.What was added
1. “Use custom timeframe” switch
You now have:
Use custom timeframe: ON/OFF
OFF → EMA-break candles behave exactly as before and are colored on the current chart timeframe.
ON → candle coloring is restricted to the timeframe you specify.
2. “Color candles timeframe”
You can enter a custom TradingView timeframe, for example:
3 → 3 minutes
5 → 5 minutes
15 → 15 minutes
45 → 45 minutes
60 → 1 hour
90 → 90 minutes
120 → 2 hours
240 → 4 hours
D → Daily
W → Weekly
3. The EMA-break calculation was not changed
Your existing logic remains:
Select EMA-1, EMA-2, EMA-3, or EMA-4.
Detect only the first candle that closes across the selected EMA.
Green for a qualifying close above.
Red for a qualifying close below.
EMA-4 remains the trend filter.
4. The filter only controls candle coloring
The key new logic is effectively:
showBreakOnTimeframe = not useBreakTimeframe or chartTfSeconds == breakTfSeconds
Then the color is only applied when that condition is true.
So, for example:
Custom timeframe = 45 minutes
Chart EMA-break colors
5m ❌ Hidden
15m ❌ Hidden
30m ❌ Hidden
45m ✅ Shown
1H ❌ Hidden
4H ❌ Hidden
Daily ❌ Hidden
Important distinction
This feature does not calculate the EMA on the selected custom timeframe.
For example, if you're on a 45-minute chart and select 45, the normal 45-minute EMAs are used and the break candles are colored.
If you're on a 5-minute chart and select 45, the 5-minute EMA-break calculations still run, but their candle colors are hidden because you're not viewing the 45-minute chart.
So the feature is essentially:
“Only show my EMA-break candle colors when I am looking at this specific timeframe.”
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。