Indicator · Pine Script v6 · On the chart

FPL Cheatcode

by onlyspx

This indicator draws up to six configurable moving averages on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code199
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update6 months ago1 May 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

199 lines of Pine Script v6 from FPL_Cheatcode.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

FPL_Cheatcode.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OnlySPX
// FPL Cheatcode 

// @version=6
indicator("FPL Cheatcode", "FPL Cheatcode", true)


//--------------------------------------------------------------------
//#region                      Constants
//--------------------------------------------------------------------

var DEFAULT_LINEWIDTH   = 1

// Default timeframe MAs colors (Blues)
var DEFAULT_COLOR1      = color.new(#c9daf8, 0)  // Light Blue - 50 SMA
var DEFAULT_COLOR2      = color.new(#a4c2f4, 0)  // Medium Blue - 50 EMA
var DEFAULT_COLOR3      = color.new(#6d9eeb, 0)  // Deep Blue - 200 SMA
var DEFAULT_COLOR4      = color.new(#3c78d8, 0)  // Dark Blue - 200 EMA

// Hourly MAs colors (Yellow/Orange)
var DEFAULT_COLOR5      = color.new(#FFFF00, 0)  // Bright Yellow - Fast MA (21 EMA)
var DEFAULT_COLOR6      = color.new(#FF8C00, 0)  // Deep Orange - Slow MA (200 SMA)

// Daily MAs colors (Red Theme)
var DEFAULT_COLOR7      = color.new(#FF0000, 0)  // Bright Red - Fast MA (21 EMA)
var DEFAULT_COLOR8      = color.new(#DC143C, 0)  // Crimson - Slow MA (200 SMA)

// VWAP color
var DEFAULT_COLOR_VWAP = color.new(#FF69B4, 0)  // Hot Pink

//#endregion


//--------------------------------------------------------------------
//#region                        Inputs
//--------------------------------------------------------------------

// Groups

g1 = "#1"
g2 = "#2"
g3 = "#3"
g4 = "#4"
g5 = "Hourly 21 EMA"
g6 = "Hourly 200 SMA"
g7 = "Daily 21 EMA"
g8 = "Daily 200 SMA"
g9 = "Preferences"


// Tooltips

tt_timeframe    = "You can display a Moving Average from a higher timeframe. " +
                     "Note: It will be automatically hidden when switching the chart to a timeframe higher than its timeframe."


// Inputs

// Default timeframe MAs (display.none: keep inputs in Settings, omit from chart status line)
i_type_1        = input.string      ("SMA", "Type", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],    group=g1, display=display.none)
i_length1       = input.int         (50,     "Length", 1,                                            group=g1, display=display.none)
i_source1       = input             (close, "Source",                                               group=g1, display=display.none)
i_offset1       = input.int         (0,     "Offset",                                               group=g1, display=display.none)
i_timeframe1    = input.timeframe   ("",    "Timeframe", tooltip=tt_timeframe,                      group=g1, display=display.none)

i_type_2        = input.string      ("EMA", "Type", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],    group=g2, display=display.none)
i_length2       = input.int         (50,    "Length", 1,                                            group=g2, display=display.none)
i_source2       = input             (close, "Source",                                               group=g2, display=display.none)
i_offset2       = input.int         (0,     "Offset",                                               group=g2, display=display.none)
i_timeframe2    = input.timeframe   ("",    "Timeframe", tooltip=tt_timeframe,                      group=g2, display=display.none)

i_type_3        = input.string      ("SMA", "Type", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],    group=g3, display=display.none)
i_length3       = input.int         (200,    "Length", 1,                                            group=g3, display=display.none)
i_source3       = input             (close, "Source",                                               group=g3, display=display.none)
i_offset3       = input.int         (0,     "Offset",                                               group=g3, display=display.none)
i_timeframe3    = input.timeframe   ("",    "Timeframe", tooltip=tt_timeframe,                      group=g3, display=display.none)

i_type_4        = input.string      ("EMA", "Type", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],    group=g4, display=display.none)
i_length4       = input.int         (200,   "Length", 1,                                            group=g4, display=display.none)
i_source4       = input             (close, "Source",                                               group=g4, display=display.none)
i_offset4       = input.int         (0,     "Offset",                                               group=g4, display=display.none)
i_timeframe4    = input.timeframe   ("",    "Timeframe", tooltip=tt_timeframe,                      group=g4, display=display.none)


// Hourly MAs
i_type_5        = input.string      ("EMA", "Type", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],    group=g5, display=display.none)
i_length5       = input.int         (21,    "Length", 1,                                            group=g5, display=display.none)
i_source5       = input             (close, "Source",                                               group=g5, display=display.none)
i_offset5       = input.int         (0,     "Offset",                                               group=g5, display=display.none)
i_timeframe5    = input.timeframe   ("60",  "Timeframe", tooltip=tt_timeframe,                      group=g5, display=display.none)

i_type_6        = input.string      ("SMA", "Type", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],    group=g6, display=display.none)
i_length6       = input.int         (200,   "Length", 1,                                            group=g6, display=display.none)
i_source6       = input             (close, "Source",                                               group=g6, display=display.none)
i_offset6       = input.int         (0,     "Offset",                                               group=g6, display=display.none)
i_timeframe6    = input.timeframe   ("60",  "Timeframe", tooltip=tt_timeframe,                      group=g6, display=display.none)
i_show6         = input.bool        (false, "Show",                                                 group=g6, display=display.none)

// Daily MAs
i_type_7        = input.string      ("EMA", "Type", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],    group=g7, display=display.none)
i_length7       = input.int         (21,    "Length", 1,                                            group=g7, display=display.none)
i_source7       = input             (close, "Source",                                               group=g7, display=display.none)
i_offset7       = input.int         (0,     "Offset",                                               group=g7, display=display.none)
i_timeframe7    = input.timeframe   ("D",   "Timeframe", tooltip=tt_timeframe,                      group=g7, display=display.none)
i_show7         = input.bool        (false, "Show",                                                 group=g7, display=display.none)

i_type_8        = input.string      ("SMA", "Type", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],    group=g8, display=display.none)
i_length8       = input.int         (200,   "Length", 1,                                            group=g8, display=display.none)
i_source8       = input             (close, "Source",                                               group=g8, display=display.none)
i_offset8       = input.int         (0,     "Offset",                                               group=g8, display=display.none)
i_timeframe8    = input.timeframe   ("D",   "Timeframe", tooltip=tt_timeframe,                      group=g8, display=display.none)
i_show8         = input.bool        (false, "Show",                                                 group=g8, display=display.none)

i_enableGaps    = input             (true,  "Wait for timeframe closes",                            group=g9, display=display.none)

//#endregion


//--------------------------------------------------------------------
//#region                       Functions 
//--------------------------------------------------------------------

// @function Get the Moving Average (MA)
// @returns float
f_getMa(string _type, float _source, _length) =>
    switch _type
        "SMA"           => ta.sma(_source, _length)
        "EMA"           => ta.ema(_source, _length)
        "SMMA (RMA)"    => ta.rma(_source, _length)
        "WMA"           => ta.wma(_source, _length)
        "VWMA"          => ta.vwma(_source, _length)


// @function Check if a timeframe is higher or equal than the chart's one
// @returns bool
f_canDisplay(_tf) =>
    timeframe.in_seconds(_tf) >= timeframe.in_seconds()

//#endregion


//--------------------------------------------------------------------
//#region                         Logic
//--------------------------------------------------------------------

var gaps = i_enableGaps ? barmerge.gaps_on : barmerge.gaps_off

// Default timeframe MAs
ma1 = request.security(syminfo.tickerid, i_timeframe1, f_getMa(i_type_1, i_source1, i_length1), gaps=gaps)      // Default MA 1
ma2 = request.security(syminfo.tickerid, i_timeframe2, f_getMa(i_type_2, i_source2, i_length2), gaps=gaps)      // Default MA 2
ma3 = request.security(syminfo.tickerid, i_timeframe3, f_getMa(i_type_3, i_source3, i_length3), gaps=gaps)      // Default MA 3
ma4 = request.security(syminfo.tickerid, i_timeframe4, f_getMa(i_type_4, i_source4, i_length4), gaps=gaps)      // Default MA 4

// Hourly MAs
ma5 = request.security(syminfo.tickerid, i_timeframe5, f_getMa(i_type_5, i_source5, i_length5), barmerge.gaps_off)      // Hourly MA
ma6 = request.security(syminfo.tickerid, i_timeframe6, f_getMa(i_type_6, i_source6, i_length6), barmerge.gaps_off)      // Hourly MA

// Daily MAs
var float ma7 = na
var float ma8 = na

[dailyClose, dailyTime] = request.security(syminfo.tickerid, "D", [close, time], barmerge.gaps_off)
if not na(dailyClose)
    ma7 := request.security(syminfo.tickerid, i_timeframe7, f_getMa(i_type_7, i_source7, i_length7), barmerge.gaps_off)     // Daily MA
    ma8 := request.security(syminfo.tickerid, i_timeframe8, f_getMa(i_type_8, i_source8, i_length8), barmerge.gaps_off)     // Daily MA

if barstate.islastconfirmedhistory
    ma7 := f_getMa(i_type_7, close, i_length7)     // Update with last confirmed bar
    ma8 := f_getMa(i_type_8, close, i_length8)     // Update with last confirmed bar

// VWAP calculation
vwap = ta.vwap(close)

//#endregion


//--------------------------------------------------------------------
//#region                   Plotting & styling
//--------------------------------------------------------------------

// Plot VWAP
plot(vwap, "VWAP", DEFAULT_COLOR_VWAP, DEFAULT_LINEWIDTH, style=plot.style_circles, display=display.all - display.status_line)

// Plot MAs
plot(f_canDisplay(i_timeframe1) ? ma1 : na, "MA #1", DEFAULT_COLOR1, DEFAULT_LINEWIDTH, offset=i_offset1, display=display.all - display.status_line)
plot(f_canDisplay(i_timeframe2) ? ma2 : na, "MA #2", DEFAULT_COLOR2, DEFAULT_LINEWIDTH, offset=i_offset2, display=display.all - display.status_line)
plot(f_canDisplay(i_timeframe3) ? ma3 : na, "MA #3", DEFAULT_COLOR3, DEFAULT_LINEWIDTH, offset=i_offset3, display=display.all - display.status_line)
plot(f_canDisplay(i_timeframe4) ? ma4 : na, "MA #4", DEFAULT_COLOR4, DEFAULT_LINEWIDTH, offset=i_offset4, display=display.all - display.status_line)

// Plot hourly MAs
plot(f_canDisplay(i_timeframe5) ? ma5 : na, "Hourly Fast MA", DEFAULT_COLOR5, DEFAULT_LINEWIDTH, offset=i_offset5, display=display.all - display.status_line)
plot(f_canDisplay(i_timeframe6) and i_show6 ? ma6 : na, "Hourly Slow MA", DEFAULT_COLOR6, DEFAULT_LINEWIDTH, offset=i_offset6, display=display.all - display.status_line)

// Plot daily MAs
plot(f_canDisplay(i_timeframe7) and i_show7 ? ma7 : na, "Daily Fast MA", DEFAULT_COLOR7, DEFAULT_LINEWIDTH, offset=i_offset7, display=display.all - display.status_line)
plot(f_canDisplay(i_timeframe8) and i_show8 ? ma8 : na, "Daily Slow MA", DEFAULT_COLOR8, DEFAULT_LINEWIDTH, offset=i_offset8, display=display.all - display.status_line)

//#endregion

Overview

Each has its own type (SMA, EMA, SMMA, WMA or VWMA), length, source, offset and optional higher timeframe. Defaults are 50 and 200 averages on the chart timeframe plus hourly 21 EMA and 200 SMA lines, with colours grouped by timeframe. Lines from a higher timeframe are hidden when the chart is set above that timeframe. Part of the code was not shown, so any extra features are unknown.

Details

Published by

onlyspx on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Moving averages, Trend

Markets

Indices

Timeframes

M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
TypestringSMAi_type_1
Lengthint50i_length1
Sourcesourceclosei_source1
Offsetint0i_offset1
Timeframetimeframei_timeframe1
TypestringEMAi_type_2
Lengthint50i_length2
Sourcesourceclosei_source2
Offsetint0i_offset2
Timeframetimeframei_timeframe2
TypestringSMAi_type_3
Lengthint200i_length3
Show all 40 settings
SettingTypeDefaultVariable
Sourcesourceclosei_source3
Offsetint0i_offset3
Timeframetimeframei_timeframe3
TypestringEMAi_type_4
Lengthint200i_length4
Sourcesourceclosei_source4
Offsetint0i_offset4
Timeframetimeframei_timeframe4
TypestringEMAi_type_5
Lengthint21i_length5
Sourcesourceclosei_source5
Offsetint0i_offset5
Timeframetimeframe60i_timeframe5
TypestringSMAi_type_6
Lengthint200i_length6
Sourcesourceclosei_source6
Offsetint0i_offset6
Timeframetimeframe60i_timeframe6
Showboolfalsei_show6
TypestringEMAi_type_7
Lengthint21i_length7
Sourcesourceclosei_source7
Offsetint0i_offset7
TimeframetimeframeDi_timeframe7
Showboolfalsei_show7
TypestringSMAi_type_8
Lengthint200i_length8
Sourcesourceclosei_source8
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

948 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 11 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter
330 stars

This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab

Indicator v4 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of 3 EMA/SMA + Cross [Alorse]
318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated 2 days ago · MIT GitHub repository of NVDA Trend Ribbon
257 stars

Donald SPX - Options Trading is an overlay indicator designed for intraday SPX analysis. It plots a 200-period Weighted Moving Average (WMA) on the price chart while evaluating multi-timeframe market structure across Daily, 15-minute, 5-minute, and 2-minute ba

Indicator v5 Moving averagesTrend Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald SPX - Options Trading

60K均線

by TaichiS
219 stars

This multi-timeframe indicator calculates and plots 20-period and 60-period simple moving averages from the 60-minute timeframe directly onto the price chart. The 20-period average displays as a green line, while the 60-period average appears in blue. It serve

Indicator v4 Moving averagesTrend Repaints
Updated 5 years ago · None stated GitHub repository of 60K均線

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers