Herifs Harmonic Pattern
Herifs Harmonic Pattern
// © Herif
indicator(title="[Herif's] Harmonic Patterns Projection ™", shorttitle="[Herif's]
Harmonic Patterns Projections™", overlay=true, max_bars_back=500)//,
default_qty_type=strategy.percent_of_equity, default_qty_value=100,
initial_capital=1000, max_lines_count=500, max_labels_count=500,
commission_type=strategy.commission.percent, commission_value=0.01, margin_long=50,
margin_short=50, max_boxes_count=500)
// study
// define pattern names
pattern_names = array.from('5-0™', 'AB=CD™', 'AB=CD™ Alternate', 'Bat™', 'Bat™
Alternate', 'Butterfly™', 'Crab™', 'Deep Crab™', 'Gartley™ (222)', 'Shark™', '3
Drives', 'ABCD', 'ABCD Extended', 'Cypher', 'Nen Star', '121', 'Double Top',
'Double Bottom')
int pattern_size = array.size(pattern_names)
// Harmonic Pattern™
Pattern_50 = '5-0™' // 2005 by Scott M. Carney,
https://harmonictrader.com/harmonic-patterns/5-0/
Pattern_ABEqCD = 'AB=CD™' // 1998 by Scott M. Carney,
https://harmonictrader.com/harmonic-patterns/abcd-pattern/
Pattern_ABEqCDAlt = 'AB=CD™ Alternate' // 1998 by Scott M. Carney,
https://harmonictrader.com/harmonic-patterns/alternate-abcd-pattern/
Pattern_Bat = 'Bat™' // 2001 by Scott M. Carney,
https://harmonictrader.com/harmonic-patterns/bat-pattern/
Pattern_BatAlt = 'Bat™ Alternate' // 2003 by Scott M. Carney,
https://harmonictrader.com/harmonic-patterns/alternate-bat-pattern/
Pattern_Butterfly = 'Butterfly™' // 1998 by Bryce Gilmore,
https://harmonictrader.com/harmonic-patterns/butterfly-pattern/
Pattern_Crab = 'Crab™' // 2000 by Scott M. Carney,
https://harmonictrader.com/harmonic-patterns/crab-pattern/
Pattern_CrabDeep = 'Deep Crab™' // 2001 by Scott M. Carney,
https://harmonictrader.com/harmonic-patterns/Deep-crab-pattern/
Pattern_Gartley = 'Gartley™ (222)' // 1935 by H. M. Gartley,
https://harmonictrader.com/harmonic-patterns/Gartley-pattern/
Pattern_Shark = 'Shark™' // 2011 by Scott M. Carney,
https://harmonictrader.com/harmonic-patterns/Shark-pattern/
// Other pattern
Pattern_3Drives = '3 Drives' // Robert Prechter,
https://www.forex.com/media/forex/images/education/articles/technical-analysis/
bullish-3-drive-pattern/bearish-3-drive-pattern-rules.svg
Pattern_ABCD = 'ABCD' // https://www.vtad.de/lexikon/Gartley-ab-cd-muster/
Pattern_ABCDExt = 'ABCD Extended' // https://www.vtad.de/lexikon/Gartley-ab-cd-
muster/
Pattern_Cypher = 'Cypher'
Pattern_NenStar = 'Nen Star' // https://forum.mt5.com/Drawthread.php?140480-
ProfitForex-s-Trading-
journal&s=a8ed9b8e82a8c47a548a22b17ce31278&p=12866665&viewfull=1#post12866665
Pattern_121 = '121'
Pattern_DoubleTop = 'Double Top'
Pattern_DoubleBottom = 'Double Bottom'
// Harmonic Pattern™
fiveZero = input.bool(true, title=Pattern_50, group='Harmonic Pattern™',
inline='1')
abEQcd = input.bool(true, title=Pattern_ABEqCD, group='Harmonic Pattern™',
inline='1')
abEQcdAlt = input.bool(true, title=Pattern_ABEqCDAlt, group='Harmonic Pattern™',
inline='1')
bat = input.bool(true, title=Pattern_Bat, group='Harmonic Pattern™', inline='2')
batAlt = input.bool(true, title=Pattern_BatAlt, group='Harmonic Pattern™',
inline='2')
butterfly = input.bool(true, title=Pattern_Butterfly, group='Harmonic Pattern™',
inline='2')
crab = input.bool(true, title=Pattern_Crab, group='Harmonic Pattern™', inline='3')
DeepCrab = input.bool(true, title=Pattern_CrabDeep, group='Harmonic Pattern™',
inline='3')
Gartley = input.bool(true, title=Pattern_Gartley, group='Harmonic Pattern™',
inline='3')
Shark = input.bool(true, title=Pattern_Shark, group='Harmonic Pattern™',
inline='4')
// Other Pattern
OneTwoOne = input.bool(false, title=Pattern_121, group='Other Pattern', inline='1')
threeDrives = input.bool(true, title=Pattern_3Drives, group='Other Pattern',
inline='1')
abcdClassic = input.bool(false, title=Pattern_ABCD, group='Other Pattern',
inline='1')
abcdExt = input.bool(false, title=Pattern_ABCDExt, group='Other Pattern',
inline='1')
Cypher = input.bool(true, title=Pattern_Cypher, group='Other Pattern', inline='2')
NenStar = input.bool(true, title=Pattern_NenStar, group='Other Pattern',
inline='2')
doubleBottomTop = input.bool(false, title='Double Bottom/Top', group='Other
Pattern', inline='2')
MaxRiskPerReward = input.int(30, title='Max Risk Per Reward (Bottom/Top)', step=1,
minval=0, group='Other Pattern')
// Pojected Point of D
float batdtargetratio = input.float(0.886, title='BatBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='1')
float batdtargetratio1 = input.float(0.886, title='BatBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='1')
float bataltdtargetratio = input.float(1.130, title='BatAltBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='2')
float bataltdtargetratio1 = input.float(1.130, title='BatAltBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='2')
float butterflydtargetratio = input.float(1.270, title='ButterflyBull',
minval=0.100, maxval=3.618, group='Harmonic Pattern™ Projected Point of D',
inline='3')
float butterflydtargetratio1 = input.float(1.270, title='ButterflyBear',
minval=0.100, maxval=3.618, group='Harmonic Pattern™ Projected Point of D',
inline='3')
float crabdtargetratio = input.float(1.618, title='CrabBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='4')
float crabdtargetratio1 = input.float(1.618, title='CrabBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='4')
float DeepCrabdtargetratio = input.float(1.618, title='DeepCrabBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='5')
float DeepCrabdtargetratio1 = input.float(1.618, title='DeepCrabBear',
minval=0.100, maxval=3.618, group='Harmonic Pattern™ Projected Point of D',
inline='5')
float Gartleydtargetratio = input.float(0.786, title='GartleyBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='6')
float Gartleydtargetratio1 = input.float(0.786, title='GartleyBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='6')
float Sharkdtargetratio = input.float(1.130, title='SharkBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='7')
float Sharkdtargetratio1 = input.float(1.130, title='SharkBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='7')
float abandcddtargetratio = input.float(1.130, title='AB=CDBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='8')
float abandcddtargetratio1 = input.float(1.130, title='AB=CDBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='8')
float cypherdtargetratio = input.float(0.786, title='CypherBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='9')
float cypherdtargetratio1 = input.float(0.786, title='CypherBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='9')
float abcddtargetratio = input.float(1.618, title='ABCDBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='10')
float abcddtargetratio1 = input.float(1.618, title='ABCDBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='10')
float nenstardtargetratio = input.float(1.272, title='NenStarBull', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='11')
float nenstardtargetratio1 = input.float(1.272, title='NenStarBear', minval=0.100,
maxval=3.618, group='Harmonic Pattern™ Projected Point of D', inline='11')
float fivezerodtargetratio = input.float(1.50, title='5-0Bull', minval=0.0001,
maxval=10.618, group='Harmonic Pattern™ Projected Point of D', inline='12')
float fivezerodtargetratio1 = input.float(0.50, title='5-0Bear', minval=0.0001,
maxval=10.618, group='Harmonic Pattern™ Projected Point of D', inline='12')
// Other Settings
max_pivot_size = input.int(300, title='Max Pivot Size', step=1, group='Other
Settings', inline='6')
// Wave Settings
bullishColor = input.color(color.green, title='Bullish Color', group='Wave
Settings', inline='0')
bearishColor = input.color(color.red, title='Bearish Color', group='Wave Settings',
inline='0')
var WaveCount = 6
fun_pivots(length) =>
float phigh = ta.highestbars(high, length) == 0 ? high : na
float plow = ta.lowestbars(low, length) == 0 ? low : na
dir = 0
iff_1 = plow and na(phigh) ? -1 : dir[1]
dir := phigh and na(plow) ? 1 : iff_1
[dir, phigh, plow]
if phigh or plow
value = dir == 1 ? phigh : plow
bar = bar_index
newDir = dir
if not dirchanged and array.size(WavePivots) >= 1
pivot = array.shift(WavePivots)
pivotbar = array.shift(WavePivotBars)
pivotdir = array.shift(WavePivotDirs)
useNewValues = value * pivotdir < pivot * pivotdir
value := useNewValues ? pivot : value
bar := useNewValues ? pivotbar : bar
bar
if array.size(WavePivots) >= 2
LastPoint = array.get(WavePivots, 1)
newDir := dir * value > dir * LastPoint ? dir * 2 : dir
newDir
array.unshift(WavePivots, value=value)
array.unshift(WavePivotBars, bar)
array.unshift(WavePivotDirs, newDir)
LabelTooltip = string(na)
// Performance data from "Encyclopedia of Chart Patterns (3rd Ed., 2021)" by
Thomas Bulkowski
if LabelText == Pattern_ABEqCD or LabelText == Pattern_ABEqCDAlt
if dir > 0 //Bullish
LabelTooltip := 'Bull Market \nPerformance: ↑ 38,4% \nFailure Rate:
11,6 % \n \nBear Market \nPerformance: ↑ 30,5% \nFailure Rate: 3,7%'
LabelTooltip
else
//Bearish
LabelTooltip := 'Bull Market \nPerformance: ↓ -12,7% \nFailure Rate:
26,3 % \n \nBear Market \nPerformance: ↓ -21,6% \nFailure Rate: 10,2%'
LabelTooltip
if LabelText == Pattern_Bat or LabelText == Pattern_BatAlt
if dir > 0 //Bullish
LabelTooltip := 'Bull Market \nPerformance: ↑ 44,3%% \nFailure Rate:
10,2% \n \nBear Market \nPerformance: ↑ 34,5% \nFailure Rate: 4,3%'
LabelTooltip
else
//Bearish
LabelTooltip := 'Bull Market \nPerformance: ↓ -14,3% \nFailure Rate:
17,7% \n \nBear Market \nPerformance: ↓ -20,2% \nFailure Rate: 4,5%'
LabelTooltip
if LabelText == Pattern_Butterfly
if dir > 0 //Bullish
LabelTooltip := 'Bull Market \nPerformance: ↑ 39,5% \nFailure Rate:
11,4% \n \nBear Market \nPerformance: ↑ 27,8% \nFailure Rate: 2,6%'
LabelTooltip
else
//Bearish
LabelTooltip := 'Bull Market \nPerformance: ↓ -13,0% \nFailure Rate:
27,3% \n \nBear Market \nPerformance: ↓ -20,2% \nFailure Rate: 7,6%'
LabelTooltip
if LabelText == Pattern_Crab or LabelText == Pattern_CrabDeep
if dir > 0 //Bullish
LabelTooltip := 'Bull Market \nPerformance: ↑ 39,1% \nFailure Rate:
7,1% \n \nBear Market \nPerformance: ↑ 32,7% \nFailure Rate: 2,6%'
LabelTooltip
else
//Bearish
LabelTooltip := 'Bull Market \nPerformance: ↓ -14,3% \nFailure Rate:
19,8% \n \nBear Market \nPerformance: ↓ -22,9% \nFailure Rate: 8,9%'
LabelTooltip
if LabelText == Pattern_Gartley
if dir > 0 //Bullish
LabelTooltip := 'Bull Market \nPerformance: ↑ 36,2% \nFailure Rate:
13,5% \n \nBear Market \nPerformance: ↑ 29,2% \nFailure Rate: 5,9%'
LabelTooltip
else
//Bearish
LabelTooltip := 'Bull Market \nPerformance: ↓ -14,1% \nFailure Rate:
21,5% \n \nBear Market \nPerformance: ↓ -23,3% \nFailure Rate: 7,3%'
LabelTooltip
if LabelText == Pattern_NenStar
if dir > 0 //Bullish
LabelTooltip := 'XABCD-Pattern:\nXAB: 0.382 - 0.618 \nABC: 1.130 -
1.414 \nBCD: 1.272 - 2.000 \nXBD: 1.272'
LabelTooltip
else
//Bearish
LabelTooltip := 'XABCD-Pattern:\nXAB: 0.382 - 0.618 \nABC: 1.130 -
1.414 \nBCD: 1.272 - 2.000 \nXBD: 1.272'
LabelTooltip
// (((yxaRatio>= 0.618*err_min and yxaRatio<= 0.618*err_max) and (xabRatio>=
1.272*err_min and xabRatio<= 1.272*err_max)) and ((abcRatio>= 0.618*err_min and
abcRatio<= 0.618*err_max) and (bcdRatio>= 1.272*err_min and bcdRatio<=
1.272*err_max))) or
if LabelText == Pattern_3Drives
if dir > 0 //Bullish
LabelTooltip := 'YXABCD-Pattern:\nYXA=ABC: 0.618 or 0.786\nXAB=BCD:
1.272 or 1.618'
LabelTooltip
else
//Bearish
LabelTooltip := 'YXABCD-Pattern:\nYXA=ABC: 0.618 or 0.786\nXAB=BCD:
1.272 or 1.618'
LabelTooltip
if dir > 0
baseLabel = label.new(x=bar, y=price, text=LabelText, yloc=yloc.price,
color=trendColor, style=label.style_label_up, textcolor=color.black,
size=size.normal, tooltip=LabelTooltip)
baseLabel
if dir < 0
baseLabel = label.new(x=bar, y=price, text=LabelText, yloc=yloc.price,
color=trendColor, style=label.style_label_down, textcolor=color.black,
size=size.normal, tooltip=LabelTooltip)
baseLabel
d = array.get(WavePivots, start + 0)
dBar = array.get(WavePivotBars, start + 0)
dDir = array.get(WavePivotDirs, start + 0)
c = array.get(WavePivots, start + 1)
cBar = array.get(WavePivotBars, start + 1)
cDir = array.get(WavePivotDirs, start + 1)
b = array.get(WavePivots, start + 2)
bBar = array.get(WavePivotBars, start + 2)
bDir = array.get(WavePivotDirs, start + 2)
a = array.get(WavePivots, start + 3)
aBar = array.get(WavePivotBars, start + 3)
aDir = array.get(WavePivotDirs, start + 3)
x = array.get(WavePivots, start + 4)
xBar = array.get(WavePivotBars, start + 4)
xDir = array.get(WavePivotDirs, start + 4)
y = array.get(WavePivots, start + 5)
yBar = array.get(WavePivotBars, start + 5)
yDir = array.get(WavePivotDirs, start + 5)
abcdDirection = a < b and a < c and c < b and c < d and a < d and b < d ? 1
: a > b and a > c and c > b and c > d and a > d and b > d ? -1 : 0
dir = c > d ? 1 : -1
trendColor = dir > 0 ? bullishColor : bearishColor
risk = math.abs(b - d)
reward = math.abs(c - d)
riskPerReward = risk * 100 / (risk + reward)
highPoint = math.max(x, a, b, c, d)
lowPoint = math.min(x, a, b, c, d)
//BatAlt
if batAlt and xabRatio >= 0.382 * err_min and xabRatio <= 0.382 *
err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max
xabcd_pattern := true
array.set(WaveLabels, 4, true)
if dir > 0
array.set(WaveStatsBull, 4, array.get(WaveStatsBear, 4) +
1) // Bullish
else
array.set(WaveStatsBear, 4, array.get(WaveStatsBear, 4) +
1) // Bearish
else
array.set(WaveLabels, 4, false)
//Butterfly ✔
if butterfly and xabRatio >= 0.786 * err_min and xabRatio <= 0.786 *
err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max
xabcd_pattern := true
array.set(WaveLabels, 5, true)
if dir > 0
array.set(WaveStatsBull, 5, array.get(WaveStatsBear, 5) +
1) // Bullish
else
array.set(WaveStatsBear, 5, array.get(WaveStatsBear, 5) +
1) // Bearish
else
array.set(WaveLabels, 5, false)
//Crab
if crab and xabRatio >= 0.382 * err_min and xabRatio <= 0.618 * err_max
and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max
xabcd_pattern := true
array.set(WaveLabels, 6, true)
if dir > 0
array.set(WaveStatsBull, 6, array.get(WaveStatsBear, 6) +
1) // Bullish
else
array.set(WaveStatsBear, 6, array.get(WaveStatsBear, 6) +
1) // Bearish
else
array.set(WaveLabels, 6, false)
//Deep Crab
if DeepCrab and xabRatio >= 0.886 * err_min and xabRatio <= 0.886 *
err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max
xabcd_pattern := true
array.set(WaveLabels, 7, true)
if dir > 0
array.set(WaveStatsBull, 7, array.get(WaveStatsBear, 7) +
1) // Bullish
else
array.set(WaveStatsBear, 7, array.get(WaveStatsBear, 7) +
1) // Bearish
else
array.set(WaveLabels, 7, false)
//Gartley
if Gartley and xabRatio >= 0.618 * err_min and xabRatio <= 0.618 *
err_max and abcRatio >= 0.382 * err_min and abcRatio <= 0.886 * err_max
xabcd_pattern := true
array.set(WaveLabels, 8, true)
if dir > 0
array.set(WaveStatsBull, 8, array.get(WaveStatsBear, 8) +
1) // Bullish
else
array.set(WaveStatsBear, 8, array.get(WaveStatsBear, 8) +
1) // Bearish
else
array.set(WaveLabels, 8, false)
//Cypher ✔
if Cypher and xabRatio >= 0.382 * err_min and xabRatio <= 0.618 *
err_max and abcRatio >= 1.130 * err_min and abcRatio <= 1.414 * err_max
xabcd_pattern := true
array.set(WaveLabels, 13, true)
if dir > 0
array.set(WaveStatsBull, 13, array.get(WaveStatsBear, 13) + 1)
// Bullish
else
array.set(WaveStatsBear, 13, array.get(WaveStatsBear, 13) + 1)
// Bearish
else
array.set(WaveLabels, 13, false)
//Nen Star ✔
if NenStar and xabRatio >= 0.382 * err_min and xabRatio <= 0.618 *
err_max and abcRatio >= 1.130 * err_min and abcRatio <= 1.414 * err_max
xabcd_pattern := true
array.set(WaveLabels, 14, true)
if dir > 0
array.set(WaveStatsBull, 14, array.get(WaveStatsBear, 14) + 1)
// Bullish
else
array.set(WaveStatsBear, 14, array.get(WaveStatsBear, 14) + 1)
// Bearish
else
array.set(WaveLabels, 14, false)
//Shark
if Shark and abcRatio >= 1.13 * err_min and abcRatio <= 1.618 * err_max
and xabRatio >= 0.50 * err_min and xabRatio <= 0.50 * err_max
xabcd_pattern := true
array.set(WaveLabels, 9, true)
if dir > 0
array.set(WaveStatsBull, 9, array.get(WaveStatsBear, 9) +
1) // Bullish
else
array.set(WaveStatsBear, 9, array.get(WaveStatsBear, 9) +
1) // Bearish
else
array.set(WaveLabels, 9, false)
//3 Drives ✔
if threeDrives and (yxaRatio >= 0.618 * err_min and yxaRatio <= 0.618 *
err_max and xabRatio >= 1.272 * err_min and xabRatio <= 1.272 * err_max and
abcRatio >= 0.618 * err_min and abcRatio <= 0.618 * err_max and bcdRatio >= 1.272 *
err_min and bcdRatio <= 1.272 * err_max or yxaRatio >= 0.618 * err_min and yxaRatio
<= 0.618 * err_max and xabRatio >= 1.618 * err_min and xabRatio <= 1.618 * err_max
and abcRatio >= 0.618 * err_min and abcRatio <= 0.618 * err_max and bcdRatio >=
1.618 * err_min and bcdRatio <= 1.618 * err_max or yxaRatio >= 0.786 * err_min and
yxaRatio <= 0.786 * err_max and xabRatio >= 1.272 * err_min and xabRatio <= 1.272 *
err_max and abcRatio >= 0.786 * err_min and abcRatio <= 0.786 * err_max and
bcdRatio >= 1.272 * err_min and bcdRatio <= 1.272 * err_max or yxaRatio >= 0.786 *
err_min and yxaRatio <= 0.786 * err_max and xabRatio >= 1.618 * err_min and
xabRatio <= 1.618 * err_max and abcRatio >= 0.786 * err_min and abcRatio <= 0.786 *
err_max and bcdRatio >= 1.618 * err_min and bcdRatio <= 1.618 * err_max)
yxabcd_pattern := true
array.set(WaveLabels, 10, true)
if dir > 0
array.set(WaveStatsBull, 10, array.get(WaveStatsBear, 10) + 1) //
Bullish
else
array.set(WaveStatsBear, 10, array.get(WaveStatsBear, 10) + 1) //
Bearish
else
array.set(WaveLabels, 10, false)
//5-0 ✔
if fiveZero and xabRatio >= 1.13 * err_min and xabRatio <= 1.618 * err_max
and abcRatio >= 1.618 * err_min and abcRatio <= 2.24 * err_max
yxabcd_pattern := true
array.set(WaveLabels, 0, true)
if dir > 0
array.set(WaveStatsBull, 0, array.get(WaveStatsBear, 0) + 1) //
Bullish
else
array.set(WaveStatsBear, 0, array.get(WaveStatsBear, 0) + 1) //
Bearish
else
array.set(WaveLabels, 0, false)
// 1-2-1 ✔
if OneTwoOne and xabRatio >= 0.618 * err_min and xabRatio <= 0.786 *
err_max and bcdRatio >= 0.5 * err_min and bcdRatio <= 0.618 * err_max
xabcd_pattern := true
array.set(WaveLabels, 15, true)
if dir > 0
array.set(WaveStatsBull, 15, array.get(WaveStatsBear, 15) + 1) //
Bullish
else
array.set(WaveStatsBear, 15, array.get(WaveStatsBear, 15) + 1) //
Bearish
else
array.set(WaveLabels, 15, false)
//AB=CD
if abEQcd and time_ratio >= err_min and time_ratio <= err_max and
price_ratio >= err_min and price_ratio <= err_max and abcdDirection != 0
abcd_pattern := true
array.set(WaveLabels, 1, true)
if dir > 0
array.set(WaveStatsBull, 1, array.get(WaveStatsBear, 1) + 1) //
Bullish
else
array.set(WaveStatsBear, 1, array.get(WaveStatsBear, 1) + 1) //
Bearish
else
array.set(WaveLabels, 1, false)
//AB=CD Alternate
if abEQcdAlt and time_ratio >= 1.272 * err_min and time_ratio <= 1.272 *
err_max and price_ratio >= 1.272 * err_min and price_ratio <= 1.272 * err_max and
abcdDirection != 0 or abEQcdAlt and time_ratio >= 1.618 * err_min and time_ratio <=
1.618 * err_max and price_ratio >= 1.618 * err_min and price_ratio <= 1.618 *
err_max and abcdDirection != 0
abcd_pattern := true
array.set(WaveLabels, 2, true)
if dir > 0
array.set(WaveStatsBull, 2, array.get(WaveStatsBear, 2) + 1) //
Bullis
else
array.set(WaveStatsBear, 2, array.get(WaveStatsBear, 2) + 1) //
Bearish
else
array.set(WaveLabels, 2, false)
//ABCD
if abcdClassic and abcRatio >= 0.618 * err_min and abcRatio <= 0.786 *
err_max and bcdRatio >= 1.272 * err_min and bcdRatio <= 1.618 * err_max and
abcdDirection != 0
abcd_pattern := true
array.set(WaveLabels, 11, true)
if dir > 0
array.set(WaveStatsBull, 11, array.get(WaveStatsBear, 11) + 1) //
Bullish
else
array.set(WaveStatsBear, 11, array.get(WaveStatsBear, 11) + 1) //
Bearish
else
array.set(WaveLabels, 11, false)
//ABCD Ext.
if abcdExt and price_ratio >= 1.272 * err_min and price_ratio <= 1.618 *
err_max and abcRatio >= 0.618 * err_min and abcRatio <= 0.786 * err_max and
abcdDirection != 0
abcd_pattern := true
array.set(WaveLabels, 12, true)
if dir > 0
array.set(WaveStatsBull, 12, array.get(WaveStatsBear, 12) + 1) //
Bullish
else
array.set(WaveStatsBear, 12, array.get(WaveStatsBear, 12) + 1) //
Bearish
else
array.set(WaveLabels, 12, false)
//Double Top/Bottom
if doubleBottomTop and (dDir == 1 and bDir == 2 and cDir == -1 or dDir == -
1 and bDir == -2 and cDir == 1)
bd_pattern := true
array.set(WaveLabels, 16, true)
if dir > 0
array.set(WaveStatsBull, 16, array.get(WaveStatsBear, 16) + 1) //
Bullish
else
array.set(WaveStatsBear, 16, array.get(WaveStatsBear, 16) + 1) //
Bearish
else
array.set(WaveLabels, 16, false)
line.delete(array.get(WaveRatioLines, 1))
line.delete(array.get(WaveRatioLines, 3))
label.delete(array.get(WaveRatios, 1))
label.delete(array.get(WaveRatios, 3))
for i = 0 to 5 by 1
line.delete(array.get(WaveLevels, i))
for i = 0 to 5 by 1
label.delete(array.get(WaveLevellabels, i))
//if (xabcd_pattern[1] and x==x[1] and a==a[1] and b==b[1] and c==c[1])
if xabcd_pattern[1] and a == a[1] and b == b[1] and c == c[1]
label.delete(array.get(WaveLabel, 0))
for i = 0 to 3 by 1
line.delete(array.get(WaveLines, i))
for i = 0 to 4 by 1
label.delete(array.get(WavePoints, i))
for i = 0 to 3 by 1
line.delete(array.get(WaveRatioLines, i))
for i = 0 to 3 by 1
label.delete(array.get(WaveRatios, i))
for i = 0 to 5 by 1
line.delete(array.get(WaveLevels, i))
for i = 0 to 5 by 1
label.delete(array.get(WaveLevellabels, i))
//if (yxabcd_pattern[1] and y==y[1] and x==x[1] and a==a[1] and b==b[1] and
c==c[1])
if yxabcd_pattern[1] and a == a[1] and b == b[1] and c == c[1]
label.delete(array.get(WaveLabel, 0))
for i = 0 to 4 by 1
line.delete(array.get(WaveLines, i))
for i = 0 to 5 by 1
label.delete(array.get(WavePoints, i))
for i = 0 to 1 by 1
line.delete(array.get(WaveRatioLines, i))
for i = 3 to 4 by 1
line.delete(array.get(WaveRatioLines, i))
for i = 0 to 1 by 1
label.delete(array.get(WaveRatios, i))
for i = 3 to 4 by 1
label.delete(array.get(WaveRatios, i))
for i = 0 to 5 by 1
line.delete(array.get(WaveLevels, i))
for i = 0 to 5 by 1
label.delete(array.get(WaveLevellabels, i))
if bd_pattern
array.set(WaveType, 0, dir)
// draw points
if dir > 0 //and (TradeDirection == 'long' or TradeDirection == 'all')
// Bullish
// draw main lines
if DrawLines == true
bd = line.new(y1=b, y2=d, x1=bBar, x2=dBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 5, bd)
if DrawLetters == true
point_b = label.new(x=bBar, y=b - math.abs((b - c) * 0.1),
text='1', textcolor=trendColor, size=size.large, style=label.style_none)
point_d = label.new(x=dBar, y=d - math.abs((b - c) * 0.1),
text='2', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 2, point_b)
array.set(WavePoints, 4, point_d)
if dir < 0 //and (TradeDirection == 'short' or TradeDirection == 'all')
// Bearish
// draw main lines
if DrawLines == true
bd = line.new(y1=b, y2=d, x1=bBar, x2=dBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 5, bd)
if DrawLetters == true
point_b = label.new(x=bBar, y=b + math.abs((b - c) * 0.2),
text='1', textcolor=trendColor, size=size.large, style=label.style_none)
point_d = label.new(x=dBar, y=d + math.abs((b - c) * 0.2),
text='2', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 2, point_b)
array.set(WavePoints, 4, point_d)
if abcd_pattern
array.set(WaveType, 0, dir)
if abEQcd == true
float xd_ycalc = 0.0000
if b < a
xd_ycalc := math.abs(b - b * abandcddtargetratio / 100)
if b > a
xd_ycalc := math.abs(b + b * abandcddtargetratio1 / 100)
ac = line.new(y1=a, y2=c, x1=aBar, x2=cBar, color=trendColor,
width=WaveWidth, style=line.style_dashed)
array.set(WaveLines, 3, ac)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
//xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
//array.set(WaveLines, 0, xb)
abbc = linefill.new(ab, bc, color.new(trendColor,
majorFillTransparency))
acbc = linefill.new(ac, bc, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bdbc = linefill.new(bd, bc, color.new(trendColor,
majorFillTransparency))
if abcdClassic == true
float xd_ycalc = 0.0000
if b < a
xd_ycalc := math.abs(b - b * abcddtargetratio / 100)
if b > a
xd_ycalc := math.abs(b + b * abcddtargetratio1 / 100)
ac = line.new(y1=a, y2=c, x1=aBar, x2=cBar, color=trendColor,
width=WaveWidth, style=line.style_dashed)
array.set(WaveLines, 3, ac)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
//xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
//array.set(WaveLines, 0, xb)
abbc = linefill.new(ab, bc, color.new(trendColor,
majorFillTransparency))
acbc = linefill.new(ac, bc, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bdbc = linefill.new(bd, bc, color.new(trendColor,
majorFillTransparency))
if dir > 0 //Bullish
// Draw main lines
if DrawLines == true
fun_DrawLines_abcd(a, b, c, d, aBar, bBar, cBar, dBar,
trendColor, WaveWidth, WaveLineStyle, WaveLines)
// Draw points
if DrawLetters == true
point_a = label.new(x=aBar, y=a + math.abs((b - c) * 0.1),
text='A', textcolor=trendColor, size=size.large, style=label.style_none)
point_b = label.new(x=bBar, y=b - math.abs((b - c) * 0.25),
text='B', textcolor=trendColor, size=size.large, style=label.style_none)
point_c = label.new(x=cBar, y=c + math.abs((b - c) * 0.1),
text='C', textcolor=trendColor, size=size.large, style=label.style_none)
point_d = label.new(x=dBar, y=d - math.abs((b - c) * 0.25),
text='D', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 1, point_a)
array.set(WavePoints, 2, point_b)
array.set(WavePoints, 3, point_c)
array.set(WavePoints, 4, point_d)
if DrawRatioAndLines == true
fun_DrawRatioAndLines_abcd(a, b, c, d, aBar, bBar, cBar, dBar,
RatioColor, RatioLineWidth, RatioLineStyle, WaveRatioLines, WaveRatios, xabRatio,
abcRatio, bcdRatio, xadRatio, yxaRatio) // draw ratios and RatioLines
if DrawTargetLevels == true
fun_DrawTarget(c, d, dBar, levelSL, levelD, levelT1, levelT2,
levelT3, levelT4, WaveLevels, WaveLevellabels, levelWidth) // call function
if xabcd_pattern
array.set(WaveType, 0, dir)
if bat == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x + x * batdtargetratio / 100)
if x > a
xd_ycalc := math.abs(x - x * batdtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if batAlt == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x - x * bataltdtargetratio / 100)
if x > a
xd_ycalc := math.abs(x + x * bataltdtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if butterfly == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x - x * butterflydtargetratio / 100)
if x > a
xd_ycalc := math.abs(x + x * butterflydtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if crab == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x - x * crabdtargetratio / 100)
if x > a
xd_ycalc := math.abs(x + x * crabdtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if DeepCrab == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x - x * DeepCrabdtargetratio / 100)
if x > a
xd_ycalc := math.abs(x + x * DeepCrabdtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if Gartley == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x + x * Gartleydtargetratio / 100)
if x > a
xd_ycalc := math.abs(x - x * Gartleydtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if Cypher == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x + x * cypherdtargetratio / 100)
if x > a
xd_ycalc := math.abs(x - x * cypherdtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if NenStar == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x - x * nenstardtargetratio / 100)
if x > a
xd_ycalc := math.abs(x + x * nenstardtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if Shark == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(x + x * Sharkdtargetratio / 100)
if x > a
xd_ycalc := math.abs(x - x * Sharkdtargetratio1 / 100)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
if yxabcd_pattern
array.set(WaveType, 0, dir)
if fiveZero == true
float xd_ycalc = 0.0000
if x < a
xd_ycalc := math.abs(b + b * fivezerodtargetratio / 100)
if x > a
xd_ycalc := math.abs(b - b * fivezerodtargetratio1 / 100)
yx = line.new(y1=y, y2=x, x1=yBar, x2=xBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, yx)
xa = line.new(y1=x, y2=a, x1=xBar, x2=aBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 0, xa)
ab = line.new(y1=a, y2=b, x1=aBar, x2=bBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 1, ab)
bc = line.new(y1=b, y2=c, x1=bBar, x2=cBar, color=trendColor,
width=WaveWidth, style=WaveLineStyle)
array.set(WaveLines, 2, bc)
bd = line.new(y1=b, y2=xd_ycalc, x1=bBar, x2=dBar + levelWidth,
color=color.new(trendColor, bdFillTransparency), width=RatioLineWidth,
style=line.style_dashed)
array.set(WaveLines, 1, bd)
cd = line.new(y1=c, y2=xd_ycalc, x1=cBar, x2=dBar + levelWidth,
color=color.new(trendColor, cdFillTransparency), width=WaveWidth,
style=line.style_dashed)
array.set(WaveLines, 3, cd)
cdt = line.new(y1=xd_ycalc, y2=xd_ycalc, x1=dBar, x2=dBar +
levelWidth, color=trendColor, width=1, style=line.style_dotted)
xb = line.new(y1=x, y2=b, x1=xBar, x2=bBar, color=RatioColor,
width=RatioLineWidth, style=RatioLineStyle)
array.set(WaveLines, 0, xb)
xaab = linefill.new(xa, ab, color.new(trendColor,
majorFillTransparency))
xbab = linefill.new(xb, ab, color.new(trendColor,
majorFillTransparency))
bccd = linefill.new(bc, cd, color.new(trendColor,
majorFillTransparency))
bcbd = linefill.new(bc, bd, color.new(trendColor,
majorFillTransparency))
// draw points
if dir > 0 // Bullish
if DrawLines == true
fun_DrawLines_yxabcd(y, x, a, b, c, d, yBar, xBar, aBar, bBar,
cBar, dBar, trendColor, WaveWidth, WaveLineStyle, WaveLines) // draw lines
if DrawLetters == true
point_y = label.new(x=yBar, y=y + math.abs((b - c) * 0.1),
text='Y', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 5, point_y)
point_x = label.new(x=xBar, y=x - math.abs((b - c) * 0.2),
text='X', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 0, point_x)
point_a = label.new(x=aBar, y=a + math.abs((b - c) * 0.1),
text='A', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 1, point_a)
point_b = label.new(x=bBar, y=b - math.abs((b - c) * 0.2),
text='B', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 2, point_b)
point_c = label.new(x=cBar, y=c + math.abs((b - c) * 0.1),
text='C', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 3, point_c)
point_d = label.new(x=dBar, y=d - math.abs((b - c) * 0.2),
text='D', textcolor=trendColor, size=size.large, style=label.style_none)
array.set(WavePoints, 4, point_d)
if DrawRatioAndLines == true
fun_DrawRatioAndLines_yxabcd(y, x, a, b, c, d, yBar, xBar,
aBar, bBar, cBar, dBar, RatioColor, RatioLineWidth, RatioLineStyle, WaveRatioLines,
WaveRatios, xabRatio, abcRatio, bcdRatio, xadRatio, yxaRatio) // draw RatioLines
if DrawTargetLevels == true
fun_DrawTarget(c, d, dBar, levelSL, levelD, levelT1, levelT2,
levelT3, levelT4, WaveLevels, WaveLevellabels, levelWidth) // call function
if DrawPatternNames == true
array.set(WaveLabel, 0, fun_get_label(WaveLabels, dir, d, dBar))
//for i = 1 to WaveCount
//fun_(("Wave"+tostring(i)+"Length"), ("WavePivots"+tostring(i)),
("WavePivotBars"+tostring(i)), ("WavePivotDirs"+tostring(i)))