OPEN-SOURCE SCRIPT

Watermark with dynamic variables [BM]

█ OVERVIEW

This indicator allows users to add highly customizable watermark messages to their charts. Perfect for branding, annotation, or displaying dynamic chart information, this script offers advanced customization options including dynamic variables, text formatting, and flexible positioning.


█ CONCEPTS

Watermarks are overlay messages on charts. This script introduces placeholders — special keywords wrapped in % signs — that dynamically replace themselves with chart-related data. These watermarks can enhance charts with context, timestamps, or branding.


█ FEATURES

  • Dynamic Variables: Replace placeholders with real-time data such as bar index, timestamps, and more.
  • Advanced Customization: Modify text size, color, background, and alignment.
  • Multiple Messages: Add up to four independent messages per group, with two groups supported (A and B).
  • Positioning Options: Place watermarks anywhere on the chart using predefined locations.
  • Timezone Support: Display timestamps in a preferred timezone with customizable formats.



█ INPUTS

The script offers comprehensive input options for customization. Each Watermark (A and B) contains identical inputs for configuration.

快照

Watermark settings are divided into two levels:

Watermark-Level Settings

These settings apply to the entire watermark group (A/B):
  • Show Watermark: Toggle the visibility of the watermark group on the chart.
  • Position: Choose where the watermark group is displayed on the chart.
  • Reverse Line Order: Enable to reverse the order of the lines displayed in Watermark A.


Message-Level Settings

Each watermark contains up to four configurable messages. These messages can be independently customized with the following options:

  • Message Content: Enter the custom text to be displayed. You can include placeholders for dynamic data.
  • Text Size: Select from predefined sizes (Tiny, Small, Normal, Large, Huge) or specify a custom size.
  • Text Alignment and Colors:
    - Adjust the alignment of the text (Left, Center, Right).
    - Set text and background colors for better visibility.
  • Format Time: Enable time formatting for this watermark message and configure the format and timezone. The settings for each message include message content, text size, alignment, and more. Please refer to Formatting dates and times for more details on valid formatting tokens.



█ PLACEHOLDERS

Placeholders are special keywords surrounded by % signs, which the script dynamically replaces with specific chart-related data. These placeholders allow users to insert dynamic content, such as bar information or timestamps, into watermark messages.
Below is the complete list of currently available placeholders:
bar_index, barstate.isconfirmed, barstate.isfirst, barstate.ishistory, barstate.islast, barstate.islastconfirmedhistory, barstate.isnew, barstate.isrealtime, chart.is_heikinashi, chart.is_kagi, chart.is_linebreak, chart.is_pnf, chart.is_range, chart.is_renko, chart.is_standard, chart.left_visible_bar_time, chart.right_visible_bar_time, close, dayofmonth, dayofweek, dividends.future_amount, dividends.future_ex_date, dividends.future_pay_date, earnings.future_eps, earnings.future_period_end_time, earnings.future_revenue, earnings.future_time, high, hl2, hlc3, hlcc4, hour, last_bar_index, last_bar_time, low, minute, month, ohlc4, open, second, session.isfirstbar, session.isfirstbar_regular, session.islastbar, session.islastbar_regular, session.ismarket, session.ispostmarket, session.ispremarket, syminfo.basecurrency, syminfo.country, syminfo.currency, syminfo.description, syminfo.employees, syminfo.expiration_date, syminfo.industry, syminfo.main_tickerid, syminfo.mincontract, syminfo.minmove, syminfo.mintick, syminfo.pointvalue, syminfo.prefix, syminfo.pricescale, syminfo.recommendations_buy, syminfo.recommendations_buy_strong, syminfo.recommendations_date, syminfo.recommendations_hold, syminfo.recommendations_sell, syminfo.recommendations_sell_strong, syminfo.recommendations_total, syminfo.root, syminfo.sector, syminfo.session, syminfo.shareholders, syminfo.shares_outstanding_float, syminfo.shares_outstanding_total, syminfo.target_price_average, syminfo.target_price_date, syminfo.target_price_estimates, syminfo.target_price_high, syminfo.target_price_low, syminfo.target_price_median, syminfo.ticker, syminfo.tickerid, syminfo.timezone, syminfo.type, syminfo.volumetype, ta.accdist, ta.iii, ta.nvi, ta.obv, ta.pvi, ta.pvt, ta.tr, ta.vwap, ta.wad, ta.wvad, time, time_close, time_tradingday, timeframe.isdaily, timeframe.isdwm, timeframe.isintraday, timeframe.isminutes, timeframe.ismonthly, timeframe.isseconds, timeframe.isticks, timeframe.isweekly, timeframe.main_period, timeframe.multiplier, timeframe.period, timenow, volume, weekofyear, year


█ HOW TO USE

1 — Add the Script:
  • Apply "Watermark with dynamic variables [BM]" to your chart from the TradingView platform.

2 — Configure Inputs:
  • Open the script settings by clicking the gear icon next to the script's name.
  • Customize visibility, message content, and appearance for Watermark A and Watermark B.

3 — Utilize Placeholders:
  • Add placeholders like %bar_index% or %timenow% in the "Watermark - Message" fields to display dynamic data.
  • Empty lines in the message box are reflected on the chart, allowing you to shift text up or down.
  • Using \n in the message box translates to a new line on the chart.

4 — Preview Changes:
  • Adjust settings and view updates in real-time on your chart.



█ EXAMPLES

Branding
DodgyDD's charts
快照
快照

Debugging
快照
快照

█ LIMITATIONS

  • Only supports variables defined within the script.
  • Limited to four messages per watermark.
  • Visual alignment may vary across different chart resolutions or zoom levels.
  • Placeholder parsing relies on correct input formatting.



█ NOTES

This script is designed for users seeking enhanced chart annotation capabilities. It provides tools for dynamic, customizable watermarks but is not a replacement for chart objects like text labels or drawings. Please ensure placeholders are properly formatted for correct parsing.

Additionally, this script can be a valuable tool for Pine Script developers during debugging. By utilizing dynamic placeholders, developers can display real-time values of variables and chart data directly on their charts, enabling easier troubleshooting and code validation.
dynamiceducationalPine utilitiesplaceholderstatisticsvariablewatermark

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?


更多:

免责声明