Indicator · Pine Script v5 · On the chart

IndicatorTemplate A002

by ruckard

This overlay indicator is a reusable template for Ruckard indicators meant to work with Zignaly.

View on GitHub

GitHub stars13on the repository
Pine versionv5runs as is
Lines of code141
Settings10inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago2 Mar 2025

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

141 lines of Pine Script v5 from indicators/zignaly_tutorial/ruckard_zignaly_indicator_template.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

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

//@version=5

// Current version: v20230312 ( A002 )
// Tradingview Public description - BEGIN
//
// This is a template for Ruckard strategies that interact with Zignaly.
// Template sections are not supposed to be modified and are similar to:
// Template foo - BEGIN
// (...)
// Template foo - END
//
// This will be a quick-and-dirty repurpose of this strategy template as an indicator template.
//
// Sections meant to be added with your own strategy logic are similar to:
// ImplementedIndicator foo - BEGIN
// (...)
// ImplementedIndicator foo - END
//
// ImplementedIndicator explanation - BEGIN
// ImplementedIndicator explanation - END
//
// ImplementedIndicator suggested pair and timeframe - BEGIN
// It was originally tested at BTCUSDT pair and 1H timeframe.
// ImplementedIndicator suggested pair and timeframe - END
//
// Template public description - BEGIN
//
// [B]SETTINGS[/B]
// [B]__ SETTINGS - Category1[/B]
// [LIST]
// [*]
// [*]
// [/LIST]
//
// [B]DEFAULT SETTINGS[/B]

// [B] ALERTS SETUP[/B]
//

// ImplementedIndicator public description - BEGIN
// ImplementedIndicator public description - END

// Tradingview Public description - END

indicator('IndicatorTemplate A002', overlay=true, max_bars_back=5000, max_lines_count=500)

// IMPORTS - BEGIN
// IMPORTS - END

// INPUTS - BEGIN

// Template inputs - BEGIN

// HigherTimeframe subindicator Inputs - BEGIN
i_higherTimeframeTrendMaEnforce = input.bool(false, title='Use {False}', group='Enforce Higher Timeframe Trend', inline='HTTimeframeUseShow')
i_showHigherTimeframeTrendMa = input.bool(false, title='Show {False}', group='Enforce Higher Timeframe Trend', inline='HTTimeframeUseShow')

i_higherTimeframeTrendMaTimeframe = input.timeframe('60', title='Timeframe/Offset {1 hour/0 bars}', group='Enforce Higher Timeframe Trend', inline='HTTimeframeOffset')

i_higherTimeframeTrendMaOffset = input.int(0, title='', group='Enforce Higher Timeframe Trend', inline='HTTimeframeOffset')

i_higherTimeframeTrendFastMaType = input.string(defval = 'VWMA', options = ['SMA', 'EMA', 'VWMA', 'RMA', 'WMA'], title = 'Fast MA {EMA/10/close}', group='Enforce Higher Timeframe Trend', inline='HTFastMa')
i_higherTimeframeTrendFastMaLength = input.int(10, minval = 1,  title = '', group='Enforce Higher Timeframe Trend', inline='HTFastMa')
i_higherTimeframeTrendFastMaSource = input.source(close, title = '', group='Enforce Higher Timeframe Trend', inline='HTFastMa')

i_higherTimeframeTrendSlowMaType = input.string(defval = 'VWMA', options = ['SMA', 'EMA', 'VWMA', 'RMA', 'WMA'], title = 'Slow MA {EMA/55/close}', group='Enforce Higher Timeframe Trend', inline='HTSlowMa')
i_higherTimeframeTrendSlowMaLength = input.int(55, minval = 1,  title = '', group='Enforce Higher Timeframe Trend', inline='HTSlowMa')
i_higherTimeframeTrendSlowMaSource = input.source(close, title = '', group='Enforce Higher Timeframe Trend', inline='HTSlowMa')
// HigherTimeframe subindicator Inputs - END

// Template inputs - END

// ImplementedIndicator inputs - BEGIN
// ImplementedIndicator inputs - END

// Strategy - INIT - BEGIN
// Strategy - INIT - END

// Template functions - BEGIN

// MTF - functions - BEGIN
// Taken from `security()` revisited [PineCoders] article.
f_secureSecurity(_symbol, _res, _src) => request.security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)
// MTF - functions - END

// MA - Functions - BEGIN
f_Ma (_maType, _maSource, _maLength) =>
    _maType == "SMA" ? ta.sma(_maSource, _maLength) : _maType == "EMA" ? ta.ema(_maSource, _maLength) : _maType == "VWMA" ? ta.vwma(_maSource, _maLength) : _maType == "RMA" ? ta.rma(_maSource, _maLength) : _maType == "WMA" ? ta.wma(_maSource, _maLength) : _maType == "HMA" ? ta.hma(_maSource, _maLength) : _maSource
// MA - Functions - END

getTrend (_fastMaType, _fastMaLength, _fastMaSource, _slowMaType, _slowMaLength, _slowMaSource, _offset) =>
    _fastMa = f_Ma (_fastMaType, _fastMaSource, _fastMaLength)
    _slowMa = f_Ma (_slowMaType, _slowMaSource, _slowMaLength)
    _trend = _fastMa >= _slowMa

    _trendOffset = _trend[_offset]
    _trendOffset

// Template functions - END

// ImplementedIndicator functions - BEGIN
// ImplementedIndicator functions - END

// Strategy Body - BEGIN
// Template subindicators - BEGIN
// Higher Timeframe Trend subindicator

higherTimeframeTrend = request.security(syminfo.tickerid, i_higherTimeframeTrendMaTimeframe, getTrend (i_higherTimeframeTrendFastMaType, i_higherTimeframeTrendFastMaLength, i_higherTimeframeTrendFastMaSource, i_higherTimeframeTrendSlowMaType, i_higherTimeframeTrendSlowMaLength, i_higherTimeframeTrendSlowMaSource, i_higherTimeframeTrendMaOffset))

int higherTimeframeTrendMaBarIndex = request.security (syminfo.tickerid, i_higherTimeframeTrendMaTimeframe, bar_index)
bool newHigherTimeframeTrendMaBar = higherTimeframeTrendMaBarIndex[1] != higherTimeframeTrendMaBarIndex[0]

var higherTimeframeTrendMaLong = higherTimeframeTrend
var higherTimeframeTrendMaShort = (not higherTimeframeTrend)

if newHigherTimeframeTrendMaBar
    higherTimeframeTrendMaLong := higherTimeframeTrend
    higherTimeframeTrendMaShort := (not higherTimeframeTrend)

// Template subindicators - END

// ImplementedIndicator subindicators - BEGIN
// ImplementedIndicator subindicators - END

// Higher Timeframe Trend - Plot - BEGIN
higherTimeframeTrendMaLongColor = i_showHigherTimeframeTrendMa ? color.new(#00c3ff, transp=0) : na
higherTimeframeTrendMaShortColor = i_showHigherTimeframeTrendMa ? color.new(#ff0062, transp=0) : na
plotshape(higherTimeframeTrendMaLong, title='SideMA Up', style=shape.arrowup, color=higherTimeframeTrendMaLongColor, location=location.top)
plotshape(higherTimeframeTrendMaShort, title='SideMA Down', style=shape.arrowdown, color=higherTimeframeTrendMaShortColor, location=location.top)
// Higher Timeframe Trend - Plot - END

// ImplementedIndicator - Plot - BEGIN

// ImplementedIndicator - Plot - END

// Alerts - BEGIN
// WARN: This might be usually empty because I prefer to write strategies for handling alerts.
// Alerts - END

Overview

The implemented logic sections are empty, so it does not plot signals or manage trades. It exposes a higher-timeframe trend filter built from a fast and a slow moving average, with selectable type, length, source, timeframe, and offset. Users can optionally enforce or show that trend. Higher-timeframe values are requested from the previous bar. Comments suggest BTCUSDT and the one-hour chart.

Details

Published by

ruckard on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages

Markets

Crypto

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
Use {False}boolfalsei_higherTimeframeTrendMaEnforce
Show {False}boolfalsei_showHigherTimeframeTrendMa
Timeframe/Offset {1 hour/0 bars}timeframe60i_higherTimeframeTrendMaTimeframe
i_higherTimeframeTrendMaOffsetint0i_higherTimeframeTrendMaOffset
Fast MA {EMA/10/close}stringVWMAi_higherTimeframeTrendFastMaType
i_higherTimeframeTrendFastMaLengthint10i_higherTimeframeTrendFastMaLength
i_higherTimeframeTrendFastMaSourcesourceclosei_higherTimeframeTrendFastMaSource
Slow MA {EMA/55/close}stringVWMAi_higherTimeframeTrendSlowMaType
i_higherTimeframeTrendSlowMaLengthint55i_higherTimeframeTrendSlowMaLength
i_higherTimeframeTrendSlowMaSourcesourceclosei_higherTimeframeTrendSlowMaSource
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 10 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 yesterday · 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