MavilimW Pine Script — Complete TradingView Guide

MavilimW (MAVW) is a six-layer cascaded Weighted Moving Average indicator that plots a colour-coded trend line directly on the price chart in TradingView Pine Script. Developed using a Fibonacci-based period sequence — 3, 5, 8, 13, 21, 34 — it applies six consecutive ta.wma() calls to produce a smooth, low-lag trend filter that turns blue when price is rising and red when falling. Traders use MavilimW as an overlay trend-direction signal, a dynamic support/resistance reference, and a trailing stop-loss anchor across equities, crypto, forex, and futures markets. The default seed parameters of fmal = 3 and smal = 5 make it responsive enough for 5-minute intraday charts while remaining smooth on daily timeframes. This guide covers the complete Pine Script v6 code, every configurable parameter, three practical trading strategies, and step-by-step instructions for generating a customised version with Pineify.

What Is the MavilimW Indicator?

The MavilimW is a cascaded Weighted Moving Average that applies six sequential WMA passes using Fibonacci-derived periods, used to generate a smooth, colour-coded trend-direction line on any TradingView chart.

MavilimW was developed by Turkish retail trader and analyst Mavilim, who published the original concept in the early 2010s on Turkish trading forums. The design principle is straightforward: instead of computing one WMA over a long period (which introduces heavy lag), apply six shorter WMAs in sequence, each operating on the already-smoothed output of the previous pass. The resulting curve retains the responsiveness of a short-period average while shedding the noise that would otherwise distort a single-pass WMA.

Core Formula

Given two seed lengths fmal and smal, all remaining periods are derived by repeated addition — producing the Fibonacci sequence when seeds are 3 and 5:

  • tmal = fmal + smal → 8
  • Fmal = smal + tmal → 13
  • Ftmal = tmal + Fmal → 21
  • Smal = Fmal + Ftmal → 34

The six WMA passes are then chained: M1 = ta.wma(close, 3), M2 = ta.wma(M1, 5), M3 = ta.wma(M2, 8), M4 = ta.wma(M3, 13), M5 = ta.wma(M4, 21), and finally MAVW = ta.wma(M5, 34). Each pass uses the previously smoothed series as its input, multiplying the noise-reduction effect without requiring a single enormous lookback window.

Markets and Timeframes

MavilimW performs reliably on any liquid instrument: US equities, cryptocurrency pairs (BTC/USDT, ETH/USDT), forex majors (EUR/USD, GBP/JPY), and futures (ES, NQ, CL). Concrete timeframe recommendations:

  • 5-minute / 15-minute: default fmal=3, smal=5 — fast intraday trend filter
  • 1-hour: fmal=3, smal=5 or fmal=5, smal=8 — swing setups within a session
  • 4-hour / Daily: fmal=5, smal=8 — multi-day position trades

The indicator is less effective in sideways, low-volatility markets because the six cascaded WMAs tend to flatten and produce frequent direction changes that do not correspond to real trend shifts. Pairing with an ATR-based volatility filter or an RSI extreme reading improves signal quality in ranging conditions.

Pine Script Code Example

The following Pine Script v6 code implements the complete MavilimW indicator with six cascaded ta.wma() calls, automatic Fibonacci period derivation, and a colour-coded plot that turns blue when the line is rising and red when falling. Copy the script, open TradingView Pine Editor (Alt + P), paste it in, and click Add to Chart — the MAVW line appears as an overlay immediately.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify

//@version=6
indicator(title="MavilimW", overlay=true, max_labels_count=500)

// MavilimW: six-layer cascaded Weighted Moving Average
p_ta_mavw(simple int fmal, simple int smal) =>
    tmal = fmal + smal
    Fmal = smal + tmal
    Ftmal = tmal + Fmal
    Smal = Fmal + Ftmal

    M1 = ta.wma(close, fmal)
    M2 = ta.wma(M1, smal)
    M3 = ta.wma(M2, tmal)
    M4 = ta.wma(M3, Fmal)
    M5 = ta.wma(M4, Ftmal)
    MAVW = ta.wma(M5, Smal)

    buySignal  = ta.crossover(MAVW, MAVW[1])
    sellSignal = ta.crossunder(MAVW, MAVW[1])
    [MAVW, buySignal, sellSignal]

[p_ind_1_mavw, p_ind_1_buySignal, p_ind_1_sellSignal] = p_ta_mavw(3, 5)

// Colour: blue when rising, red when falling, yellow when flat
plot(p_ind_1_mavw, "MAVW",
     p_ind_1_mavw > p_ind_1_mavw[1] ? color.rgb(41, 98, 255) :
     p_ind_1_mavw < p_ind_1_mavw[1] ? color.rgb(242, 54, 69) :
     color.yellow, 2)
MavilimW indicator Pine Script code example in TradingView

Parameters

MavilimW exposes only two configurable seed lengths. All other internal periods are automatically derived from these two inputs via the Fibonacci addition formula.

ParameterDefault ValueDescriptionRecommended Range
fmal3First (shortest) WMA seed length. Controls the initial smoothing pass on raw close prices.2 – 5
smal5Second WMA seed length. Together with fmal, determines all downstream period lengths via the Fibonacci addition rule.4 – 8
Tuning scenarios:
  • Scalping (1-min / 5-min): fmal = 2, smal = 3 — periods become 2, 3, 5, 8, 13, 21 for maximum responsiveness.
  • Intraday swing (15-min / 1-hr): fmal = 3, smal = 5 (default) — standard Fibonacci sequence 3–5–8–13–21–34.
  • Daily position trading: fmal = 5, smal = 8 — periods extend to 5, 8, 13, 21, 34, 55, covering one to two months of trading days.

Trading Strategies

Strategy 1: MavilimW Colour-Flip Trend-Follow

Market environment: Trending (strong directional move with expanding ATR)

This strategy enters in the direction of the MavilimW line's colour change and holds until the opposite flip occurs, making it ideal for momentum markets.

Entry conditions (Long):

  1. MavilimW line was red (falling) on the previous bar.
  2. MavilimW line turns blue on the current bar (current value > previous value — buySignal = true).
  3. Price close is above MavilimW at the signal bar.
  4. Pair with EMA 200 — only take longs when close is above the 200-bar EMA.

Exit conditions:

  1. MavilimW flips from blue to red (sellSignal = true).
  2. Or price closes more than 2× ATR(14) below MavilimW.

Strategy 2: MavilimW Dynamic Support Bounce

Market environment: Uptrend with periodic pullbacks

In a confirmed uptrend, price often pulls back to the MavilimW line before resuming higher. This strategy buys the bounce off the indicator line and uses it as a trailing stop.

Entry conditions (Long):

  1. MavilimW has been blue (rising) for at least 5 consecutive bars.
  2. Price low touches or crosses below MavilimW but the candle closes above it.
  3. Combine with RSI(14) > 45 to confirm the pullback has not turned into a reversal.

Exit conditions:

  1. Price closes a full candle body below MavilimW.
  2. MavilimW turns red for two consecutive bars.

Strategy 3: MavilimW + MACD Crossover Confirmation

Market environment: Trending with moderate volatility (any timeframe)

Combining MavilimW's directional signal with a MACD histogram crossover filters out noise and reduces whipsaws in oscillating markets.

Entry conditions (Long):

  1. MavilimW buySignal fires (line turns blue).
  2. MACD histogram (12, 26, 9) crosses from negative to positive on the same bar or within the previous 2 bars.
  3. Price is above the MavilimW line at entry.

Exit conditions:

  1. MavilimW sellSignal fires (line turns red).
  2. MACD histogram turns negative, or a hard stop of 1.5× ATR(14) below entry is hit.
Disclaimer: The strategies above are for educational purposes only. They do not constitute financial or investment advice. Always test any trading strategy on paper or a demo account before using real capital.

How to Generate MavilimW in Pineify

Pineify generates a ready-to-use MavilimW Pine Script in seconds. Follow these five steps:

  1. 1

    Open Pineify at pineify.app

    Navigate to pineify.app and click Generate Indicator to open the indicator builder.

  2. 2

    Click the MavilimW indicator type

    Select MavilimW from the Moving Average category, or search for "MAVW" in the indicator search box.

  3. 3

    Describe your customisation requirements

    Enter parameters such as "fmal = 3, smal = 5, add buy/sell arrow labels, use with 15-minute BTC chart" — Pineify adapts the six-layer WMA code to your specification.

  4. 4

    Copy the generated Pine Script v6 code

    Click the Copy Code button to copy the complete, runnable indicator script to your clipboard — no editing required.

  5. 5

    Adjust and apply in TradingView Pine Editor

    Paste the code into TradingView Pine Editor (Alt + P), click Add to Chart, then open indicator settings to fine-tune fmal and smal for your preferred timeframe.

Frequently Asked Questions

Related Indicators

Ready to Build Your MavilimW Strategy?

Generate a fully customised MavilimW Pine Script in seconds — no coding experience required.

Start for Free