RedK_Momentum-based Step MA
"RedK_Momentum-based Step MA (MoStep_MA)" by RedKTrader, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: RedK_Momentum-based Step MA (MoStep_MA) (v1.0), read 2026-10-12T16:18:06.476Z; source language v4.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
RedK_Momentum-based Step MA (MoStep_MA) by RedKTrader, ported from Pine v4. Overlay indicator with 2 plots and 6 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader -- May 2021
// ------------------------------------------------------------------------------------------------
// Original author: RedKTrader
// Original title: RedK_Momentum-based Step MA (MoStep_MA)
// Licence: MPL-2.0 (the header above is the original notice, kept verbatim)
// Pine version: 4
// Fetched: 2026-10-12
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
// Converted by the FloScript converter from a Pine-compatible v4 source.
indicator("RedK_Momentum-based Step MA", shorttitle="Redk_MoStep MA_v1", overlay=true, timeframe="")
//=======================================================================================================
// this script plots a stepping Moving Average of various types
// The steps are created when a "momentum change" - expressed by a "relatively significant price move" - has been detected - either up or down
// "Significant" is defined as a price move that is relatively large compared to the "recent" average (absolute) price moves within a certain period
// the "strength average" period can be adjusted, as well as the "significance" relative to that average
//=======================================================================================================
//inputs
price = input(title="Source", defval=close, inline="MA Line", group="MA Line")
length = input.int(title="Length", defval=15, minval=1, inline="MA Length", group="MA Line")
ma_type1 = "WMA"
ma_type2 = "EMA"
ma_type3 = "Simple MA"
ma_type4 = "Hull MA"
ma_type = input.string(title="MA Type", options=[ma_type1, ma_type2, ma_type3, ma_type4], defval=ma_type1, inline="MA Length", group="MA Line")
savg1 = "WMA"
savg2 = "EMA"
savg3 = "Simple MA"
mo_length = input.int(title="Length", defval=5, minval=1, inline="Strength", group="Avg Strength")
savg = input.string(title="Average Type", options=[savg1, savg2, savg3], defval=savg1, inline="Strength", group="Avg Strength")
factor = input.float(title="Significance", defval=1.0, minval=0.0, step=0.1, inline="Significance", group="Avg Strength")
//calculate MA
MA = ma_type == ma_type1 ? ta.wma(price, length) : ma_type == ma_type2 ? ta.ema(price, length) : ma_type == ma_type3 ? ta.sma(price, length) : ta.hma(price, length)
// calculate the average Strength of move (note that we're looking at absolute moves here)
c = ta.change(price) / price[1] * 100
avgsom = savg == savg1 ? ta.wma(math.abs(c), mo_length) : savg == savg2 ? ta.ema(math.abs(c), mo_length) : ta.sma(math.abs(c), mo_length)
//apply significance factor -- a factor of zero will yield a regular moving average line.
a = factor * avgsom
// price has to make a move that is higher than or equal to "a" AND that move has to be in the direction of the existing MA Trend
// otherwise we maintain the value of current step
float ssma = 0.0
ssma := math.abs(c) >= a and math.sign(c) == math.sign(ta.change(MA)) ? MA : ssma[1]
// colors & plots
c_MA = color.new(#9598a1, 70)
c_up = color.new(#00ff00, 0)
c_dn = color.new(#ff0000, 0)
c_sw = color.new(#1976d2, 0)
c_ssma = ssma == ssma[1] ? c_sw : ssma > ssma[1] ? c_up : c_dn
plot(MA, "MA", color=c_MA, linewidth=2)
plot(ssma, "MoStep MA", color=c_ssma, linewidth=3)
This file is under the Mozilla Public License 2.0; it is a port of the original by RedKTrader, with the original licence header kept and the changes made for FloScript noted in the file.
- v2
Library refresh 2026-10-14
- v1
Library refresh 2026-10-12
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.