0% found this document useful (0 votes)
9 views4 pages

Pine Script 3

This document is a Pine Script code for a trading indicator named 'Perfect ABC + Stochastic 9,3'. It identifies bullish and bearish ABC patterns based on price pivots and stochastic values, and provides buy and sell signals along with alerts. The script includes functionalities to draw lines and labels for the identified patterns on a trading chart.

Uploaded by

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

Pine Script 3

This document is a Pine Script code for a trading indicator named 'Perfect ABC + Stochastic 9,3'. It identifies bullish and bearish ABC patterns based on price pivots and stochastic values, and provides buy and sell signals along with alerts. The script includes functionalities to draw lines and labels for the identified patterns on a trading chart.

Uploaded by

aurobinda2
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

//@version=5

indicator("Perfect ABC + Stochastic 9,3", overlay=true, max_lines_count=500,


max_labels_count=500)

//====================================================
// INPUT
//====================================================
len = [Link](5, "Pivot Length")

//====================================================
// STOCHASTIC 9,3
//====================================================
k = [Link](high, low, close, 9)
d = [Link](k, 3)

//====================================================
// PRICE PIVOTS
//====================================================
ph = [Link](high, len, len)
pl = [Link](low, len, len)

//====================================================
// STORE LAST 3 SWINGS
//====================================================
var float pA = na
var float pB = na
var float pC = na

var int bA = na
var int bB = na
var int bC = na

var int tA = na
var int tB = na
var int tC = na

var float sA = na
var float sB = na
var float sC = na

//====================================================
// HIGH PIVOT
//====================================================
if not na(ph)

pA := pB
pB := pC
pC := ph

bA := bB
bB := bC
bC := bar_index - len
tA := tB
tB := tC
tC := 1

sA := sB
sB := sC
sC := d[len]

//====================================================
// LOW PIVOT
//====================================================
if not na(pl)

pA := pB
pB := pC
pC := pl

bA := bB
bB := bC
bC := bar_index - len

tA := tB
tB := tC
tC := -1

sA := sB
sB := sC
sC := d[len]

//====================================================
// BULLISH ABC
//
// A = HIGH
// B = LOW BELOW 20
// C = HIGH ABOVE 20
//====================================================
bullABC =
tA == 1 and
tB == -1 and
tC == 1 and
sB < 20 and
sC > 20 and
pC < pA

//====================================================
// BEARISH ABC
//
// A = LOW
// B = HIGH ABOVE 80
// C = LOW BELOW 80
//====================================================
bearABC =
tA == -1 and
tB == 1 and
tC == -1 and
sB > 80 and
sC < 80 and
pC > pA

//====================================================
// DRAW LAST ABC ONLY
//====================================================
var line ab = na
var line bc = na

var label la = na
var label lb = na
var label lc = na

if bullABC or bearABC

[Link](ab)
[Link](bc)

[Link](la)
[Link](lb)
[Link](lc)

col = bullABC ? [Link] : [Link]

ab := [Link](
bA,
pA,
bB,
pB,
width=3,
color=col)

bc := [Link](
bB,
pB,
bC,
pC,
width=3,
color=col)

la := [Link](
bA,
pA,
"A",
color=col,
textcolor=[Link])
lb := [Link](
bB,
pB,
"B",
color=col,
textcolor=[Link])

lc := [Link](
bC,
pC,
"C",
color=col,
textcolor=[Link])

//====================================================
// SIGNALS
//====================================================
buy =
bullABC and
close > pC

sell =
bearABC and
close < pC

plotshape(
buy,
style=[Link],
color=[Link],
text="BUY",
location=[Link])

plotshape(
sell,
style=[Link],
color=[Link],
text="SELL",
location=[Link])

//====================================================
// ALERTS
//====================================================
alertcondition(
buy,
title="BUY",
message="Bullish ABC + Stochastic")

alertcondition(
sell,
title="SELL",
message="Bearish ABC + Stochastic")

You might also like