INVITE-ONLY SCRIPT

- Trading Bot - Stochastic MACD / SMA - Robot Strategy -

153
Overview

This strategy is a complete algorithmic trading solution designed for traders looking to automate their positions on cryptocurrency or traditional markets. It combines the precision of the Stochastic Oscillator with the trend-following power of the MACD and a Multi-Timeframe SMA.

Unlike simple crossover strategies that often fail in ranging markets, this script uses a "Funnel Logic" to filter out low-probability trades, ensuring that entries are only taken when momentum and trend are aligned.


1. The Logic Behind the Strategy

The strategy operates on a three-layer confirmation system:

Layer 1: The Trend Filter (SMA MTF)
The strategy first checks the long-term trend using a Simple Moving Average (SMA).
  • Longs are only allowed if the price is above the SMA.
  • Shorts are only allowed if the price is below the SMA.

Note: You can select a higher timeframe for this SMA (e.g., viewing the 4H trend while trading on the 15m chart).

Layer 2: The Momentum Filter (MACD)
The MACD (Moving Average Convergence Divergence) ensures we are not trading against short-term momentum.
  • A Long signal requires the MACD line to be above the Signal line.
  • A Short signal requires the Signal line to be above the MACD line.

Layer 3: The Trigger (Stochastic)
Once the trend and momentum are validated, the strategy waits for a precise entry signal from the Stochastic Oscillator (%K and %D).
  • Entry: Occurs when the %K line crosses the defined threshold (e.g., oversold for longs).
  • Exit: Occurs when the %K line crosses the opposite threshold (e.g., 50% median line) or hits a Stop-Loss.


2. Key Features for Automation

This script is specifically engineered for third-party automation (custom webhooks) :
  • Clean Alert Messages: The comment= fields in the order alerts only contain the necessary entry/exit strings, keeping your logs clean.
  • JSON Data Plots: The script includes invisible plots (display.none) that output strategy values (leverage, quantity type, trade direction) specifically formatted to be picked up by dynamic placeholders in TradingView alerts.
  • Backtest Date Range: You can restrict the strategy to a specific date range to test performance over specific market cycles.


3. Risk Management & Safety
  • Stop-Loss: Configurable percentage-based Stop-Loss for Longs and Shorts.
  • Cooldown Mechanism: To prevent "revenge trading" or chopping in volatile markets, the script features a "Cooldown" system. If a Stop-Loss is hit, the strategy pauses for a set number of bars.
  • SMA Re-Cross Requirement: Optionally, you can force the strategy to wait for the price to re-cross the SMA after a cooldown before taking a new trade, adding an extra layer of safety.


4. How to use
  • Add the script to your chart (Recommended timeframes: 15m, 1h, 4h).
  • Open the settings to choose your Trading Mode (Long Only, Short Only, or Both).
  • Adjust the Stochastic and MACD settings to fit the volatility of your specific asset.
  • Enable the Filters (SMA/MACD) based on your preference.
  • Set up your alerts using the provided message placeholders for your trading bot.


Disclaimer
Past performance is not indicative of future results. This script is a tool for technical analysis and automation. Please use proper risk management and backtest thoroughly before using real funds.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.