Link TradingView charts with Cycles app via webhooks alerts

The integration provides a back-to-back integration between your TradingView charts and the cycle analysis toolset. Allowing to keep your TradingView chart data synced in real-time with the cycle analysis API and cycle application. Allowing to monitor active cycles in your TradingView chart for any symbol and time-frame.

The first step is to setup a separate alert-condition via a new pine script and attach it to your chart you want to use for cycle analysis.

1. Create alert-condition

Create a new individual alert-condition via a custom pine script. The simplest way of alert-condition for a pine script looks like this:

//@version=4
study("WTT_DataFeed")
plot(close)
alert = true

msg = "{\"streamid\":\"YOUR-STREAM-ID\", \"messagetype\":\"UPSERT\", \"dates\": [ \"{{time}}\" ], \"values\": [ {{close}} ] }"

alertcondition(alert, title='data', message=msg)

Be aware that the text string YOUR-STREAM-ID within the msg variable will be replaced later when you setup the alert. This is just a new alert-condition we place on your chart. This is not the alert. The message object (msg) is already prepared to work with the cycle analysis endpoint. So don't change this message if you want it to work with our cycle analysis.

2. Open symbol/chart

Open your symbol on a TradingView chart. Select the required time-frame and place the new script on the chart. You can use the pre-build script down below and can link it to your favorite indicators.

Want to place this script on your TradingView chart? Just use this prepared script:
https://www.tradingview.com/script/FTEsZurP-Cycle-Analysis-WebHook-API-Integration/

3. Get Cycle Analysis API Key

Before we start the alert and connection, ensure you have your cycle analysis API key at hand. You will find your API key via the cycle application: https://cycle.tools/account/api

Note down that key as you need to enter it when you setup the webhook connection in the next step.

4. Activate the webhook

The "Create Alert" function from TradingView panel will activate the webhook on their servers for your symbol and time-frame:

Create Alert to connect via webhook with cycle analysis

To start the live sync, the web-hook will be activated via the alert activation from the TradingView alert panel. Ensure to select the following options as shown:

  • Condition: "WTT_DataFeed", data
  • Options: "Once Per Bar Close"
  • Expiration: Open-ended
  • Alert Actions: Webhook URL
  • Cycle Analysis Webhook URL: https://api.cycle.tools/api/Stream/SubmitStreamData?api_key=YOUR-KEY
  • Message: Replace YOUR-STREAM-ID with the name you want to see it in the cycle analysis tools

TradingView Create Alert

Before you create the alert, replace the YOUR-STREAM-ID tag in the Message section with the stream ID you want to see that in your cycle analysis platform. Also replace YOUR-KEY in the webhook URL with your cycle analysis API key.

5. First webhook activation

After activation, you will see a confirmation in the alert panel that this webhook has now been created. Before we move on to the cycle analysis, we should wait and ensure that the first webhook has successfully been fired. We can see this in the alert panel when a date/time information has been placed in this section below your alert:

TradingView Alert webhook triggered

6. Open Cycle Analysis Streams

Now, you have done everything required on TradingView. The webhook will continuously fire off, even when you close and change your chart configuration. We can now monitor this symbol in our cycle analysis environment to see the cycle detection for that symbol. Open the cycle analysis streams page to see your new symbol added.

Go to the following page to see the connection: https://cycle.tools/settings/streams

In this case, we named the symbol "TV-BTCUSD-5M" - and you will find it with this ID in your cycle analysis streams board:

image-1616921324162.png

After you have setup the connection, there is not enough history available to start the cycle analysis. Therefore you either need to wait until at least 100 datapoints have been fired from the webhook connection or you can backfill the series manually via the "Fill" button and upload CSV data.