Indicator · Pine Script v5 · On the chart

Wonder2

by turnupdigital· code credited to coderboring

An indicator on the price chart that builds smoothed average prices from a Heikin Ashi style open, high, low and close, then compares a smoothed close with a smoothed open.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code80
Settings4inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago12 Aug 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

80 lines of Pine Script v5 from BuySellIndicators/BUYSELLSIGNALS/Wonder2.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

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

//@version=5
indicator("Wonder2", overlay = true)

// Automatically show the bullish(buy) / bearish(sell) signals
// Automatically show the price trend

wtpLength = input(10   ,"WTP Length") 
sensitivity = input(0    ,"Sensitivity")
scale     = input(1    ,"Scale    ")
distance  = input(100  ,"Distance ")

wtpClose_org     = (open + high + low + close) / 4
var wtpOpen_org  = float(na) 
wtpOpen_org      := (nz(wtpOpen_org[1]) + wtpClose_org[1]) / 2
wtpHigh_org_temp = math.max(wtpOpen_org, wtpClose_org)
wtpHigh_org      = math.max(high, wtpHigh_org_temp)
wtpLow_org_temp  = math.min(wtpOpen_org, wtpClose_org)
wtpLow_org       = math.min(low, wtpLow_org_temp)

wtpOpen = ta.sma(wtpOpen_org, wtpLength) * 100 / distance

popen = plot(wtpOpen_org, "wtp Open org", color.gray)

wtpHigh =  ta.sma(wtpHigh_org, wtpLength) * 100 / distance
wtpLow  =  ta.sma(wtpLow_org, wtpLength) * 100 / distance 

wtpClose = ta.sma(wtpClose_org, wtpLength) * 100 / distance
pclose = plot(wtpClose, "wtp Close", color.gray)

fill(popen, pclose, wtpOpen_org > wtpClose ? color.new(color.green, 75) : color.new(color.red, 75) )

flag_green = wtpClose > wtpOpen
flag_red = wtpClose < wtpOpen
flag_green_1 = wtpClose > wtpOpen and wtpClose[1] <= wtpOpen[1]

flag_red_1 = wtpClose < wtpOpen and wtpClose[1] >= wtpOpen[1]

var bull_pre_1 = float(na) 
var bull_pre_2 = float(na) 
var bull_pre_3 = float(na) 

bull_pre_1 := flag_green_1 ? close : bull_pre_1[1]
bull_pre_2 := flag_green_1 ? bull_pre_1[1] : bull_pre_2[1]
bull_pre_3 := flag_green_1 ? bull_pre_2[1] : bull_pre_3[1]
bull = flag_green ? close > bull_pre_2 * (1+sensitivity/(1000*scale)) : 0

var bearish_pre_1 = float(na)
var bearish_pre_2 = float(na)
var bearish_pre_3 = float(na)

bearish_pre_1 := flag_red_1 ? close : bearish_pre_1[1]
bearish_pre_2 := flag_red_1 ? bearish_pre_1[1] : bearish_pre_2[1]
bearish_pre_3 := flag_red_1 ? bearish_pre_2[1] : bearish_pre_3[1]
bearish   = flag_red   ? close < bearish_pre_2 * (1-sensitivity/(1000*scale)) : 0

isAbove =  bull and not bull[1] ? bull : 0
isBelow =  bearish and not bearish[1] ? bearish : 0

// Clear plots for external system integration
buySignal = isAbove ? 1 : 0
sellSignal = isBelow ? 1 : 0
bullishTrend = flag_green ? 1 : 0
bearishTrend = flag_red ? 1 : 0
trendStrength = math.abs(wtpClose - wtpOpen)

// Human-readable plots for TradingView picker
plot(buySignal, "Buy Signal", color.green, linewidth=2)
plot(sellSignal, "Sell Signal", color.red, linewidth=2)
plot(bullishTrend, "Bullish Trend", color.lime, linewidth=1)
plot(bearishTrend, "Bearish Trend", color.orange, linewidth=1)
plot(trendStrength, "Trend Strength", color.blue, linewidth=1)
plot(wtpClose, "WTP Close", color.gray, linewidth=1)
plot(wtpOpen, "WTP Open", color.silver, linewidth=1)

// Keep original visual signals
plotshape(isAbove, "Buy Shape", shape.triangleup, location.belowbar, color.green, size = size.small)
plotshape(isBelow, "Sell Shape", shape.triangledown, location.abovebar, color.red, size = size.small)

Overview

Green or red shading marks which is higher, and a buy or sell triangle appears when the trend turns and the close clears an earlier reference level by a sensitivity amount. It also plots buy and sell flags, trend flags and trend strength as numeric series for external use.

Details

Published by

turnupdigital on GitHub

Code credit

coderboring, as written in the script's header

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend

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
WTP Lengthint10wtpLength
Sensitivityint0sensitivity
Scale int1scale
Distance int100distance
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
575 stars

This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult

Indicator v5 Support & resistanceTrend
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows with Screener
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 calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

All Candlestick Patterns

by shunjizhan
292 stars

All Candlestick Patterns detects and highlights a wide range of bullish, bearish, and neutral candlestick patterns directly on the price chart. It features optional trend filtering using either a 50-period simple moving average or a combination of 50-period an

Indicator v4 Candlestick patternsTrend
Updated 3 years ago · None stated GitHub repository of All Candlestick Patterns

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