TradingView

Volatility Stop MTF

TradingView 已更新   
This is a multi-timeframe version of our Volatility Stop, an ATR-based trend detector that can be used as a stop.

► Timeframe selection
The higher timeframe can be selected using 3 different ways:
• By steps (60 min., 1D, 3D, 1W, 1M, 1Y).
• As a multiple of the current chart's resolution, which can be fractional, so 3.5 will work.
• Fixed.
Note that you can also use this indicator without the higher timeframe functionality. It will then behave as our normal Volatility Stop would.

► Stop breaches
Two modes of stop-breaching logic can be selected.
• In the default, Early Breach mode, the stop is considered breached when a bar at the chart's current resolution breaches the higher timeframe stop.
• You may also choose to calculate breaches on the higher timeframe information only.

Choosing the Early Breach mode has the advantage of generating faster exits. It will create a state of limbo where the stop has been breached but the Volatility Stop trend has not yet reversed. The impact of detecting earlier exits to minimize losses comes, as is usually the case, at the cost of a compromise: if the stop is breached early in a long trend, the indicator will then spend most of that trend in limbo. Sizeable portions of a trend can thus be missed.

A few options are provided when you use Early Breach mode:
• A red triangle can identify early breaches (default).
• You can color bars or the background to identify limbo states.
When in limbo, the color used to plot the indicator's line or shapes will always be darker.

► Alerts
Five pre-defined alerts are supplied:
• #1: On any trend change.
• #2: On changes into an uptrend.
• #3: On changes into a downtrend.
• #4: Only on breaches of the uptrend by the chart's bars (Early Breach mode). Will not trigger on a trend change.
• #5: Only on breaches of the downtrend by the chart's bars (Early Breach mode). Will not trigger on a trend change.
As usual, alerts should be configured to trigger Once Per Bar Close. When creating alerts, you will see a warning to the effect that potentially repainting code is used, even if the indicator's default non-repainting mode is active. The warning is normal.

► Other features
• You can color bars using the indicator's up/down state. When bars are colored, up bars are more brightly colored.
• The HTF line is non-repainting by default, but you can allow it to repaint.
• You can confirm the higher timeframe used by displaying it at a selectable distance from the last bar on the chart.
• Choice of 2 color themes.
• Choice of display as a line, circles, diamonds or arrows. The line can be used with the other shapes. If no line is required, set its thickness to zero.

Enjoy!



Look first. Then leap.

版本注释:
Fixed a typo.
版本注释:
v3

Updated Code
The code has been updated to use Pine Script™ v5. It follows the most recent recommendations from the Pine Script™ User Manual's Style Guide.


New Features
You can now configure the script's alerts to trigger in three different ways:
 1. Immediately, when the condition is detected. This will produce repainting alerts.
 2. On the bar's close, to avoid repainting.
 3. When the condition occurs for a delay that you specify. This allows you to protect yourself from repainting in a more granular fashion.

Using the new delay feature, you can create your alert from a 1H chart, but specify that it only trigger when its condition is continually true for 15 minutes, let's say. The delay is specified in the script's inputs, and will be included in the alert's message.

For Pine coders, this feature is implemented using the `secondsSince()` function from the recent Time library by PineCoders.

Get $15 worth of TradingView Coins for you and a friend: www.tradingview.com/share-your-love/

Read more about the new tools and features we're building for you: www.tradingview.com/blog/en/
开源脚本

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

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?