# Alerts

{% stepper %}
{% step %}

### Add Alert

<div data-with-frame="true"><figure><img src="https://3353728891-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1dlOGDREop4WMfLcctYT%2Fuploads%2FhhrwN2Y5pyCic8oOWfKJ%2Fimage.png?alt=media&#x26;token=e8d7b171-b366-4eed-8f51-414c1745a766" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

### Set Condition

<div data-with-frame="true"><figure><img src="https://3353728891-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1dlOGDREop4WMfLcctYT%2Fuploads%2FWCKYscYpdor50tzkqIMN%2Fimage.png?alt=media&#x26;token=8efd73db-cd84-4b69-89d0-2fc8071a7086" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

### Customize the Alert Message

<mark style="color:$info;">Enter a clear</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**Alert Name**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">and edit the</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**Message**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">that will appear when the alert triggers.</mark>\ <mark style="color:$info;">You can also add</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**placeholders**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">like</mark>

* `{{ticker}}` <mark style="color:$info;">- ticker of the symbol used in alert (AAPL, BTCUSD, etc.)</mark>
* `{{interval}}`  <mark style="color:$info;">- returns the interval (i.e. timeframe/resolution) of the chart that the alert is created on</mark>
* `{{strategy.position_size}}` <mark style="color:$info;">- returns the value of the same keyword in Pine, i.e., the size of the current position.</mark>
* `{{strategy.order.action}}` <mark style="color:$info;">- returns the string “buy” or “sell” for the executed order.</mark>
* `{{strategy.order.contracts}}` <mark style="color:$info;">- returns the number of contracts of the executed order.</mark>
* `{{strategy.order.price}}` <mark style="color:$info;">- returns the price at which the order was executed.</mark>
* `{{strategy.order.id}}` <mark style="color:$info;">- returns the ID of the executed order (the string used as the first parameter in one of the function calls generating orders: strategy.entry, strategy.exit or strategy.order).</mark>
* `{{strategy.order.comment}}` <mark style="color:$info;">- returns the comment of the executed order (the string used in the comment parameter in one of the function calls generating orders: strategy.entry, strategy.exit or strategy.order). If no comment is specified, then the value of</mark> <mark style="color:$info;"></mark>*<mark style="color:$info;">strategy.order.id</mark>* <mark style="color:$info;"></mark><mark style="color:$info;">will be used.</mark>
* `{{strategy.order.alert_message}}` <mark style="color:$info;">- returns the value of the alert\_message parameter which can be used in the strategy's Pine code when calling one of the functions used to place orders: strategy.entry, strategy.exit or strategy.order. This feature is only supported in Pine v4 and higher.</mark>
* `{{strategy.market_position}}` <mark style="color:$info;">- returns the current position of the strategy in string form: “long”, “flat”, or “short”.</mark>
* `{{strategy.market_position_size}}` <mark style="color:$info;">- returns the size of the current position as an absolute value, i.e. a non-negative number.</mark>
* `{{strategy.prev_market_position}}` <mark style="color:$info;">- returns the previous position of the strategy in string form: “long”, “flat”, or “short”.</mark>
* `{{strategy.prev_market_position_size}}` <mark style="color:$info;">- returns the size of the previous position as an absolute value, i.e. a non-negative number.</mark>

<div data-with-frame="true"><figure><img src="https://3353728891-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1dlOGDREop4WMfLcctYT%2Fuploads%2FwzXUfoC7absdD7IZMxGk%2Fimage.png?alt=media&#x26;token=142a2ccb-7e8f-4408-87eb-0e8c135f1fe3" alt=""><figcaption></figcaption></figure></div>

**Example:**\ <mark style="color:$info;">Alert name: Strategy Builder</mark>\ <mark style="color:$info;">Message:</mark>&#x20;

{\
"symbol":"{{ticker}}"\
"size":"{{strategy.order.action}}"\
"qty":"{{strategy.position\_size}}"\
"price":"{{close}}"\
"trigger\_time":"{{timenow}}"\
}
{% endstep %}

{% step %}

### Click **Create Alert**

<mark style="color:$info;">Once all settings are configured — click</mark> <mark style="color:$info;"></mark><mark style="color:$info;">**Create Alert**</mark> <mark style="color:$info;"></mark><mark style="color:$info;">to activate it.</mark>\ <mark style="color:$info;">Your alert will now monitor the Strategy Builder trades automatically and send a notification as soon as the trade appears.</mark>
{% endstep %}
{% endstepper %}
