OPEN-SOURCE SCRIPT
업데이트됨 Smart MACD + KNN (Dynamic SL Fix)

This script is a comprehensive trading system designed for TradingView that combines traditional momentum indicators with machine learning concepts and advanced trade management logic.
Here is a detailed description of its features:
1. Signal Generation (The "Brain")
Smart MACD: Uses a standard MACD (Moving Average Convergence Divergence) to identify buy and sell opportunities.
KNN Machine Learning: Filters every MACD signal using a K-Nearest Neighbors algorithm. It analyzes historical market data (RSI, CCI, Volatility, Volume) to determine if the current signal is statistically likely to be profitable. If the ML prediction is negative, the signal is ignored.
Trend Filter: An optional 200 EMA filter ensures you only trade with the long-term trend (Buy above EMA 200, Sell below).
Volatility Guard: Automatically blocks signals during extreme volatility spikes (like news events) to prevent bad entries.
2. Trade Management (The Logic)
Single Trade Mode: The script enforces a "one trade at a time" rule. It will not generate a new "Buy" signal if a "Buy" trade is already active. It waits for the trade to hit Take Profit (TP) or Stop Loss (SL) before resetting.
Flip Capability: While it blocks same-direction signals, it allows opposite signals. If you are in a Long trade and a valid Short signal appears, it effectively "flips" the trade—closing the Long and opening the Short immediately.
Dynamic Stop Loss (Stepped ROI): This is a profit-locking feature.
Trigger 1: When price moves X% in profit, the SL moves to a specified ROI % (e.g., Break Even).
Trigger 2: When price moves further to Y% profit, the SL moves again to lock in a larger profit.
3. Automation & Alerts
Customizable Messages: You can input your own text or JSON commands for Entry, TP, and SL alerts directly in the settings menu.
3x Trigger Safety: Every alert fires 3 times continuously to ensure that external bots or webhooks receive the signal, minimizing the risk of missed trades due to network lag.
4. Visuals
TP/SL Lines: Draws active Stop Loss and Take Profit lines on the chart that update in real-time.
Dashboard Table: A panel in the top-right corner displays the precise price levels for the current TP and SL.
Fog & Colors: The background and candles change color based on the trend direction, giving you an immediate visual cue of market sentiment.
Here is a detailed description of its features:
1. Signal Generation (The "Brain")
Smart MACD: Uses a standard MACD (Moving Average Convergence Divergence) to identify buy and sell opportunities.
KNN Machine Learning: Filters every MACD signal using a K-Nearest Neighbors algorithm. It analyzes historical market data (RSI, CCI, Volatility, Volume) to determine if the current signal is statistically likely to be profitable. If the ML prediction is negative, the signal is ignored.
Trend Filter: An optional 200 EMA filter ensures you only trade with the long-term trend (Buy above EMA 200, Sell below).
Volatility Guard: Automatically blocks signals during extreme volatility spikes (like news events) to prevent bad entries.
2. Trade Management (The Logic)
Single Trade Mode: The script enforces a "one trade at a time" rule. It will not generate a new "Buy" signal if a "Buy" trade is already active. It waits for the trade to hit Take Profit (TP) or Stop Loss (SL) before resetting.
Flip Capability: While it blocks same-direction signals, it allows opposite signals. If you are in a Long trade and a valid Short signal appears, it effectively "flips" the trade—closing the Long and opening the Short immediately.
Dynamic Stop Loss (Stepped ROI): This is a profit-locking feature.
Trigger 1: When price moves X% in profit, the SL moves to a specified ROI % (e.g., Break Even).
Trigger 2: When price moves further to Y% profit, the SL moves again to lock in a larger profit.
3. Automation & Alerts
Customizable Messages: You can input your own text or JSON commands for Entry, TP, and SL alerts directly in the settings menu.
3x Trigger Safety: Every alert fires 3 times continuously to ensure that external bots or webhooks receive the signal, minimizing the risk of missed trades due to network lag.
4. Visuals
TP/SL Lines: Draws active Stop Loss and Take Profit lines on the chart that update in real-time.
Dashboard Table: A panel in the top-right corner displays the precise price levels for the current TP and SL.
Fog & Colors: The background and candles change color based on the trend direction, giving you an immediate visual cue of market sentiment.
릴리즈 노트
Update on pre-settings, and Triggered TP/SL once per bar instead of Per bar closed this help to prevent volitive price movement. 오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Knowledge's Joe
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Knowledge's Joe
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.