Extremum Range MA Crossover Strategy by Script_Algo

By Script_Algo

Performance Metrics

Description

1. Principle of Work & Strategy Logic โš™๏ธ๐Ÿ“ˆMain idea: The strategy tries to catch the moment of a breakout from a price consolidation range (flat) and the start of a new trend. It combines two key elements:Moving Average (MA) ๐Ÿ“‰: Acts as a dynamic support/resistance level and trend filter.Range Extremes (Range High/Low) ๐Ÿ”บ๐Ÿ”ป: Define the borders of the recent price channel or consolidation.The strategy does not attempt to catch absolute tops and bottoms. Instead, it enters an already formed move after the breakout, expecting continuation.Type: Trend-following, momentum-based.Timeframes: Works on different TFs (H1, H4, D), but best suited for H4 and higher, where breakouts are more meaningful.2. Justification of Indicators & Settings โš™๏ธA. Moving Average (MA) ๐Ÿ“ŠWhy used: Core of the strategy. It smooths price fluctuations and helps define the trend. The price (via extremes) must cross the MA โ†’ signals a potential trend shift or strengthening.Parameters:maLength = 20: Default length (โ‰ˆ one trading month, 20-21 days). Good balance between sensitivity & smoothing.Lower TF โ†’ reduce (10โ€“14).Higher TF โ†’ increase (50).maSource: Defines price source (default = Close). Alternatives (HL2, HLC3) โ†’ smoother, less noisy MA.maType: Default = EMA (Exponential MA).Why EMA? Faster reaction to recent price changes vs SMA โ†’ useful for breakout strategies.Other options:SMA ๐ŸŸฆ โ€“ classic, slowest.WMA ๐ŸŸจ โ€“ weights recent data stronger.HMA ๐ŸŸฉ โ€“ near-zero lag, but โ€œnervous,โ€ more false signals.DEMA/TEMA ๐ŸŸง โ€“ even faster & more sensitive than EMA.VWMA ๐Ÿ”Š โ€“ volume-weighted.ZLEMA โฑ โ€“ reduced lag.๐Ÿ‘‰ Choice = tradeoff between speed of reaction & false signals.B. Range Extremes (Previous High/Low) ๐Ÿ“Why used: Define borders of recent trading range.prevHigh = local resistance.prevLow = local support.Break of these levels on close = trigger.Parameters:lookbackPeriod = 5: Searches for highest high / lowest low of last 5 candles. Very recent range.Higher value (10โ€“20) โ†’ wider, stronger ranges but rarer signals.3. Entry & Exit Rules ๐ŸŽฏLong signals (BUY) ๐ŸŸข๐Ÿ“ˆCondition (longCondition): Previous Low crosses MA from below upwards.โ†’ Price bounced from the bottom & strong enough to push range border above MA.Execution: Auto-close short (if any) โ†’ open long.Short signals (SELL) ๐Ÿ”ด๐Ÿ“‰Condition (shortCondition): Previous High crosses MA from above downwards.โ†’ Price rejected from the top, upper border failed above MA.Execution: Auto-close long (if any) โ†’ open short.Exit conditions ๐ŸšชExit Long (exitLongCondition): Close below prevLow.โ†’ Uptrend likely ended, range shifts down.Exit Short (exitShortCondition): Close above prevHigh.โ†’ Downtrend likely ended, range shifts up.โš ๏ธ Important: Exit = only on candle close beyond extremes (not just wick).4. Trading Settings โš’๏ธoverlay = true โ†’ indicators shown on chart.initial_capital = 10000 ๐Ÿ’ต.default_qty_type = strategy.cash, default_qty_value = 100 โ†’ trades fixed $100 per order (not lots). Can switch to % of equity.commission_type = strategy.commission.percent, commission_value = 0.1 โ†’ default broker fee = 0.1%. Adjust for your broker!slippage = 3 โ†’ slippage = 3 ticks. Adjust to asset liquidity.currency = USD.margin_long = 100, margin_short = 100 โ†’ no leverage (100% margin).5. Visualization on Chart ๐Ÿ“ŠThe strategy draws 3 lines:๐Ÿ”ต MA line (thickness 2).๐Ÿ”ด Previous High (last N candles).๐ŸŸข Previous Low (last N candles).Also: entry/exit arrows & equity curve shown in backtest.Disclaimer โš ๏ธ๐Ÿ“ŒRisk Warning: This description & code are for educational purposes only. Not financial advice. Trading (Forex, Stocks, Crypto) carries high risk and may lead to full capital loss. You trade at your own risk.Testing: Always backtest & demo test first. Past results โ‰  future profits.Responsibility: Author of this strategy & description is not responsible for your trading decisions or losses.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView