Soon available

Not on the Chrome Web Store yet

ProRealCode Studio is on its way. As soon as it is published, this button will take you straight to its Chrome Web Store page.

Chapter 17 · Part IV — Alerts and strategies

Your alerts, sent as data to the program of your choice.

An alert can carry a block of values. Studio then sends it as JSON to an address you choose: a bot, an automation service, a spreadsheet, your own server. You add the block, paste the address, and this chapter shows exactly what arrives at the other end.

Your codeStudioYour receiver alert(…, {side: "long"})fires on a live barin your ProRealTime tabbuilds the JSON objectat your webhook URLacts on it, or not POST · JSON
What happens when an alert carrying a block fires. The receiver is yours: Studio only delivers.
  1. 01Add a payload block Values in braces at the end of alert().
  2. 02Set the webhook URL Preferences, tab “Alert”, then “Test”.
  3. 03What your receiver gets The JSON object, field by field.
  4. 04Strategy fills, checks, and how to stop The same channel for strategies.
Before you startYou know how to write an alert (chapter 16). You have a receiver reachable at a public address, starting with https://. The ProRealTime tab stays open: signals leave from it, like alerts.
ProRealCode StudioUser guide · Chapter 17
01 · Task · Add a payload block

Put values in braces, and the alert also leaves as data.

An alert with a block at the end. Everything before the braces works as in chapter 16.

1IF Average[50](close) CROSSES OVER Average[200](close) THEN2  alert("Golden cross", "MA50 crossed MA200 at #close#", onceperbarclose, 1, {side: "long",3        price: close, score: RSI[14]})4ENDIF
You write in the bracesThe receiver gets, in “payload”
no braces at allNothing: the alert stays a popup and sends no data.
{}"payload": {}, with the other fields around it.
{signal: "breakout_up"}"signal": "breakout_up". Text can carry #…# like a message.
{rsi: RSI[14], price: close}"rsi": 32.7, "price": 1.0852: numbers, computed on the bar that fired.
{up: close > open}"up": false. A comparison, true or false becomes a yes / no value.
{pivot: PivotHigh[5,5]}"pivot": null when there is no value on that bar. The key stays.

Names are labels

The word before each colon is only a name for your receiver. {close: close} sends the price under the name “close”. Any word works, even one the language reserves elsewhere.

One flat level

No braces inside the braces, no lists. At most 64 names, each used once. Studio refuses the code otherwise, it never drops a value quietly.

Where to put it

Anywhere after the message, before or after the frequency and the sound. A line may break inside the braces, nowhere else in alert().

Run, then checkClick “Run” after adding the block. Nothing leaves until an alert fires on a live bar, and nothing leaves at all until the address of task 2 is set.
ProRealCode StudioUser guide · Chapter 17
02 · Task · Set the webhook URL

Paste the address once. Every signal goes there.

Preferences on the Alert tab: under Webhook URL for JSON signals, the switch Send signals to webhook turned on, its explanation, an empty address field showing https://your-webhook.example.com/prt-alert, a Test button, and a note on receivers on your own machine. The window's bottom edge is cropped. 1 2 3 4
Preferences, tab “Alert”. The field is empty: its grey text is only an example of an address.
  1. “Alert”, the tab that holds the webhook.
  2. “Send signals to webhook”. On at first. Off, nothing is sent; your address stays.
  3. The address of your receiver. Empty means no signal leaves.
  4. “Test” sends one test signal to the address in the field, even with the switch off.
  1. Click the gear at the bottom of the rail to open Preferences, then the tab “Alert”.
  2. Paste your receiver's address into the field, then click outside it.It is saved. An address must start with http:// or https://, or it is refused.
  3. Click “Test”.“last webhook delivered (200) at …” when your receiver answered. “⚠ webhook failed (…) — is the receiver running?” when it did not.
A receiver on your own computer is out of reachlocalhost, 127.0.0.1 or an address of your home network: the browser blocks them, and Studio cannot ask for access. Use a tunnel (ngrok, for example) or a receiver on the internet.
ProRealCode StudioUser guide · Chapter 17
03 · Task · What your receiver gets

Every signal is the same object. Only the payload is yours.

The body of the request for the alert of task 1, on EUR/USD in 5 minutes.

{
  "instrument": "EURUSD",
  "timeframe": "5 minutes",
  "bar": 4213,
  "barTime": 1751020200,
  "title": "Golden cross",
  "message": "MA50 crossed MA200 at 1.0852",
  "freq": "onceperbarclose",
  "payload": {
    "side": "long",
    "price": 1.0852,
    "score": 62.4
  },
  "at": 1751020500412
}

What your receiver must accept

  • A POST request whose body is JSON (Content-Type: application/json).
  • A request coming from a browser. The browser first asks permission with an OPTIONS request; the receiver answers with Access-Control-Allow-Origin: *, Access-Control-Allow-Headers: Content-Type and Access-Control-Allow-Methods: POST, OPTIONS.
  • Preferences names n8n, Make and Zapier as receivers. Whether yours answers that OPTIONS request, “Test” tells you in one click.
FieldContent
instrumentThe chart's instrument, as Studio names it. Empty when unknown.
timeframeThe chart's timeframe in words: “5 minutes”, “1 day”. Empty when unknown.
barThe number of the bar that fired, counted from the first bar of the chart.
barTimeWhen that bar opened, in seconds since 1 January 1970, UTC.
title, messageThe alert's texts, #…# already replaced. Cut at 260 characters.
freqfreqall, onceperbar or onceperbarclose.
payloadYour block, as written in task 1. A text value is cut at 260 characters.
atWhen Studio sent it, in milliseconds since 1 January 1970, UTC.

The test signal of task 2 has the same fields: instrument “TEST”, title “Webhook test”, and "payload": {"test": true, "source": "settings"}. Set your receiver to ignore it.

ProRealCode StudioUser guide · Chapter 17
04 · Task · Strategy fills, checks, and how to stop

Strategies use the same channel. One receiver reads both.

A strategy armed in real time (chapter 19) sends each of its fills to the same address, in the same object. Only the texts and the payload change.

Field of a fillContent
title“BUY” or “SELL”: what the order did. Closing a long is a SELL.
message“entry long”, “exit long”, “entry short” or “exit short”.
freqAlways onceperbarclose.
timeframeThe same words as an alert: “5 minutes”, “1 hour”, “1 day”. One format for both kinds of signal.
payloadaction (“buy” or “sell”), qty, price (the fill price) and strategy (its name). An exit adds pnl and reason: “stop”, “target”, “order” for the code's own exit order, or another word for a time-based close.

How do I see what was sent?

In the Alerts window, under “Fired this session”, an alert with a block shows “{ } JSON signal”, then “· sent” once it left. Click it to read the exact object.

I muted the indicator. Why does my receiver still get signals?

Mute and snooze stop the noise, not the data, so an automation does not break without warning. To stop the data, see the next answer.

How do I stop sending?

For everything: switch off “Send signals to webhook”; your address stays. For one alert: remove its braces and click “Run”.

The receiver was down. Are signals resent later?

No. A signal that could not be delivered is lost; the alert itself still fired and is still in the list.

Next

Chapter 18 · Backtesting a strategy

A code that places orders, run over the chart's history, and the window that reads its results.

ProRealCode StudioUser guide · Chapter 17
ProRealCode ProRealCode
Loading...