0% found this document useful (0 votes)
45 views2 pages

Pinescript

This document outlines a trading strategy based on Nison's candlestick patterns, implemented in Pine Script for use in trading platforms. It includes definitions for various candlestick patterns, trend detection using moving averages, and conditions for generating buy and sell signals. Additionally, it provides visual outputs for trends and alerts for detected patterns.

Uploaded by

dev.wildblog
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views2 pages

Pinescript

This document outlines a trading strategy based on Nison's candlestick patterns, implemented in Pine Script for use in trading platforms. It includes definitions for various candlestick patterns, trend detection using moving averages, and conditions for generating buy and sell signals. Additionally, it provides visual outputs for trends and alerts for detected patterns.

Uploaded by

dev.wildblog
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//@version=5

indicator("Nison Candlestick Strategy", overlay=true, max_labels_count=500)

// —————— Inputs ——————


fastMA_len = input.int(20, "Fast MA Period")
slowMA_len = input.int(50, "Slow MA Period")
bodyThreshold = input.float(0.25, "Body Size Threshold", minval=0.1, maxval=1)

// —————— Trend Detection ——————


fastMA = ta.sma(close, fastMA_len)
slowMA = ta.sma(close, slowMA_len)
uptrend = fastMA > slowMA
dntrend = fastMA < slowMA

// —————— Candle Anatomy ——————


openPrice = ta.open
closePrice = ta.close
highPrice = ta.high
lowPrice = ta.low
bodySize = math.abs(closePrice - openPrice)
totalRange = highPrice - lowPrice
isBullish = closePrice > openPrice
isBearish = closePrice < openPrice

// —————— Core Patterns (Nison's Criteria) ——————


// 1. Engulfing Patterns
bullishEngulfing = isBullish and isBearish[1] and
closePrice > openPrice[1] and
openPrice < closePrice[1] and
bodySize > bodySize[1]

bearishEngulfing = isBearish and isBullish[1] and


closePrice < openPrice[1] and
openPrice > closePrice[1] and
bodySize > bodySize[1]

// 2. Hammer/Hanging Man
hammer = (lowPrice - math.min(openPrice, closePrice)) >= 2 * bodySize and
(math.max(openPrice, closePrice) - lowPrice) <= totalRange * 0.1 and
dntrend

hangingMan = (highPrice - math.max(openPrice, closePrice)) >= 2 * bodySize and


(math.min(openPrice, closePrice) - lowPrice) <= totalRange * 0.1 and
uptrend

// 3. Morning/Evening Star
morningStar = isBearish[2] and
math.abs(closePrice[1] - openPrice[1]) <= bodySize[2] * 0.3 and
isBullish and
closePrice > (openPrice[2] + closePrice[2])/2

eveningStar = isBullish[2] and


math.abs(closePrice[1] - openPrice[1]) <= bodySize[2] * 0.3 and
isBearish and
closePrice < (openPrice[2] + closePrice[2])/2

// 4. Piercing Line/Dark Cloud Cover


piercingLine = isBearish[1] and isBullish and
openPrice < closePrice[1] and
closePrice > (openPrice[1] + closePrice[1])/2

darkCloud = isBullish[1] and isBearish and


openPrice > closePrice[1] and
closePrice < (openPrice[1] + closePrice[1])/2

// 5. Harami Patterns
bullishHarami = isBearish[1] and
isBullish and
openPrice > closePrice[1] and
closePrice < openPrice[1]

bearishHarami = isBullish[1] and


isBearish and
openPrice < closePrice[1] and
closePrice > openPrice[1]

// 6. Doji Family
doji = bodySize <= totalRange * 0.05
dragonflyDoji = doji and (lowPrice == math.min(openPrice, closePrice))
gravestoneDoji = doji and (highPrice == math.max(openPrice, closePrice))

// 7. Tweezer Tops/Bottoms
tweezerTop = highPrice == highPrice[1] and isBullish[1] and isBearish
tweezerBottom = lowPrice == lowPrice[1] and isBearish[1] and isBullish

// —————— Signal Generation ——————


buyConditions = (hammer or bullishEngulfing or morningStar or piercingLine or
bullishHarami or (dragonflyDoji and dntrend) or tweezerBottom) and
dntrend

sellConditions = (hangingMan or bearishEngulfing or eveningStar or darkCloud or


bearishHarami or (gravestoneDoji and uptrend) or tweezerTop) and
uptrend

// —————— Visual Output ——————


// Trend Background
bgcolor(uptrend ? color.new(color.green, 90) : color.new(color.red, 90))

// Pattern Labels
label.new(bar_index, lowPrice, "★\nBULL", style=label.style_label_up,
color=color.green, textcolor=color.white, size=size.small) when buyConditions
label.new(bar_index, highPrice, "★\nBEAR", style=label.style_label_down,
color=color.red, textcolor=color.white, size=size.small) when sellConditions

// MA Plots
plot(fastMA, "Fast MA", color.aqua)
plot(slowMA, "Slow MA", color.orange)

// —————— Alerts ——————


alertcondition(buyConditions, "Bullish Reversal", "Nison Bullish Pattern Detected")
alertcondition(sellConditions, "Bearish Reversal", "Nison Bearish Pattern
Detected")

You might also like