OPEN-SOURCE SCRIPT

Step SMA

165
Step SMA – Block-Based Moving Average

Description:
Step SMA is a simple, block-based moving average that shows price trends in discrete steps. Instead of a continuous moving average, it divides the chart into fixed-length blocks and calculates an SMA within each block. At the start of each new block, the average resets, creating a clear “step” effect.

How it Works:
• Block Length: Set the number of bars per block (Block SMA Length).
• Step SMA Calculation: Computes the average of closes within each block. At the end of a block, the calculation resets for the next one.
• Restart Circles: Optional circles mark the first bar of each block for easy visual reference.
• Visual Defaults: The SMA line defaults to bright cyan (width 3) and restart circles default to orange (max size). All colors, line width, and circle size can be customized in the Style tab.

Key Features:
• Stepwise SMA for clear, block-level trend visualization
• Optional restart circles to highlight block starts
• Fully customizable styling via the Style tab
• Simple block length input to adjust sensitivity

Use Cases:
• Easily see short-term trends within discrete blocks
• Identify points where trend averages reset
• Compare block-level trends to standard SMA or EMA

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.