OPEN-SOURCE SCRIPT
Apex Turn v4

APEX TURN v4: Kalman Snapback with Fee Gate, Trend Guard and Fair Value Take Profit
Apex Turn is a mean reversion tool that hunts exhausted moves and trades the snap back to fair value. It was designed for crypto perpetual futures but works on any liquid market.
HOW IT WORKS
The script runs an adaptive Kalman filter on log price to estimate fair value, drawn as the orange line. The gap between price and fair value is normalized into a z score over a rolling window. When the z score stretches beyond the entry threshold (2.8 by default) and then hooks back toward the mean while still deeply stretched, the engine looks to trade against the extreme. Longs trigger at washed out lows and shorts trigger at blow off highs.
THREE GATES PROTECT EVERY SIGNAL
Gate one is the chop filter. The Kaufman Efficiency Ratio must confirm a ranging market before any mean reversion entry is allowed.
Gate two is the fee gate. The script projects the reward from current price to fair value, converts your maker and taker fees into R units based on the stop distance, and blocks any signal that would not cover all fees plus a minimum net gain of 0.35R. Blocked signals print as small gray crosses so you can see exactly what fees would have eaten.
Gate three is the strong trend guard. Fair value drift is measured in ATR per bar. When drift is strong, counter trend signals are suppressed until the market prints a release event: a momentum divergence on the z score, volume absorption at the extreme, or both together depending on the mode you select. Trend blocked signals print as orange squares and release events print as aqua diamonds.
EXITS
On entry the script freezes the current fair value as the take profit target, plotted in green, and places the stop in red at 1.5 ATR from entry. The default exit mode assumes you rest a reduce only limit order at the target so your winning exit pays the lower maker fee. Mean touch and overshoot exit modes are also included in the settings. A time stop closes stale positions after 45 bars.
ADAPTIVE ATR
The ATR length is anchored to real time rather than a fixed bar count. It always measures roughly 112 minutes of volatility, so stops, targets and fee math stay consistent whether you chart 30 seconds or 4 hours.
ALERTS
Four webhook ready alerts are included. Entry alerts carry the close price, the stop, the frozen take profit and the projected net R, so an automated system can place the full bracket the moment a position is born. Exit alerts fire for stop, target and time stop events.
SUGGESTED USE
Developed and tested for the 8 minute chart on liquid perpetual pairs. The 30 minute and 1 hour charts also suit the logic well. Timeframes under 5 minutes are not recommended because trading fees consume most of the edge there. Set the maker and taker fee inputs to match your own exchange tier before trusting the fee gate.
Signals are evaluated at bar close and do not repaint. Nothing in this script is financial advice and past behavior in testing does not guarantee future results. Always size positions responsibly and manage your own risk.
Apex Turn is a mean reversion tool that hunts exhausted moves and trades the snap back to fair value. It was designed for crypto perpetual futures but works on any liquid market.
HOW IT WORKS
The script runs an adaptive Kalman filter on log price to estimate fair value, drawn as the orange line. The gap between price and fair value is normalized into a z score over a rolling window. When the z score stretches beyond the entry threshold (2.8 by default) and then hooks back toward the mean while still deeply stretched, the engine looks to trade against the extreme. Longs trigger at washed out lows and shorts trigger at blow off highs.
THREE GATES PROTECT EVERY SIGNAL
Gate one is the chop filter. The Kaufman Efficiency Ratio must confirm a ranging market before any mean reversion entry is allowed.
Gate two is the fee gate. The script projects the reward from current price to fair value, converts your maker and taker fees into R units based on the stop distance, and blocks any signal that would not cover all fees plus a minimum net gain of 0.35R. Blocked signals print as small gray crosses so you can see exactly what fees would have eaten.
Gate three is the strong trend guard. Fair value drift is measured in ATR per bar. When drift is strong, counter trend signals are suppressed until the market prints a release event: a momentum divergence on the z score, volume absorption at the extreme, or both together depending on the mode you select. Trend blocked signals print as orange squares and release events print as aqua diamonds.
EXITS
On entry the script freezes the current fair value as the take profit target, plotted in green, and places the stop in red at 1.5 ATR from entry. The default exit mode assumes you rest a reduce only limit order at the target so your winning exit pays the lower maker fee. Mean touch and overshoot exit modes are also included in the settings. A time stop closes stale positions after 45 bars.
ADAPTIVE ATR
The ATR length is anchored to real time rather than a fixed bar count. It always measures roughly 112 minutes of volatility, so stops, targets and fee math stay consistent whether you chart 30 seconds or 4 hours.
ALERTS
Four webhook ready alerts are included. Entry alerts carry the close price, the stop, the frozen take profit and the projected net R, so an automated system can place the full bracket the moment a position is born. Exit alerts fire for stop, target and time stop events.
SUGGESTED USE
Developed and tested for the 8 minute chart on liquid perpetual pairs. The 30 minute and 1 hour charts also suit the logic well. Timeframes under 5 minutes are not recommended because trading fees consume most of the edge there. Set the maker and taker fee inputs to match your own exchange tier before trusting the fee gate.
Signals are evaluated at bar close and do not repaint. Nothing in this script is financial advice and past behavior in testing does not guarantee future results. Always size positions responsibly and manage your own risk.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Don't force a trade. Wait for your setup, be patient. Trade ideas are my own and not financial advice, I'm a monkey with a phone for crying out loud.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Don't force a trade. Wait for your setup, be patient. Trade ideas are my own and not financial advice, I'm a monkey with a phone for crying out loud.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.