Kick off TradingView and Ngrok with TBOT-Wind

Kick off TradingView and Ngrok with TBOT-Wind

Context:

This section assumes you are familiar with TradingBoat. If not, you can learn more by visiting the following resources:

Introduction: TBOT on TradingBoat

To propel the TradingBoat, you need a Wind. In the context of TBOT on TradingBoat, this Wind traditionally blows from TradingView. But what if we could generate our own Wind, eliminating dependencies on TradingView and Ngrok? This is where TBOT-Wind comes into play.

The Concept of TBOT-Wind

TradingBoat is designed like a set of Lego blocks. Just as any type of wind can move a boat, TBOT on TradingBoat can function regardless of the source of the Wind—whether it comes from TradingView or from a custom solution like TBOT-Wind.

In this article series, we will explore how to kick off TBOT-Wind and eliminate the need for TradingView alerts and Ngrok/Server setups.

The Traditional Setup

Currently, TBOT on TradingBoat functions as a trading robot, bridging TradingView and Interactive Brokers. TradingView sends webhook alerts to TBOT, which then places and tracks orders using the IB-async API. To deliver webhook messages to TBOT, you typically need:

  1. TradingView: To generate and send alerts.
  2. Ngrok: To expose TBOT's localhost to receive alerts from TradingView.

The Challenge

Suppose you've completed backtesting on TradingView and want to implement the strategy in TBOT on the same machine. This would traditionally require both TradingView and Ngrok, which can be cumbersome and restrictive.

Enter TBOT-Wind

TBOT-Wind offers a new approach by directly fetching historical data from Interactive Brokers and sending alerts to TBOT. This eliminates the dependency on TradingView and Ngrok. TBOT-Wind is like a wind that powers TradingBoat from within.

TBOT-Wind Architecture

The good news is that TBOT on TradingBoat is already modular, making it easy to integrate TBOT-Wind without any changes. Implementing indicators in Python may require more coding than PineScript, but it offers greater control and flexibility. TBOT-Wind provides a framework where you can focus solely on your custom indicators.

 AI-Powered Alerts with OpenAI

AI comes into play by analyzing the trading signals, providing additional context and interpretation. This makes TBOT-Wind not only a webhook generator but also a smart system that leverages AI to boost the efficiency of trading alerts.

Building Blocks of TBOT-Wind

1. Historical Data (Warm Data) Management

TBOT-Wind is not a replacement for backtesting but rather a tool for forward-testing with custom indicators. To match the technical indicators used in TradingView's PineScript, you need a good amount of historical data, which we call "Warm Data." This warm data helps stabilize and synchronize indicator values between TBOT-Wind and TradingView.

  • Lookback Period: Indicators like Supertrend require a sufficient lookback period to generate stable results. For example, a Supertrend indicator with a length of 10 needs at least 10 data points, but ideally more, to stabilize.
  • Indicator Stabilization: Feeding an indicator with only a few rows of data results in noisy or inaccurate calculations. Providing a larger dataset (e.g., 100 rows) ensures smoother, more accurate results.
  • Consistency: To achieve consistency with platforms like TradingView, you need a DataFrame with enough rows for the indicator to produce stable results.

2. Real-Time Data Management (Hot Data)

During market hours, TBOT-Wind needs to fetch the most recent data, termed "Hot Data."

3. Merging Warm and Hot Data

Once both warm and hot data are available, they are merged into a single Pandas DataFrame. This merged data includes additional columns for tracking the status of indicators, called TBOT columns.

4. Event Loop for Indicator Processing

TBOT-Wind runs an event loop that acts as a producer, feeding data to multiple indicators (consumers). Each indicator manages its own window of data and processes it independently, generating alerts if necessary.

  • Skipping Overlapping Data: If the event loop detects overlapping data marked as 'completed,' it will skip to newer data, avoiding redundant processing.
  • Periodic Data Checks: The event loop periodically checks for new data, especially as bar-close times approach.

5. Sending Alert Messages

Once a signal is detected, it sends alerts to TBOT on TradingBoat. This can be done through:

  • HTTP POST: For public network delivery.
  • Redis Pub/Sub: For internal network delivery.

To avoid duplicate alerts, each alert message's hash value is saved in Redis and checked against history before sending.

6. How to Download the Program

Please clone the TBOT-Wind repository from GitHub:

git clone https://github.com/PlusGenie/tbot-wind.git

Summary

TBOT-Wind eliminates the need for TradingView and Ngrok by fetching historical and real-time data directly from Interactive Brokers. It merges this data into a single DataFrame, processes it through a customizable event loop, and sends alerts to TBOT on TradingBoat.

This modular, flexible system allows for robust, real-time trading without the constraints of traditional setups. In the upcoming articles, we will dive

Subscribe to TBOT on TradingBoat

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe