OPEN-SOURCE SCRIPT
Cập nhật

OCC Strategy Optimized (MA 5 + Delayed TSL)

128
# OCC Strategy Optimized (MA 5 + Delayed TSL) - User Guide

## Introduction
The **OCC Strategy Optimized** is an enhanced version of the classic **Open Close Cross (OCC)** strategy. This strategy is designed for high-precision trend following, utilizing the crossover logic of Open and Close moving averages to identify market shifts. This optimized version incorporates advanced risk management, multi-timeframe analysis, and a variety of moving average types to provide a robust trading solution for modern markets.

> [!IMPORTANT]
> **Special Thanks:** This strategy is based on the original work of **JustUncleL**, a renowned Pine Script developer. You can find their work and profile on TradingView here: [JustUncleL's Profile](in.tradingview.com/u/JustUncleL/).

---

## Key Features

### 1. Optimized Core Logic
- **MA Period (Default: 5):** The strategy is tuned with a shorter MA length to reduce lag and capture trends earlier.
- **Crossing Logic:** Signals are generated when the Moving Average of the **Close** crosses the Moving Average of the **Open**.

### 2. Multi-Timeframe (MTF) Analysis
- **Alternate Resolution:** Use a higher timeframe (Resolution Multiplier) to filter out noise. By default, it uses $3 \times$ your current chart timeframe to confirm the trend.
- **Non-Repainting:** Includes an optional delay offset to ensure signals are confirmed and do not disappear (repaint) after the bar closes.

### 3. Advanced Risk Management
This script features a hierarchical exit system to protect your capital and lock in profits:
- **Fixed Stop Loss (Initial):** Protects against sudden market reversals immediately after entry.
- **Delayed Trailing Stop Loss (TSL):**
- **Activation Delay:** The TSL only activates after the trade reaches a specific profit threshold (e.g., 1%). This prevents being stopped out too early in the trade's development.
- **Ratchet Trail:** Once activated, the stop loss "ratchets" up/down, never moving backward, ensuring you lock in profits as the trend continues.
- **Take Profit (TP):** A fixed percentage target to exit the trade at a pre-defined profit level.

### 4. Versatility
- **12 MA Types:** Choose from SMA, EMA, DEMA, TEMA, WMA, VWMA, SMMA, HullMA, LSMA, ALMA, SSMA, and TMA.
- **Trade Direction:** Toggle between Long-only, Short-only, or Both.
- **Visuals:** Optional bar coloring to visualize the trend directly on the candlesticks.

---

## User Input Guide

### Core Settings
- **Use Alternate Resolution?:** Enable this to use the MTF logic.
- **Multiplier for Alternate Resolution:** How many charts higher the "filter" timeframe should be.
- **MA Type:** Select your preferred moving average smoothing method.
- **MA Period:** The length of the Open/Close averages.
- **Delay Open/Close MA:** Use `1` or higher to force non-repainting behavior.

### Risk Management Settings
- **Use Trailing Stop Loss?:** Enables the TSL system.
- **Trailing Stop %:** The distance the stop follows behind the price (Optimized Default: 1.5%).
- **TSL Activation % (Delay):** The profit % required before the TSL starts moving. (Optimized Default: 2.0% to ensure 0.5% profit is locked immediately).
- **Initial Fixed Stop Loss %:** Your hard stop if the trade immediately goes against you.
- **Take Profit %:** Your ultimate profit target for the trade.

---

## How to Trade with This Strategy
1. **Identify the Trend:** Look for the Moving Average lines (Close vs Open) to cross.
2. **Wait for Confirmation:** If using MTF, ensure the higher timeframe also shows a trend change.
3. **Manage the Trade:** Let the TSL work. With the default **2.0% Activation** and **1.5% Trail**, the strategy will automatically lock in **0.5% profit** the moment the threshold is hit, then follow the price higher.
4. **Position Sizing:** Adjust the `Properties` tab in the script settings to match your desired capital allocation (Default is 10% of equity).

---

## Recommended Settings

1. Trialing < Activation
2. Check ranging

## Credits
Original Strategy by: **JustUncleL**
Optimized and Enhanced by: **Antigravity AI**
Phát hành các Ghi chú
Deprecated

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.