Indicator · Pine Script v6 · On the chart

15M

by etnt· code credited to kruskakli

15M is an intraday chart overlay designed for 15-minute timeframes.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code113
Settings12inputs
LicenceMPL-2.0
Last update1 year ago3 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

113 lines of Pine Script v6 from PineScript/15M.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

15M.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kruskakli
//
// To be used on the 15M chart.
//
//@version=6
indicator("15M", overlay=true)

//
// VWMA
//
plotVWMA = input(defval=true, title="Plot VWMA", group="Intraday Moving Averages")
len = input.int(defval=21, title="VWMA Length", group="Intraday Moving Averages")
VWMA = ta.vwma(hlc3, len)

plot(series=plotVWMA ? VWMA : na,   linewidth=1, color=color.blue,   title="VWMA",    style=plot.style_line)


// DMA5 gives the overall trend
openHours = input(defval=6.5, title="Open: Hours a Day")
plotD5 = input(defval=true, title="Plot DMA5", group="Intraday Moving Averages")
dayMinutes = math.round(openHours * 60)
intraDayLength = 5
dminutes = intraDayLength * dayMinutes
dlen = dminutes / timeframe.multiplier
DMA5 = ta.sma(close, dlen)
plotDMA5 = plotD5

plot(series=plotDMA5 ? DMA5 : na,   linewidth=1, color=color.green,  title="DMA5",   style=plot.style_circles)


//
// A L E R T   C O N D I T I O N
//
// Define the crossing conditions
priceCrossAboveVWMA = close > VWMA and close[1] <= VWMA[1]
priceCrossBelowVWMA = close < VWMA and close[1] >= VWMA[1]

// Register the alerts
alertcondition(condition=priceCrossAboveVWMA, title="Price Cross Above VWMA", message="Price crossed above VWMA")
alertcondition(condition=priceCrossBelowVWMA, title="Price Cross Below VWMA", message="Price crossed below VWMA")

//
// Z E B R A   P A T T E R N
//

// User input
show_zebra = input.bool(defval=true, title="Show Zebra Pattern")

// Timeframe checks
isDaily = timeframe.period == "1D"
is15Min = timeframe.period == "15"

// Get time-based numbers
weekNumber = weekofyear(time)
dayNumber = dayofweek(time)

// For 15M chart, calculate which 15-minute period of the day it is
minutesSinceMidnight = hour * 60 + minute
period15Min = minutesSinceMidnight / 15

// Light gray color with 90% transparency
gee = color.new(#eeeeee, 90)

// Apply zebra pattern:
// - Weekly pattern on Daily chart (even/odd weeks)
// - Daily pattern on 15M chart using continuous counting across weeks
isEvenPeriod = ((weekNumber * 5 + dayNumber) % 2 == 0)  // Multiply week by 5 (trading days) and add day number

bgcolor(title="Zebra Pattern", color=(show_zebra and isEvenPeriod) ? gee : na)


//
// Candlestick patterns
//
plotCandlesticks = input(defval=true, title="Plot Candlestick Patterns", group="Candlestick Patterns")
plotEveningStar = input(defval=true, title="Plot Evening Star", group="Candlestick Patterns")
plotMorningStar = input(defval=true, title="Plot Morning Star", group="Candlestick Patterns")
plotShootingStar = input(defval=true, title="Plot Shooting Star", group="Candlestick Patterns")
plotHammer = input(defval=true, title="Plot Hammer", group="Candlestick Patterns")
plotInvertedHammer = input(defval=true, title="Plot Inverted Hammer", group="Candlestick Patterns")
plotGravestone = input(defval=true, title="Plot Gravestone", group="Candlestick Patterns")

// Candlestick Patterns
isEveningStar=(close[2] > open[2] and math.min(open[1], close[1]) > close[2] and open < math.min(open[1], close[1]) and close < open )

isMorningStar=(close[2] < open[2] and math.max(open[1], close[1]) < close[2] and open > math.max(open[1], close[1]) and close > open )

// The inverted hammer and the shooting star look exactly the same. 
// They both have long upper shadows and small real bodies near the low of the candle,
// with little or no lower shadow.
// The difference is context: A shooting star occurs after a price advance and marks a
// potential turning point lower. An inverted hammer occurs after a price decline and 
// marks a potential turning point higher.
//isShootingStar=(open[1] < close[1] and open > close[1] and high - math.max(open, close) >= math.abs(open - close) * 3 and math.min(close, open) - low <= math.abs(open - close))
isShootingStar=(open[1] < close[1] and ((high - low)>3*(open -close)) and  ((high - close)/(.001 + high - low) > 0.7) and ((high - open)/(.001 + high - low) > 0.7))
isInvertedHammer=open[1]>close[1] and (((high - low)>3*(open -close)) and  ((high - close)/(.001 + high - low) > 0.7) and ((high - open)/(.001 + high - low) > 0.6))

isHammer=((open[1]>close) and (low<low[1]) and ((high - low)>3*(open -close)) and  ((close - low)/(.001 + high - low) > 0.7) and ((open - low)/(.001 + high - low) > 0.7))

isGravestone=(close<math.min(open[1],close[1]) and ((high - low)>3*(open -close)) and  ((high - close)/(.001 + high - low) > 0.9) and ((high - open)/(.001 + high - low) > 0.9))

// Plotting
plotshape(plotCandlesticks and plotEveningStar and isEveningStar, title = "Evening Star", color = color.red, style = shape.arrowdown, text = "Evening\nStar", textcolor = color.red, size = size.normal, location = location.abovebar)

plotshape(plotCandlesticks and plotMorningStar and isMorningStar, title = "Morning Star", color = color.lime, style = shape.arrowup, text = "Morning\nStar", textcolor = color.lime, size = size.normal, location = location.belowbar)

plotshape(plotCandlesticks and plotShootingStar and isShootingStar, title= "Shooting Star", color=color.red, style=shape.arrowdown, textcolor = color.red, size = size.normal, text="Shooting\nStar")
plotshape(plotCandlesticks and plotInvertedHammer and isInvertedHammer, title= "Inverted Hammer", location=location.belowbar, color=color.lime, style=shape.arrowup, textcolor = color.lime, size = size.normal, text="IH")

plotshape(plotCandlesticks and plotHammer and isHammer, title= "Hammer", location=location.belowbar, color=color.lime, style=shape.arrowup, textcolor = color.lime, size = size.normal, text="H")

plotshape(plotCandlesticks and plotGravestone and isGravestone, title= "Gravestone", location=location.belowbar, color=color.lime, style=shape.arrowup, textcolor = color.lime, size = size.normal, text="G")

Overview

15M plots a volume-weighted moving average (VWMA) alongside a simulated 5-day moving average calculated from user-defined daily trading hours. The script detects several classic candlestick patterns, including morning stars, evening stars, hammers, shooting stars, and gravestone dojis, while shading the background with an alternating zebra pattern across trading sessions. Configurable settings allow toggling individual candlestick patterns, moving average lengths, and market hours. Built-in alerts signal price crosses over the VWMA.

Details

Published by

etnt on GitHub

Code credit

kruskakli, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Moving averages, Candlestick patterns, Trend

Markets

Stocks

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
Plot VWMAbooltrueplotVWMA
VWMA Lengthint21len
Open: Hours a Dayfloat6.5openHours
Plot DMA5booltrueplotD5
Show Zebra Patternbooltrueshow_zebra
Plot Candlestick PatternsbooltrueplotCandlesticks
Plot Evening StarbooltrueplotEveningStar
Plot Morning StarbooltrueplotMorningStar
Plot Shooting StarbooltrueplotShootingStar
Plot HammerbooltrueplotHammer
Plot Inverted HammerbooltrueplotInvertedHammer
Plot GravestonebooltrueplotGravestone
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

55 stars

This indicator overlays on the price chart and provides trend and momentum analysis. It calculates and plots three exponential moving averages with fixed periods of 20, 50, and 200 using yellow, orange, and blue colors respectively. The script also computes th

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · Apache-2.0 GitHub repository of Trend & Momentum Analysis

Hanging Man - Bearish

by TWODS-CAPITAL
37 stars

This overlay indicator marks a bearish hanging man candlestick on the price chart. It looks for a small real body sitting in the upper part of the range, a lower shadow at least twice the body, and no upper shadow, and only while an uptrend filter is active. T

Indicator v5 Candlestick patternsTrend
Updated 3 years ago · MIT GitHub repository of Hanging Man - Bearish
29 stars

Zen EMA Pullback Patterns identifies pullback formations relative to an Exponential Moving Average on the price chart. It detects 3-bar pullbacks consisting of three consecutive bearish bars above the EMA or bullish bars below it, as well as 4-bar micro channe

Indicator v6 Moving averagesCandlestick patterns
Updated 2 weeks ago · MIT GitHub repository of Zen EMA Pullback Patterns
15 stars

This indicator plots Bollinger Bands and smoothed HAMA candles on the price chart. It builds each candle from separate moving averages of open, high, low and close, using selectable EMA, SMA or WMA lengths. A simple moving average forms the band basis, and an

Indicator v5 Candlestick patternsMoving averages
Updated 4 months ago · Apache-2.0 GitHub repository of NSDT HAMA Candles with Bollinger Bands

Calculates adaptive arithmetic candles by blending price data with Kaufman Efficiency Ratio smoothing and a linear regression anchor. It measures trend health using a zero-to-hundred Quality Score derived from market efficiency, regression slope, and normalize

Indicator v6 TrendCandlestick patterns
Updated yesterday · MIT GitHub repository of Adaptive Arithmetic Candles + Quality Score [WavesUnchained]

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