OPEN-SOURCE SCRIPT

Gemini Trend Following System

449
Strategy Description: The Gemini Trend Following System
Core Philosophy
This is a long-term trend-following system designed for a position trader or a patient swing trader, not a day trader. The fundamental goal is to capture the majority of a stock's major, multi-month or even multi-year uptrend.

The core principle is: "Buy weakness in a confirmed uptrend, and sell only when the uptrend's structure is fundamentally broken."

It operates on the belief that it's more profitable to ride a durable trend than to chase short-term breakouts or worry about daily price fluctuations. It prioritizes staying in a winning trade over frequent trading.

The Three Pillars of the Strategy
The script's logic is built on three distinct pillars, processed in order:

1. The Regime Filter: "Is This Stock in a Healthy Uptrend?"
Before even considering a trade, the script acts as a strict gatekeeper. It will only "watch" a stock if it meets all the criteria of a healthy, long-term uptrend. This is the most important part of the strategy as it filters out weak or speculative stocks.

A stock passes this filter if:

The 50-day Simple Moving Average (SMA) is above the 200-day SMA. This is the classic definition of a "Golden Cross" state, indicating the medium-term trend is stronger than the long-term trend—a hallmark of a bull market for the stock.

The stock's performance over the last year is positive. The Rate of Change (ROC) must be above a minimum threshold (e.g., 15%). This ensures we are only looking at stocks that have already demonstrated significant strength.

The 200-day SMA itself is rising. This is a crucial check to ensure the very foundation of the trend is solid and not flattening out or beginning to decline.

If a stock doesn't meet these conditions, the script ignores it completely.

2. The Entry Trigger: "When to Buy the Dip"
Once a stock is confirmed to be in a healthy uptrend, the script does not buy immediately. Instead, it patiently waits for a point of lower risk and higher potential reward—a pullback.

The entry trigger is a specific, two-step sequence:

The stock price first dips and closes below its 50-day SMA. This signifies a period of temporary weakness or profit-taking.

The price then recovers and closes back above the 50-day SMA within a short period (10 bars).

This sequence is a powerful signal. It suggests that institutional buyers view the 50-day SMA as a key support level and have stepped in to defend it, overpowering the sellers. The entry occurs at this point of confirmed support, marking the likely resumption of the uptrend. On the chart, this event is highlighted with a teal background.

3. The Exit Strategy: "When is the Trend Over?"
The exit logic is designed to keep you in the trade as long as possible and only sell when the trend's character has fundamentally changed. It uses a dual-exit system:

Primary Exit (Trend Failure): The main reason to sell is a "Death Cross"—when the 50-day SMA crosses below the 200-day SMA. This is a robust, albeit lagging, signal that the long-term uptrend is over and a bearish market structure is taking hold. This exit condition is designed to ignore normal market corrections and only trigger when the underlying trend has truly broken. On the chart, this is highlighted with a maroon background.

Safety-Net Exit (Catastrophic Stop-Loss): To protect against a sudden market crash or a company-specific disaster, a "safety-net" stop-loss is placed at the time of entry. This stop is set far below the entry price, typically underneath the 200-day SMA. It is a "just-in-case" measure that should only be triggered in a severe and rapid decline, protecting your capital from an unexpected black swan event.

Who is This Strategy For?
Position Traders: Investors who are comfortable holding a stock for many months to over a year.

Patient Swing Traders: Traders who want to capture large price swings over weeks and months, not days.

Investors using a Rules-Based Approach: Anyone looking to apply a disciplined, non-emotional system to their long-term portfolio.

Ideal Market Conditions
This strategy excels in markets with clear, durable trends. It performs best on strong, leading stocks during a sustained bull market. It will underperform significantly or generate losses in choppy, sideways, or range-bound markets, where the moving averages will frequently cross back and forth, leading to "whipsaw" trades.

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.