アラート

alert #

Triggers an alert event when called during the real-time bar and an alert based on alert function events was previously created for the indicator or strategy through the “Create Alert” dialog box.

alert(message, freq)  void
引数 #
message (series string)アラートがトリガーされた時に送信されるメッセージ。必須の引数です。
freq (input string)トリガー頻度。可能な値は alert.freq_all (すべての関数呼び出しがアラートをトリガー), alert.freq_once_per_bar (バー内の最初の関数の呼び出しがアラートをトリガー), alert.freq_once_per_bar_close (リアルタイムバーでバーがクローズする際の最後のスクリプトの実行中に発生した場合のみアラートをトリガー) です。デフォルトは alert.freq_once_per_bar です。
#
//@version=5
indicator("`alert()` example", "", true)
ma = ta.sma(close, 14)
xUp = ta.crossover(close, ma)
if xUp
    // Trigger the alert the first time a cross occurs during the real-time bar.
    alert("Price (" + str.tostring(close) + ") crossed over MA (" + str.tostring(ma) +  ").", alert.freq_once_per_bar)
plot(ma)
plotchar(xUp, "xUp", "▲", location.top, size = size.tiny)
備考 #

ヘルプセンターでは、このようなアラートの作成方法を解説しています。
alertconditionとは異なり、alertの呼び出しは追加のplotとしてカウントされません。
関数の呼び出しは、グローバルスコープとローカルスコープの両方に配置できます。
関数の呼び出しはチャート上に何も表示しません。
‘freq‘ 引数は、それが使用されている関数の呼び出しのトリガー頻度にのみ影響します

関連 #

alertcondition

alertcondition #

アラート作成ダイアログで利用できるアラート条件を作成します。alertcondition は直接アラートを作成しない点にご注意ください。アラート作成ダイアログでより多くの選択肢を提供するのみです。また alertcondition の動作はチャートには表示されない点にもご注意ください。

alertcondition(condition, title, message)  void
引数 #
condition (series bool)アラートに用いられるブール値の系列。値が true の場合はアラートがトリガーされ、false の場合はアラートはトリガーされません。必須引数。
title (const string)アラート条件のタイトル。オプション引数。
message (const string)アラートが発生した時に表示するメッセージ。オプション引数。
#
alertcondition(close >= open, title='Alert on Green Bar', message='Green Bar!')
備考 #

Pine v4では alertcondition の呼び出しによって追加の plot が生成されます。こうした呼び出しはすべてスクリプト毎にアウトプット系列の数を計算する際に考慮されます。

関連 #

alert

© - 2021 - TradingViewの教科書