OPEN-SOURCE SCRIPT

TrinityBar

284
**TrinityBar Strategy Description**

The TrinityBar strategy is a price‐action based trading model that leverages Bill Williams’ bar thirds concept to generate entry signals and execute market orders automatically. Here’s how it works:

1. **Bar Thirds Calculation:**
The strategy calculates the range of both the current fully formed bar and the previous fully formed bar. It then divides each bar’s range into three equal parts (thirds).
- For the current bar, the lower third and upper third levels are computed.
- The same is done for the previous bar.

2. **Bar Type Classification:**
Each bar is classified into one of several types based on where its open and close fall relative to its thirds:
- **Bullish Patterns:**
- *1‑3 Bar:* Opens in the lower third and closes in the upper third.
- *2‑3 Bar:* Opens in the middle third and closes in the upper third.
- *3‑3 Bar:* Both open and close are in the upper third.
- **Bearish Patterns:**
- *3‑1 Bar:* Opens in the upper third and closes in the lower third.
- *2‑1 Bar:* Opens in the middle third and closes in the lower third.
- *1‑1 Bar:* Both open and close are in the lower third.

3. **Signal Generation:**
- **Bullish Signal:** A valid buy is generated when the previous bar exhibits any bullish pattern (1‑3, 2‑3, or 3‑3) and the current bar is either a 1‑3 or a 3‑3 bar.
- **Bearish Signal:** A valid sell is generated when the previous bar shows any bearish pattern (1‑1, 2‑1, or 3‑1) and the current bar is either a 1‑1 or a 3‑1 bar.

4. **Visual Alerts:**
When a valid signal is identified, the strategy plots a small triangle below the bar for a buy signal (labeled “B” in green) and a triangle above the bar for a sell signal (labeled “S” in red).

5. **Trade Execution:**
Once a signal is confirmed:
- If a bullish signal is generated, any short positions are closed, and if there is no existing long position, a market long order is entered.
- Conversely, if a bearish signal occurs, any long positions are closed, and a market short order is entered if not already in a short position.

This strategy is designed to capture significant price expansions by relying solely on price action and bar structure, without relying on lagging indicators. It provides a mechanical, systematic approach that removes emotional bias from trading decisions.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.