OPEN-SOURCE SCRIPT
מעודכן Slope Failure (Momentum Stall) STRATEGY

//======================================================================================
// SLOPE FAILURE (MOMENTUM STALL) STRATEGY
//--------------------------------------------------------------------------------------
// WHAT THIS STRATEGY DOES
// -----------------------
// This strategy trades **momentum failure**, not trend direction.
//
// Instead of predicting where price will go, it detects when **momentum can no longer
// continue in its current direction** and briefly fades that failure.
//
// Core idea:
// - Momentum expands → slope grows
// - Momentum stalls → slope collapses or flips
// - That stall represents **state transition**, not noise
//
// The system exploits these transitions repeatedly at short horizons.
//
//--------------------------------------------------------------------------------------
// HOW MOMENTUM IS MEASURED
// ------------------------
// 1. Source price (optionally smoothed)
// 2. First derivative (slope = price[t] - price[t-1])
// 3. Optional smoothing of the slope itself
//
// The slope represents **instantaneous directional force**, not trend bias.
//
//--------------------------------------------------------------------------------------
// ENTRY LOGIC (SLOPE FAILURE)
// ---------------------------
// • Bull Slope Failure (SHORT):
// - Prior slope was sufficiently positive
// - Current slope collapses to zero or below
// → Upward momentum failed → enter SHORT
//
// • Bear Slope Failure (LONG):
// - Prior slope was sufficiently negative
// - Current slope rises to zero or above
// → Downward momentum failed → enter LONG
//
// Optional:
// - Minimum slope band can be enforced to avoid weak/noisy failures
//
//--------------------------------------------------------------------------------------
// EXIT LOGIC
// ----------
// Primary exits are **force-based**, not price-based:
//
// • Longest Slope Local Turn (optional):
// - Detects when the strongest slope in a recent window has occurred
// - Exits when momentum starts decaying from that extreme
//
// • Percent Stop Loss (optional):
// - Fixed % protection relative to entry price
//
// The strategy does NOT rely on profit targets.
// Winners are exited when **momentum decays**, not when price "looks good".
//
//--------------------------------------------------------------------------------------
// POSITION SIZING
// ---------------
// This strategy supports **percent-of-equity sizing**, computed dynamically:
//
// position size = (account equity × % allocation) / price
//
// This allows:
// - P&L to scale smoothly
// - Drawdowns to remain proportional
// - The same logic to work across symbols and account sizes
//
//--------------------------------------------------------------------------------------
// STRATEGY CHARACTERISTICS
// ------------------------
// • High trade count
// • Win rate near ~45–50%
// • Small, fast losers
// • Slightly larger winners
// • Very low drawdown
//
// This profile is intentionally designed for **scalability**, not prediction.
//
//--------------------------------------------------------------------------------------
// IMPORTANT NOTES
// ---------------
// • This is NOT a trend-following strategy
// • This is NOT a mean-reversion guess
// • This is a momentum **state-transition detector**
//
// The edge comes from structure + exits + sizing — not indicators.
//
//======================================================================================
// SLOPE FAILURE (MOMENTUM STALL) STRATEGY
//--------------------------------------------------------------------------------------
// WHAT THIS STRATEGY DOES
// -----------------------
// This strategy trades **momentum failure**, not trend direction.
//
// Instead of predicting where price will go, it detects when **momentum can no longer
// continue in its current direction** and briefly fades that failure.
//
// Core idea:
// - Momentum expands → slope grows
// - Momentum stalls → slope collapses or flips
// - That stall represents **state transition**, not noise
//
// The system exploits these transitions repeatedly at short horizons.
//
//--------------------------------------------------------------------------------------
// HOW MOMENTUM IS MEASURED
// ------------------------
// 1. Source price (optionally smoothed)
// 2. First derivative (slope = price[t] - price[t-1])
// 3. Optional smoothing of the slope itself
//
// The slope represents **instantaneous directional force**, not trend bias.
//
//--------------------------------------------------------------------------------------
// ENTRY LOGIC (SLOPE FAILURE)
// ---------------------------
// • Bull Slope Failure (SHORT):
// - Prior slope was sufficiently positive
// - Current slope collapses to zero or below
// → Upward momentum failed → enter SHORT
//
// • Bear Slope Failure (LONG):
// - Prior slope was sufficiently negative
// - Current slope rises to zero or above
// → Downward momentum failed → enter LONG
//
// Optional:
// - Minimum slope band can be enforced to avoid weak/noisy failures
//
//--------------------------------------------------------------------------------------
// EXIT LOGIC
// ----------
// Primary exits are **force-based**, not price-based:
//
// • Longest Slope Local Turn (optional):
// - Detects when the strongest slope in a recent window has occurred
// - Exits when momentum starts decaying from that extreme
//
// • Percent Stop Loss (optional):
// - Fixed % protection relative to entry price
//
// The strategy does NOT rely on profit targets.
// Winners are exited when **momentum decays**, not when price "looks good".
//
//--------------------------------------------------------------------------------------
// POSITION SIZING
// ---------------
// This strategy supports **percent-of-equity sizing**, computed dynamically:
//
// position size = (account equity × % allocation) / price
//
// This allows:
// - P&L to scale smoothly
// - Drawdowns to remain proportional
// - The same logic to work across symbols and account sizes
//
//--------------------------------------------------------------------------------------
// STRATEGY CHARACTERISTICS
// ------------------------
// • High trade count
// • Win rate near ~45–50%
// • Small, fast losers
// • Slightly larger winners
// • Very low drawdown
//
// This profile is intentionally designed for **scalability**, not prediction.
//
//--------------------------------------------------------------------------------------
// IMPORTANT NOTES
// ---------------
// • This is NOT a trend-following strategy
// • This is NOT a mean-reversion guess
// • This is a momentum **state-transition detector**
//
// The edge comes from structure + exits + sizing — not indicators.
//
//======================================================================================
הערות שחרור
//======================================================================================// SLOPE FAILURE (MOMENTUM STALL) STRATEGY
//--------------------------------------------------------------------------------------
// WHAT THIS STRATEGY DOES
// -----------------------
// This strategy trades **momentum failure**, not trend direction.
//
// Instead of predicting where price will go, it detects when **momentum can no longer
// continue in its current direction** and briefly fades that failure.
//
// Core idea:
// - Momentum expands → slope grows
// - Momentum stalls → slope collapses or flips
// - That stall represents **state transition**, not noise
//
// The system exploits these transitions repeatedly at short horizons.
//
//--------------------------------------------------------------------------------------
// HOW MOMENTUM IS MEASURED
// ------------------------
// 1. Source price (optionally smoothed)
// 2. First derivative (slope = price[t] - price[t-1])
// 3. Optional smoothing of the slope itself
//
// The slope represents **instantaneous directional force**, not trend bias.
//
//--------------------------------------------------------------------------------------
// ENTRY LOGIC (SLOPE FAILURE)
// ---------------------------
// • Bull Slope Failure (SHORT):
// - Prior slope was sufficiently positive
// - Current slope collapses to zero or below
// → Upward momentum failed → enter SHORT
//
// • Bear Slope Failure (LONG):
// - Prior slope was sufficiently negative
// - Current slope rises to zero or above
// → Downward momentum failed → enter LONG
//
// Optional:
// - Minimum slope band can be enforced to avoid weak/noisy failures
//
//--------------------------------------------------------------------------------------
// EXIT LOGIC
// ----------
// Primary exits are **force-based**, not price-based:
//
// • Longest Slope Local Turn (optional):
// - Detects when the strongest slope in a recent window has occurred
// - Exits when momentum starts decaying from that extreme
//
// • Percent Stop Loss (optional):
// - Fixed % protection relative to entry price
//
// The strategy does NOT rely on profit targets.
// Winners are exited when **momentum decays**, not when price "looks good".
//
//--------------------------------------------------------------------------------------
// POSITION SIZING
// ---------------
// This strategy supports **percent-of-equity sizing**, computed dynamically:
//
// position size = (account equity × % allocation) / price
//
// This allows:
// - P&L to scale smoothly
// - Drawdowns to remain proportional
// - The same logic to work across symbols and account sizes
//
//--------------------------------------------------------------------------------------
// STRATEGY CHARACTERISTICS
// ------------------------
// • High trade count
// • Win rate near ~30%
// • Small, fast losers
// • Slightly larger winners
// • Very low drawdown
//
// This profile is intentionally designed for **scalability**, not prediction.
//
//--------------------------------------------------------------------------------------
// IMPORTANT NOTES
// ---------------
// • This is NOT a trend-following strategy
// • This is NOT a mean-reversion guess
// • This is a momentum **state-transition detector**
//
// The edge comes from structure + exits + sizing — not indicators.
//
//======================================================================================
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.