Indicator · Pine Script v4 · Own pane

My Script

by ricardosantos79· code credited to RicardoSantos

This indicator uses array operations to track recent high and low values.

View on GitHub

GitHub stars261on the repository
Pine versionv4older, still runs
Lines of code35
Settings1inputs
LicenceNone statedfile: MPL-2.0
Last update4 years ago13 Nov 2021

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

35 lines of Pine Script v4 from beta/arrays/test-003-push_array.pinescript, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

test-003-push_array.pinescript
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos

//@version=4
study("My Script")

f_push(_id, _value)=>
    _e = array.pop(_id)
    array.insert(_id, 0, _value)

f_push_array(_A, _B)=>
    for _i = array.size(_B)-1 to 0
        f_push(_A, array.get(_B, _i))

h = highest(10)
l = lowest(10)
avg = (h+l)/2
newhigh = high >= h ? 1 : 0
newlow = low <= l ? 1 : 0

length = input(6)
var float[] A = array.new_float(length, close)
float[] B = array.new_float(2, 0.0)

if change(newhigh) < 0 or change(newlow) < 0
    //array.set(B, 0, avg)
    array.set(B, 0, h)
    array.set(B, 1, l)
    f_push_array(A, B)

plot(array.sum(A) / length)
plot(array.max(A), color=color.white)
plot(array.min(A), color=color.white)
plot(close, color=color.yellow)
//plot(array.sum(A))

Overview

My Script defines helper functions to insert values into a fixed-size array. On each bar it calculates the 10-bar highest high and lowest low, then checks for the formation of a new high or low using change. When detected it pushes the current high and low values into the array after shifting out the oldest element. The array starts filled with the close price and holds up to 6 elements. It plots the average of the array values, the maximum array value, the minimum array value and the current close price on the chart.

Details

Published by

ricardosantos79 on GitHub

Code credit

RicardoSantos, as written in the script's header

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Support & resistance, Mean reversion

Markets

Any symbol

Timeframes

Any timeframe

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
lengthint6length
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

2 stars

This Pine Script indicator calculates Z-Score based bands for grid trading using a user-selectable moving average. It computes the MA from chosen type, length and source then derives upper and lower bands offset by stddevs. Grid ranges are set by min and max w

Indicator v6 Support & resistanceMean reversion Repaints
Updated 8 months ago · MIT GitHub repository of Grid Bot Z-Score [psyll]

Bias

by JohnsonHsiao
1 stars

The indicator computes bias and mbias curves from typical price relative to highest and lowest closes across periods 3, 6, 9, 12, and 20. It sums the positive and negative biases then negates and plots them as b (red) and s (green) lines in a separate pane to

Indicator v5 Support & resistanceMean reversion
Updated 3 years ago · None stated GitHub repository of Bias
257 stars

This indicator plots auto trade signals for E-mini S&P 500 futures on the price chart. It computes an EMA200 filter along with day ETH RTH session levels and percentage-based entry zones. Signals trigger CALL or PUT cases when price crosses defined thresholds

Indicator v6 TrendSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of Auto Trade Futures ES
55 stars

This Pine Script indicator overlays institutional liquidity levels on the price chart. It identifies order block levels using pivot highs and lows, then draws mean reversion lines from the 20 and 50 period simple moving averages, a volatility range midpoint pr

Indicator v6 Support & resistanceSMC / ICT / price action Repaints
Updated 6 months ago · Apache-2.0 GitHub repository of AAPL Institutional Liquidity Grid
9 stars

This indicator plots an anchored MIDAS support and resistance curve from launch-anchored volume-weighted price on the price chart. It adds two configurable volume-weighted standard-deviation, ATR, or hybrid bands and a topfinder or bottomfinder accelerated exh

Indicator v6 Mean reversionSupport & resistance Repaints
Updated yesterday · MIT GitHub repository of MIDAS 2.0 [WavesUnchained]

VWAP Trader NXi

by eddiebelaval
7 stars

VWAP Trader NXi calculates a daily session-anchored Volume Weighted Average Price along with two custom standard deviation bands on the main price chart. It plots the core VWAP, Value Area bands, outer extension zones with background shading, and the previous

Indicator v5 VolumeVolatility & bands
Updated 3 months ago · None stated GitHub repository of VWAP Trader NXi

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