TP11(TP11FE)//version=6
indicator("อินดี้ tp 11 (TP11FE)", overlay=true, scale=scale.right, max_lines_count=500, max_labels_count=500)
//================ Inputs ================
group200 = "EMA200 / 5up-5down"
emaLen200 = input.int(200, "EMA length (ฐาน EMA200)", minval=1, group=group200)
show200Mid = input.bool(true, "แสดง EMA200 (midline)", group=group200)
show200_5u = input.bool(true, "แสดง 5up (จาก EMA200)", group=group200)
show200_5d = input.bool(true, "แสดง 5down (จาก EMA200)", group=group200)
group85 = "EMA85 (เฉพาะ 4 up / 4 down)"
emaLen85 = input.int(85, "EMA length สำหรับเส้น 4up/4down", minval=1, group=group85)
show85_4u = input.bool(true, "แสดง EMA85 — 4 up", group=group85)
show85_4d = input.bool(true, "แสดง EMA85 — 4 down", group=group85)
group35 = "EMA35"
emaLen35 = input.int(35, "EMA35 length", minval=1, group=group35)
showEMA35 = input.bool(true, "แสดง EMA35", group=group35)
groupPNR = "PNR (Percentile Nearest Rank)"
pnrLen = input.int(15, "PNR length (จำนวนแท่งในหน้าต่าง)", minval=1, group=groupPNR)
pnrPerc = input.int(50, "PNR Percentile (0–100)", minval=0, maxval=100, group=groupPNR)
pnrSrc = input.source(close, "PNR Source", group=groupPNR)
showPNR = input.bool(true, "แสดงเส้น PNR", group=groupPNR)
groupDSI = "Dynamic Structure Indicator (DSI)"
showDSI = input.bool(true, "แสดง DSI (โซน S/R ไดนามิก)", group=groupDSI)
atrMovement = input.float(1.0, "ATR Movement Required", step=0.5, group=groupDSI)
lookback = input.int(25, "High/Low Lookback", step=5, group=groupDSI)
maxZoneSize = input.float(2.5, "Max Zone Size (เทียบกับ ATR)", step=0.5, group=groupDSI)
newStructureReset = input.int(25, "Zone Update Count Before Reset", step=5, group=groupDSI)
drawPreviousStructure = input.bool(true, "Draw Previous Structure (RS/SR)", group=groupDSI)
groupFE = "FE Settings"
feLenBars = input.int(35, "FE length (bars) จาก P3", minval=5, group=groupFE)
feLife = input.int(500, "อายุเส้น FE (bars) ก่อนลบ", minval=50, group=groupFE)
showFE = input.bool(true, "แสดงเส้น FE", group=groupFE)
colBand = input.color(color.teal, "สีเส้น 95/105", group=groupFE)
colBandFill = input.color(color.new(color.teal, 85), "สีแถบ 95–105", group=groupFE)
col1618 = input.color(color.orange, "สีเส้น 161.8", group=groupFE)
col2618 = input.color(color.fuchsia, "สีเส้น 261.8", group=groupFE)
groupP1P2P3 = "Options for P1/P2/P3"
p1Lookback = input.int(200, "กรอบย้อนซ้ายสูงสุดสำหรับหา P1", minval=20, group=groupP1P2P3)
useCloseForEMA35 = input.bool(false, "EMA35 ใช้ close (แทน effClose)", group=groupP1P2P3)
groupPerf = "Performance / Safety"
p3MaxWindowBars = input.int(600, "จำกัดจำนวนแท่งสูงสุดที่สแกนหา P3", minval=100, maxval=2000, step=50, group=groupPerf)
//================ Colors ================
colMid200 = color.rgb(100, 50, 0)
col5band = color.rgb(200,170, 0)
col85_4 = color.rgb(90, 140, 230)
col35 = color.new(color.blue, 0)
colPNR = color.rgb(255, 17, 0)
//================ Core helpers ================
float effClose = close >= open ? math.max(open, close) : math.min(open, close)
f_bodyTop(_o, _c) => math.max(_o, _c)
f_bodyBot(_o, _c) => math.min(_o, _c)
f_midBody_at(_i) =>
float bt = f_bodyTop(open , close )
float bb = f_bodyBot(open , close )
(bt + bb) / 2.0
f_core(_len) =>
float mid = ta.ema(effClose, _len)
float _dev = ta.stdev(effClose, _len)
float devS = _dev == 0.0 ? na : _dev
float plus = na(mid) or na(devS) ? na : (close > mid ? (close - mid) / devS : 0.0)
float minus = na(mid) or na(devS) ? na : (close < mid ? (mid - close) / devS : 0.0)
float mmax = na(plus) or na(minus) ? na : math.max(plus, minus)
float lm = ta.ema(mmax, _len)
//================ EMA200 + 5up/5down ================
= f_core(emaLen200)
phi_adj = 1.38196601
float fiveUp_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 + (lm200 * phi_adj) * dev200
float fiveDown_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 - (lm200 * phi_adj) * dev200
plot(show200_5d ? fiveDown_200 : na, title="5down (EMA200)", color=col5band, linewidth=3)
plot(show200Mid ? mid200 : na, title="EMA200 (midline)", color=colMid200, linewidth=3)
plot(show200_5u ? fiveUp_200 : na, title="5up (EMA200)", color=col5band, linewidth=3)
//================ EMA85 — เฉพาะ 4up/4down ================
= f_core(emaLen85)
float up4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 + lm85 * dev85
float down4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 - lm85 * dev85
plot(show85_4u ? up4_85 : na, title="EMA85 — 4 up", color=col85_4, linewidth=2)
plot(show85_4d ? down4_85 : na, title="EMA85 — 4 down", color=col85_4, linewidth=2)
//================ EMA35 ========================
float ema35 = useCloseForEMA35 ? ta.ema(close, emaLen35) : ta.ema(effClose, emaLen35)
plot(showEMA35 ? ema35 : na, title="EMA35", color=col35, linewidth=2)
//================ PNR ==========================
float pnr = na
if bar_index >= pnrLen - 1
float win = array.new_float()
for i = 0 to pnrLen - 1
array.push(win, pnrSrc)
array.sort(win)
int idx = int(math.round(pnrPerc / 100.0 * pnrLen)) - 1
idx := idx < 0 ? 0 : (idx > pnrLen - 1 ? pnrLen - 1 : idx)
pnr := array.get(win, idx)
plot(showPNR ? pnr : na, title="PNR", color=colPNR, linewidth=2)
//==================== P1 / P2 / P3 + FE ====================//
// ---------- Utilities ----------
isGreen_at(i) => close > open
isRed_at(i) => close < open
bodyTop_at(i) => f_bodyTop(open, close)
bodyBot_at(i) => f_bodyBot(open, close)
aboveEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bt >= midv) : ((bt - math.max(bb, midv)) / body >= 0.75)
belowEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bb <= midv) : ((math.min(bt, midv) - bb) / body >= 0.75)
// ------- ตรวจ P2 (Long) ที่ offset i -------
isP2Long_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool green = isGreen_at(i)
float fu = fiveUp_200
float bb = bodyBot_at(i)
bool bodyAbove5 = not na(fu) and bb >= fu
float M2 = f_midBody_at(i)
bool leftOK = close <= M2 and close <= M2
bool rightOK = close <= M2 and close <= M2
hasRoom and green and bodyAbove5 and leftOK and rightOK
// ------- ตรวจ P2 (Short) ที่ offset i -------
isP2Short_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool red = isRed_at(i)
float fd = fiveDown_200
float bt = bodyTop_at(i)
bool bodyBelow5 = not na(fd) and bt <= fd
float M2s = f_midBody_at(i)
bool leftOK = close >= M2s and close >= M2s
bool rightOK = close >= M2s and close >= M2s
hasRoom and red and bodyBelow5 and leftOK and rightOK
// ------- หา P1 จากสตรีค (Long) โดยใช้ offset ของ P2 -------
f_findP1_long_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isGreen_at(i) and aboveEMA75_at(i)
foundRight := i
break
if na(foundRight)
int loBar = p2Off
float loVal = bodyBot_at(p2Off)
for i = p2Off to maxOff
float v = bodyBot_at(i)
if v < loVal
loVal := v
loBar := i
[open , loBar]
else
int j = foundRight
while j < 5000 and isGreen_at(j+1) and aboveEMA75_at(j+1)
j += 1
[open , j]
// ------- หา P1 (Short) โดยใช้ offset ของ P2 -------
f_findP1_short_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isRed_at(i) and belowEMA75_at(i)
foundRight := i
break
if na(foundRight)
int hiBar = p2Off
float hiVal = bodyTop_at(p2Off)
for i = p2Off to maxOff
float v = bodyTop_at(i)
if v > hiVal
hiVal := v
hiBar := i
[open , hiBar]
else
int j = foundRight
while j < 5000 and isRed_at(j+1) and belowEMA75_at(j+1)
j += 1
[open , j]
// ------- เลือก P3 ภายในหน้าต่าง (offset ช่วง start..end; step บวกเสมอ) -------
f_bin(v) => math.round(v / syminfo.mintick) * syminfo.mintick
f_pickP3_window(winStartOff, winEndOff, isLong) =>
// --- Normalize window ---
int s0 = math.min(winStartOff, winEndOff)
int e0 = math.max(winStartOff, winEndOff)
// --- Clamp to Pine's history limit (0..10000) และไม่เกินจำนวนแท่งที่มีอยู่ ---
int eCap = math.min(e0, math.min(10000, bar_index))
int sMin = math.max(0, s0)
// --- จำกัดความกว้างหน้าต่างตาม p3MaxWindowBars ---
int sTmp = math.max(eCap - p3MaxWindowBars + 1, sMin)
int s = math.max(0, math.min(sTmp, eCap))
int e = eCap
// ถ้า window กลายเป็นว่าง ให้คืนค่า na
if e < 0 or s > e
else
float levels = array.new_float()
int counts = array.new_int()
int firstI = array.new_int()
int maxRun = array.new_int()
float minOpen = open
int minIdx = s
float maxOpen = open
int maxIdx = s
float prevBin = na
int curRun = 0
for t = s to e
float bin = f_bin(open )
int idx = array.indexof(levels, bin)
if idx == -1
array.push(levels, bin)
array.push(counts, 1)
array.push(firstI, t)
array.push(maxRun, 1)
curRun := 1
else
array.set(counts, idx, array.get(counts, idx) + 1)
if not na(prevBin) and bin == prevBin
curRun += 1
else
curRun := 1
int prevMax = array.get(maxRun, idx)
if curRun > prevMax
array.set(maxRun, idx, curRun)
if open < minOpen
minOpen := open
minIdx := t
if open > maxOpen
maxOpen := open
maxIdx := t
prevBin := bin
// หา cluster ≥ 3
int best = na
int bestCnt = 0
int bestRun = 0
int bestFirst = na
int L = array.size(levels)
if L > 0
for m = 0 to L - 1
int c = array.get(counts, m)
if c >= 3
int r = array.get(maxRun, m)
int f = array.get(firstI, m)
if c > bestCnt or (c == bestCnt and (r > bestRun or (r == bestRun and f < bestFirst)))
best := m
bestCnt := c
bestRun := r
bestFirst := f
if not na(best)
int pickOff = array.get(firstI, best)
[open , pickOff]
else
if isLong
[open , minIdx]
else
[open , maxIdx]
// --------- สถานะ / ค่าที่ต้องจำ ---------
var int L_stage = 0
var int L_P2Abs = na
var float L_P2Close = na
var float L_M2 = na
var float L_P1Open = na
var int S_stage = 0
var int S_P2Abs = na
var float S_P2Close = na
var float S_M2 = na
var float S_P1Open = na
// --------- FE storage ---------
var line FE_l95 = array.new_line()
var line FE_l105 = array.new_line()
var line FE_l161 = array.new_line()
var line FE_l261 = array.new_line()
var linefill FE_fill = array.new_linefill()
var int FE_born = array.new_int()
f_add_fe_set(p3Abs, y95, y105, y161, y261) =>
int x1 = p3Abs, x2 = p3Abs + feLenBars
line l95 = line.new(x1, y95, x2, y95, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l105 = line.new(x1, y105, x2, y105, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l161 = line.new(x1, y161, x2, y161, xloc=xloc.bar_index, extend=extend.none, color=col1618, width=2)
line l261 = line.new(x1, y261, x2, y261, xloc=xloc.bar_index, extend=extend.none, color=col2618, width=2)
linefill lf = linefill.new(l95, l105, color=colBandFill)
array.push(FE_l95, l95)
array.push(FE_l105, l105)
array.push(FE_l161, l161)
array.push(FE_l261, l261)
array.push(FE_fill, lf)
array.push(FE_born, p3Abs)
f_delete_fe_index(idx) =>
linefill.delete(array.get(FE_fill, idx))
line.delete(array.get(FE_l95, idx))
line.delete(array.get(FE_l105, idx))
line.delete(array.get(FE_l161, idx))
line.delete(array.get(FE_l261, idx))
array.remove(FE_l95, idx)
array.remove(FE_l105, idx)
array.remove(FE_l161, idx)
array.remove(FE_l261, idx)
array.remove(FE_fill, idx)
array.remove(FE_born, idx)
// ลบตามอายุ (เดินหน้าแล้วอ้างย้อนกลับ เพื่อเลี่ยง step ติดลบ)
if array.size(FE_born) > 0
int n = array.size(FE_born)
for k = 0 to n - 1
int i = n - 1 - k
int born = array.get(FE_born, i)
if bar_index >= born + feLife
f_delete_fe_index(i)
// --------- เครื่องจักรสถานะ: Long ---------
int candL = 2
if bar_index >= 4 and L_stage == 0
if isP2Long_at(candL)
L_P2Abs := bar_index - candL
L_P2Close := close
L_M2 := f_midBody_at(candL)
= f_findP1_long_rel(candL)
L_P1Open := __p1OpenTmp
L_stage := 1
if L_stage == 1
int p2Ago = bar_index - L_P2Abs
if p2Ago >= 1 and close <= L_M2
L_stage := 2
if L_stage == 2
if isGreen_at(0) and close >= L_M2
int p2Ago = bar_index - L_P2Abs
int wStart = 0
int wEnd = math.max(p2Ago - 1, 0) // ไม่รวมแท่ง P2 เอง
= f_pickP3_window(wStart, wEnd, true)
int p3Abs = bar_index - p3Off
float wave = L_P2Close - L_P1Open
if showFE and wave > 0 and not na(p3Open)
float y95 = p3Open + 0.95 * wave
float y105 = p3Open + 1.05 * wave
float y1618 = p3Open + 1.618 * wave
float y2618 = p3Open + 2.618 * wave
f_add_fe_set(p3Abs, y95, y105, y1618, y2618)
L_stage := 0
L_P2Abs := na, L_P2Close := na, L_M2 := na, L_P1Open := na
// --------- เครื่องจักรสถานะ: Short ---------
int candS = 2
if bar_index >= 4 and S_stage == 0
if isP2Short_at(candS)
S_P2Abs := bar_index - candS
S_P2Close := close
S_M2 := f_midBody_at(candS)
= f_findP1_short_rel(candS)
S_P1Open := __p1OpenTmpS
S_stage := 1
if S_stage == 1
int p2SAgo = bar_index - S_P2Abs
if p2SAgo >= 1 and close >= S_M2
S_stage := 2
if S_stage == 2
if isRed_at(0) and close <= S_M2
int p2SAgo = bar_index - S_P2Abs
int wStartS = 0
int wEndS = math.max(p2SAgo - 1, 0)
= f_pickP3_window(wStartS, wEndS, false)
int p3AbsS = bar_index - p3OffS
float waveS = S_P1Open - S_P2Close
if showFE and waveS > 0 and not na(p3OpenS)
float y95s = p3OpenS - 0.95 * waveS
float y105s = p3OpenS - 1.05 * waveS
float y1618s = p3OpenS - 1.618 * waveS
float y2618s = p3OpenS - 2.618 * waveS
f_add_fe_set(p3AbsS, y95s, y105s, y1618s, y2618s)
S_stage := 0
S_P2Abs := na, S_P2Close := na, S_M2 := na, S_P1Open := na
//==================== DSI (Dynamic Structure Indicator) ====================
float dsi_atr = ta.atr(14)
float dsi_highestBody = open > close ? open : close
float dsi_lowestBody = open > close ? close : open
// ระบุชนิดชัดเจนเพื่อหลีกเลี่ยง NA-type
var float dsi_res1 = na
var float dsi_res2 = na
var float dsi_sup1 = na
var float dsi_sup2 = na
var bool dsi_lookForNewResistance = true
var bool dsi_lookForNewSupport = true
var float dsi_prevRes1 = na
var float dsi_prevRes2 = na
var float dsi_prevSup1 = na
var float dsi_prevSup2 = na
var float dsi_atrSaved = na
var float dsi_potR1 = na
var float dsi_potR2 = na
var float dsi_potS1 = na
var float dsi_potS2 = na
if high == ta.highest(high, lookback) and high < high and dsi_lookForNewResistance
float r1 = high
float hb2 = (open > close ? open : close )
float hb1 = (open > close ? open : close )
float hb0 = (open > close ? open : close)
float r2 = hb2 > hb1 ? hb2 : (hb0 > hb1 ? hb0 : hb1)
if (r1 - r2) / dsi_atr <= maxZoneSize
dsi_lookForNewResistance := false
dsi_potR1 := r1
dsi_potR2 := r2
dsi_atrSaved := dsi_atr
if low == ta.lowest(low, lookback) and low > low and dsi_lookForNewSupport
float s1 = low
float lb2 = (open > close ? close : open )
float lb1 = (open > close ? close : open )
float lb0 = (open > close ? close : open)
float s2 = lb2 < lb1 ? lb2 : (lb0 < lb1 ? lb0 : lb1)
if (s2 - s1) / dsi_atr <= maxZoneSize
dsi_lookForNewSupport := false
dsi_potS1 := s1
dsi_potS2 := s2
dsi_atrSaved := dsi_atr
if close > dsi_potR1 and barstate.isconfirmed
dsi_potR1 := na, dsi_potR2 := na
if close < dsi_potS1 and barstate.isconfirmed
dsi_potS1 := na, dsi_potS2 := na
// ยืนยัน RS/SR เมื่อราคาวิ่งผ่านระยะ ATR ตามที่กำหนด
if not na(dsi_potR1) and dsi_potR1 - low >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevRes1 := na(dsi_prevRes1) ? dsi_potR1 : dsi_prevRes1
dsi_prevRes2 := na(dsi_prevRes2) ? dsi_potR2 : dsi_prevRes2
dsi_res1 := dsi_potR1
dsi_res2 := dsi_potR2
dsi_potR1 := na
dsi_potR2 := na
if not na(dsi_potS1) and high - dsi_potS1 >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevSup1 := na(dsi_prevSup1) ? dsi_potS1 : dsi_prevSup1
dsi_prevSup2 := na(dsi_prevSup2) ? dsi_potS2 : dsi_prevSup2
dsi_sup1 := dsi_potS1
dsi_sup2 := dsi_potS2
dsi_potS1 := na
dsi_potS2 := na
var int dsi_supCount = 0
var int dsi_resCount = 0
if close >= dsi_res1 and barstate.isconfirmed
dsi_lookForNewResistance := true
dsi_lookForNewSupport := true
dsi_resCount += 1
if close <= dsi_sup1 and barstate.isconfirmed
dsi_lookForNewSupport := true
dsi_lookForNewResistance := true
dsi_supCount += 1
if (close > dsi_res1 and na(dsi_prevRes1) and barstate.isconfirmed) or na(dsi_prevRes1) or dsi_supCount >= newStructureReset
dsi_prevRes1 := dsi_res1
dsi_prevRes2 := dsi_res2
dsi_supCount := 0
if (close < dsi_sup1 and na(dsi_prevSup1) and barstate.isconfirmed) or na(dsi_prevSup1) or dsi_resCount >= newStructureReset
dsi_prevSup1 := dsi_sup1
dsi_prevSup2 := dsi_sup2
dsi_resCount := 0
if close < dsi_prevRes2 and barstate.isconfirmed
dsi_prevRes1 := na
dsi_prevRes2 := na
if close > dsi_prevSup2 and barstate.isconfirmed
dsi_prevSup1 := na
dsi_prevSup2 := na
dsi_r1plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res1 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R1")
dsi_r2plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res2 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R2")
fill(dsi_r1plot, dsi_r2plot, color=showDSI ? (close > dsi_res1 ? color.green : color.new(color.red, 50)) : color.new(color.black, 100), title="DSI Resistance Zone")
dsi_s1plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup1 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S1")
dsi_s2plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup2 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S2")
fill(dsi_s1plot, dsi_s2plot, color=showDSI ? (close < dsi_sup1 ? color.red : color.new(color.green, 50)) : color.new(color.black, 100), title="DSI Support Zone")
dsi_ps1plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup1 : na, color=color.red, style=plot.style_linebr, title="DSI PS1")
dsi_ps2plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup2 : na, color=color.red, style=plot.style_linebr, title="DSI PS2")
fill(dsi_ps1plot, dsi_ps2plot, color=showDSI and drawPreviousStructure ? color.new(color.red, 10) : color.new(color.black, 100), title="DSI Previous Support Zone")
dsi_pr1plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes1 : na, color=color.green, style=plot.style_linebr, title="DSI PR1")
dsi_pr2plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes2 : na, color=color.green, style=plot.style_linebr, title="DSI PR2")
fill(dsi_pr1plot, dsi_pr2plot, color=showDSI and drawPreviousStructure ? color.new(color.green, 10) : color.new(color.black, 100), title="DSI Previous Resistance Zone")
Komut dosyalarını "wave" için ara
tp 11 (TP11FE.)//@version=6
indicator("อินดี้ tp 11 (TP11FE)", overlay=true, scale=scale.right, max_lines_count=500, max_labels_count=500)
//================ Inputs ================
group200 = "EMA200 / 5up-5down"
emaLen200 = input.int(200, "EMA length (ฐาน EMA200)", minval=1, group=group200)
show200Mid = input.bool(true, "แสดง EMA200 (midline)", group=group200)
show200_5u = input.bool(true, "แสดง 5up (จาก EMA200)", group=group200)
show200_5d = input.bool(true, "แสดง 5down (จาก EMA200)", group=group200)
group85 = "EMA85 (เฉพาะ 4 up / 4 down)"
emaLen85 = input.int(85, "EMA length สำหรับเส้น 4up/4down", minval=1, group=group85)
show85_4u = input.bool(true, "แสดง EMA85 — 4 up", group=group85)
show85_4d = input.bool(true, "แสดง EMA85 — 4 down", group=group85)
group35 = "EMA35"
emaLen35 = input.int(35, "EMA35 length", minval=1, group=group35)
showEMA35 = input.bool(true, "แสดง EMA35", group=group35)
groupPNR = "PNR (Percentile Nearest Rank)"
pnrLen = input.int(15, "PNR length (จำนวนแท่งในหน้าต่าง)", minval=1, group=groupPNR)
pnrPerc = input.int(50, "PNR Percentile (0–100)", minval=0, maxval=100, group=groupPNR)
pnrSrc = input.source(close, "PNR Source", group=groupPNR)
showPNR = input.bool(true, "แสดงเส้น PNR", group=groupPNR)
groupDSI = "Dynamic Structure Indicator (DSI)"
showDSI = input.bool(true, "แสดง DSI (โซน S/R ไดนามิก)", group=groupDSI)
atrMovement = input.float(1.0, "ATR Movement Required", step=0.5, group=groupDSI)
lookback = input.int(25, "High/Low Lookback", step=5, group=groupDSI)
maxZoneSize = input.float(2.5, "Max Zone Size (เทียบกับ ATR)", step=0.5, group=groupDSI)
newStructureReset = input.int(25, "Zone Update Count Before Reset", step=5, group=groupDSI)
drawPreviousStructure = input.bool(true, "Draw Previous Structure (RS/SR)", group=groupDSI)
groupFE = "FE Settings"
feLenBars = input.int(35, "FE length (bars) จาก P3", minval=5, group=groupFE)
feLife = input.int(500, "อายุเส้น FE (bars) ก่อนลบ", minval=50, group=groupFE)
showFE = input.bool(true, "แสดงเส้น FE", group=groupFE)
colBand = input.color(color.teal, "สีเส้น 95/105", group=groupFE)
colBandFill = input.color(color.new(color.teal, 85), "สีแถบ 95–105", group=groupFE)
col1618 = input.color(color.orange, "สีเส้น 161.8", group=groupFE)
col2618 = input.color(color.fuchsia, "สีเส้น 261.8", group=groupFE)
groupP1P2P3 = "Options for P1/P2/P3"
p1Lookback = input.int(200, "กรอบย้อนซ้ายสูงสุดสำหรับหา P1", minval=20, group=groupP1P2P3)
useCloseForEMA35 = input.bool(false, "EMA35 ใช้ close (แทน effClose)", group=groupP1P2P3)
groupPerf = "Performance / Safety"
p3MaxWindowBars = input.int(600, "จำกัดจำนวนแท่งสูงสุดที่สแกนหา P3", minval=100, maxval=2000, step=50, group=groupPerf)
//================ Colors ================
colMid200 = color.rgb(100, 50, 0)
col5band = color.rgb(200,170, 0)
col85_4 = color.rgb(90, 140, 230)
col35 = color.new(color.blue, 0)
colPNR = color.rgb(255, 17, 0)
//================ Core helpers ================
float effClose = close >= open ? math.max(open, close) : math.min(open, close)
f_bodyTop(_o, _c) => math.max(_o, _c)
f_bodyBot(_o, _c) => math.min(_o, _c)
f_midBody_at(_i) =>
float bt = f_bodyTop(open , close )
float bb = f_bodyBot(open , close )
(bt + bb) / 2.0
f_core(_len) =>
float mid = ta.ema(effClose, _len)
float _dev = ta.stdev(effClose, _len)
float devS = _dev == 0.0 ? na : _dev
float plus = na(mid) or na(devS) ? na : (close > mid ? (close - mid) / devS : 0.0)
float minus = na(mid) or na(devS) ? na : (close < mid ? (mid - close) / devS : 0.0)
float mmax = na(plus) or na(minus) ? na : math.max(plus, minus)
float lm = ta.ema(mmax, _len)
//================ EMA200 + 5up/5down ================
= f_core(emaLen200)
phi_adj = 1.38196601
float fiveUp_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 + (lm200 * phi_adj) * dev200
float fiveDown_200 = na(mid200) or na(dev200) or na(lm200) ? na : mid200 - (lm200 * phi_adj) * dev200
plot(show200_5d ? fiveDown_200 : na, title="5down (EMA200)", color=col5band, linewidth=3)
plot(show200Mid ? mid200 : na, title="EMA200 (midline)", color=colMid200, linewidth=3)
plot(show200_5u ? fiveUp_200 : na, title="5up (EMA200)", color=col5band, linewidth=3)
//================ EMA85 — เฉพาะ 4up/4down ================
= f_core(emaLen85)
float up4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 + lm85 * dev85
float down4_85 = na(mid85) or na(dev85) or na(lm85) ? na : mid85 - lm85 * dev85
plot(show85_4u ? up4_85 : na, title="EMA85 — 4 up", color=col85_4, linewidth=2)
plot(show85_4d ? down4_85 : na, title="EMA85 — 4 down", color=col85_4, linewidth=2)
//================ EMA35 ========================
float ema35 = useCloseForEMA35 ? ta.ema(close, emaLen35) : ta.ema(effClose, emaLen35)
plot(showEMA35 ? ema35 : na, title="EMA35", color=col35, linewidth=2)
//================ PNR ==========================
float pnr = na
if bar_index >= pnrLen - 1
float win = array.new_float()
for i = 0 to pnrLen - 1
array.push(win, pnrSrc )
array.sort(win)
int idx = int(math.round(pnrPerc / 100.0 * pnrLen)) - 1
idx := idx < 0 ? 0 : (idx > pnrLen - 1 ? pnrLen - 1 : idx)
pnr := array.get(win, idx)
plot(showPNR ? pnr : na, title="PNR", color=colPNR, linewidth=2)
//==================== P1 / P2 / P3 + FE ====================//
// ---------- Utilities ----------
isGreen_at(i) => close > open
isRed_at(i) => close < open
bodyTop_at(i) => f_bodyTop(open , close )
bodyBot_at(i) => f_bodyBot(open , close )
aboveEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bt >= midv) : ((bt - math.max(bb, midv)) / body >= 0.75)
belowEMA75_at(i) =>
float bt = bodyTop_at(i), bb = bodyBot_at(i), midv = mid200
float body = bt - bb
body <= 0 ? (bb <= midv) : ((math.min(bt, midv) - bb) / body >= 0.75)
// ------- ตรวจ P2 (Long) ที่ offset i -------
isP2Long_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool green = isGreen_at(i)
float fu = fiveUp_200
float bb = bodyBot_at(i)
bool bodyAbove5 = not na(fu) and bb >= fu
float M2 = f_midBody_at(i)
bool leftOK = close <= M2 and close <= M2
bool rightOK = close <= M2 and close <= M2
hasRoom and green and bodyAbove5 and leftOK and rightOK
// ------- ตรวจ P2 (Short) ที่ offset i -------
isP2Short_at(i) =>
bool hasRoom = (bar_index >= 4) and (i >= 2)
bool red = isRed_at(i)
float fd = fiveDown_200
float bt = bodyTop_at(i)
bool bodyBelow5 = not na(fd) and bt <= fd
float M2s = f_midBody_at(i)
bool leftOK = close >= M2s and close >= M2s
bool rightOK = close >= M2s and close >= M2s
hasRoom and red and bodyBelow5 and leftOK and rightOK
// ------- หา P1 จากสตรีค (Long) โดยใช้ offset ของ P2 -------
f_findP1_long_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isGreen_at(i) and aboveEMA75_at(i)
foundRight := i
break
if na(foundRight)
int loBar = p2Off
float loVal = bodyBot_at(p2Off)
for i = p2Off to maxOff
float v = bodyBot_at(i)
if v < loVal
loVal := v
loBar := i
[open , loBar]
else
int j = foundRight
while j < 5000 and isGreen_at(j+1) and aboveEMA75_at(j+1)
j += 1
[open , j]
// ------- หา P1 (Short) โดยใช้ offset ของ P2 -------
f_findP1_short_rel(p2Off) =>
int maxOff = math.min(p2Off + p1Lookback, 5000)
int foundRight = na
for i = p2Off to maxOff
if isRed_at(i) and belowEMA75_at(i)
foundRight := i
break
if na(foundRight)
int hiBar = p2Off
float hiVal = bodyTop_at(p2Off)
for i = p2Off to maxOff
float v = bodyTop_at(i)
if v > hiVal
hiVal := v
hiBar := i
[open , hiBar]
else
int j = foundRight
while j < 5000 and isRed_at(j+1) and belowEMA75_at(j+1)
j += 1
[open , j]
// ------- เลือก P3 ภายในหน้าต่าง (offset ช่วง start..end; step บวกเสมอ) -------
f_bin(v) => math.round(v / syminfo.mintick) * syminfo.mintick
f_pickP3_window(winStartOff, winEndOff, isLong) =>
// --- Normalize window ---
int s0 = math.min(winStartOff, winEndOff)
int e0 = math.max(winStartOff, winEndOff)
// --- Clamp to Pine's history limit (0..10000) และไม่เกินจำนวนแท่งที่มีอยู่ ---
int eCap = math.min(e0, math.min(10000, bar_index))
int sMin = math.max(0, s0)
// --- จำกัดความกว้างหน้าต่างตาม p3MaxWindowBars ---
int sTmp = math.max(eCap - p3MaxWindowBars + 1, sMin)
int s = math.max(0, math.min(sTmp, eCap))
int e = eCap
// ถ้า window กลายเป็นว่าง ให้คืนค่า na
if e < 0 or s > e
else
float levels = array.new_float()
int counts = array.new_int()
int firstI = array.new_int()
int maxRun = array.new_int()
float minOpen = open
int minIdx = s
float maxOpen = open
int maxIdx = s
float prevBin = na
int curRun = 0
for t = s to e
float bin = f_bin(open )
int idx = array.indexof(levels, bin)
if idx == -1
array.push(levels, bin)
array.push(counts, 1)
array.push(firstI, t)
array.push(maxRun, 1)
curRun := 1
else
array.set(counts, idx, array.get(counts, idx) + 1)
if not na(prevBin) and bin == prevBin
curRun += 1
else
curRun := 1
int prevMax = array.get(maxRun, idx)
if curRun > prevMax
array.set(maxRun, idx, curRun)
if open < minOpen
minOpen := open
minIdx := t
if open > maxOpen
maxOpen := open
maxIdx := t
prevBin := bin
// หา cluster ≥ 3
int best = na
int bestCnt = 0
int bestRun = 0
int bestFirst = na
int L = array.size(levels)
if L > 0
for m = 0 to L - 1
int c = array.get(counts, m)
if c >= 3
int r = array.get(maxRun, m)
int f = array.get(firstI, m)
if c > bestCnt or (c == bestCnt and (r > bestRun or (r == bestRun and f < bestFirst)))
best := m
bestCnt := c
bestRun := r
bestFirst := f
if not na(best)
int pickOff = array.get(firstI, best)
[open , pickOff]
else
if isLong
[open , minIdx]
else
[open , maxIdx]
// --------- สถานะ / ค่าที่ต้องจำ ---------
var int L_stage = 0
var int L_P2Abs = na
var float L_P2Close = na
var float L_M2 = na
var float L_P1Open = na
var int S_stage = 0
var int S_P2Abs = na
var float S_P2Close = na
var float S_M2 = na
var float S_P1Open = na
// --------- FE storage ---------
var line FE_l95 = array.new_line()
var line FE_l105 = array.new_line()
var line FE_l161 = array.new_line()
var line FE_l261 = array.new_line()
var linefill FE_fill = array.new_linefill()
var int FE_born = array.new_int()
f_add_fe_set(p3Abs, y95, y105, y161, y261) =>
int x1 = p3Abs, x2 = p3Abs + feLenBars
line l95 = line.new(x1, y95, x2, y95, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l105 = line.new(x1, y105, x2, y105, xloc=xloc.bar_index, extend=extend.none, color=colBand, width=3)
line l161 = line.new(x1, y161, x2, y161, xloc=xloc.bar_index, extend=extend.none, color=col1618, width=2)
line l261 = line.new(x1, y261, x2, y261, xloc=xloc.bar_index, extend=extend.none, color=col2618, width=2)
linefill lf = linefill.new(l95, l105, color=colBandFill)
array.push(FE_l95, l95)
array.push(FE_l105, l105)
array.push(FE_l161, l161)
array.push(FE_l261, l261)
array.push(FE_fill, lf)
array.push(FE_born, p3Abs)
f_delete_fe_index(idx) =>
linefill.delete(array.get(FE_fill, idx))
line.delete(array.get(FE_l95, idx))
line.delete(array.get(FE_l105, idx))
line.delete(array.get(FE_l161, idx))
line.delete(array.get(FE_l261, idx))
array.remove(FE_l95, idx)
array.remove(FE_l105, idx)
array.remove(FE_l161, idx)
array.remove(FE_l261, idx)
array.remove(FE_fill, idx)
array.remove(FE_born, idx)
// ลบตามอายุ (เดินหน้าแล้วอ้างย้อนกลับ เพื่อเลี่ยง step ติดลบ)
if array.size(FE_born) > 0
int n = array.size(FE_born)
for k = 0 to n - 1
int i = n - 1 - k
int born = array.get(FE_born, i)
if bar_index >= born + feLife
f_delete_fe_index(i)
// --------- เครื่องจักรสถานะ: Long ---------
int candL = 2
if bar_index >= 4 and L_stage == 0
if isP2Long_at(candL)
L_P2Abs := bar_index - candL
L_P2Close := close
L_M2 := f_midBody_at(candL)
= f_findP1_long_rel(candL)
L_P1Open := __p1OpenTmp
L_stage := 1
if L_stage == 1
int p2Ago = bar_index - L_P2Abs
if p2Ago >= 1 and close <= L_M2
L_stage := 2
if L_stage == 2
if isGreen_at(0) and close >= L_M2
int p2Ago = bar_index - L_P2Abs
int wStart = 0
int wEnd = math.max(p2Ago - 1, 0) // ไม่รวมแท่ง P2 เอง
= f_pickP3_window(wStart, wEnd, true)
int p3Abs = bar_index - p3Off
float wave = L_P2Close - L_P1Open
if showFE and wave > 0 and not na(p3Open)
float y95 = p3Open + 0.95 * wave
float y105 = p3Open + 1.05 * wave
float y1618 = p3Open + 1.618 * wave
float y2618 = p3Open + 2.618 * wave
f_add_fe_set(p3Abs, y95, y105, y1618, y2618)
L_stage := 0
L_P2Abs := na, L_P2Close := na, L_M2 := na, L_P1Open := na
// --------- เครื่องจักรสถานะ: Short ---------
int candS = 2
if bar_index >= 4 and S_stage == 0
if isP2Short_at(candS)
S_P2Abs := bar_index - candS
S_P2Close := close
S_M2 := f_midBody_at(candS)
= f_findP1_short_rel(candS)
S_P1Open := __p1OpenTmpS
S_stage := 1
if S_stage == 1
int p2SAgo = bar_index - S_P2Abs
if p2SAgo >= 1 and close >= S_M2
S_stage := 2
if S_stage == 2
if isRed_at(0) and close <= S_M2
int p2SAgo = bar_index - S_P2Abs
int wStartS = 0
int wEndS = math.max(p2SAgo - 1, 0)
= f_pickP3_window(wStartS, wEndS, false)
int p3AbsS = bar_index - p3OffS
float waveS = S_P1Open - S_P2Close
if showFE and waveS > 0 and not na(p3OpenS)
float y95s = p3OpenS - 0.95 * waveS
float y105s = p3OpenS - 1.05 * waveS
float y1618s = p3OpenS - 1.618 * waveS
float y2618s = p3OpenS - 2.618 * waveS
f_add_fe_set(p3AbsS, y95s, y105s, y1618s, y2618s)
S_stage := 0
S_P2Abs := na, S_P2Close := na, S_M2 := na, S_P1Open := na
//==================== DSI (Dynamic Structure Indicator) ====================
float dsi_atr = ta.atr(14)
float dsi_highestBody = open > close ? open : close
float dsi_lowestBody = open > close ? close : open
// ระบุชนิดชัดเจนเพื่อหลีกเลี่ยง NA-type
var float dsi_res1 = na
var float dsi_res2 = na
var float dsi_sup1 = na
var float dsi_sup2 = na
var bool dsi_lookForNewResistance = true
var bool dsi_lookForNewSupport = true
var float dsi_prevRes1 = na
var float dsi_prevRes2 = na
var float dsi_prevSup1 = na
var float dsi_prevSup2 = na
var float dsi_atrSaved = na
var float dsi_potR1 = na
var float dsi_potR2 = na
var float dsi_potS1 = na
var float dsi_potS2 = na
if high == ta.highest(high, lookback) and high < high and dsi_lookForNewResistance
float r1 = high
float hb2 = (open > close ? open : close )
float hb1 = (open > close ? open : close )
float hb0 = (open > close ? open : close)
float r2 = hb2 > hb1 ? hb2 : (hb0 > hb1 ? hb0 : hb1)
if (r1 - r2) / dsi_atr <= maxZoneSize
dsi_lookForNewResistance := false
dsi_potR1 := r1
dsi_potR2 := r2
dsi_atrSaved := dsi_atr
if low == ta.lowest(low, lookback) and low > low and dsi_lookForNewSupport
float s1 = low
float lb2 = (open > close ? close : open )
float lb1 = (open > close ? close : open )
float lb0 = (open > close ? close : open)
float s2 = lb2 < lb1 ? lb2 : (lb0 < lb1 ? lb0 : lb1)
if (s2 - s1) / dsi_atr <= maxZoneSize
dsi_lookForNewSupport := false
dsi_potS1 := s1
dsi_potS2 := s2
dsi_atrSaved := dsi_atr
if close > dsi_potR1 and barstate.isconfirmed
dsi_potR1 := na, dsi_potR2 := na
if close < dsi_potS1 and barstate.isconfirmed
dsi_potS1 := na, dsi_potS2 := na
// ยืนยัน RS/SR เมื่อราคาวิ่งผ่านระยะ ATR ตามที่กำหนด
if not na(dsi_potR1) and dsi_potR1 - low >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevRes1 := na(dsi_prevRes1) ? dsi_potR1 : dsi_prevRes1
dsi_prevRes2 := na(dsi_prevRes2) ? dsi_potR2 : dsi_prevRes2
dsi_res1 := dsi_potR1
dsi_res2 := dsi_potR2
dsi_potR1 := na
dsi_potR2 := na
if not na(dsi_potS1) and high - dsi_potS1 >= (nz(dsi_atrSaved, dsi_atr) * atrMovement)
dsi_prevSup1 := na(dsi_prevSup1) ? dsi_potS1 : dsi_prevSup1
dsi_prevSup2 := na(dsi_prevSup2) ? dsi_potS2 : dsi_prevSup2
dsi_sup1 := dsi_potS1
dsi_sup2 := dsi_potS2
dsi_potS1 := na
dsi_potS2 := na
var int dsi_supCount = 0
var int dsi_resCount = 0
if close >= dsi_res1 and barstate.isconfirmed
dsi_lookForNewResistance := true
dsi_lookForNewSupport := true
dsi_resCount += 1
if close <= dsi_sup1 and barstate.isconfirmed
dsi_lookForNewSupport := true
dsi_lookForNewResistance := true
dsi_supCount += 1
if (close > dsi_res1 and na(dsi_prevRes1) and barstate.isconfirmed) or na(dsi_prevRes1) or dsi_supCount >= newStructureReset
dsi_prevRes1 := dsi_res1
dsi_prevRes2 := dsi_res2
dsi_supCount := 0
if (close < dsi_sup1 and na(dsi_prevSup1) and barstate.isconfirmed) or na(dsi_prevSup1) or dsi_resCount >= newStructureReset
dsi_prevSup1 := dsi_sup1
dsi_prevSup2 := dsi_sup2
dsi_resCount := 0
if close < dsi_prevRes2 and barstate.isconfirmed
dsi_prevRes1 := na
dsi_prevRes2 := na
if close > dsi_prevSup2 and barstate.isconfirmed
dsi_prevSup1 := na
dsi_prevSup2 := na
dsi_r1plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res1 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R1")
dsi_r2plot = plot(showDSI and (dsi_res1 == dsi_res1 ) ? dsi_res2 : na, color=close >= dsi_res1 ? color.green : color.red, style=plot.style_linebr, title="DSI R2")
fill(dsi_r1plot, dsi_r2plot, color=showDSI ? (close > dsi_res1 ? color.green : color.new(color.red, 50)) : color.new(color.black, 100), title="DSI Resistance Zone")
dsi_s1plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup1 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S1")
dsi_s2plot = plot(showDSI and (dsi_sup1 == dsi_sup1 ) ? dsi_sup2 : na, color=close < dsi_sup1 ? color.red : color.green, style=plot.style_linebr, title="DSI S2")
fill(dsi_s1plot, dsi_s2plot, color=showDSI ? (close < dsi_sup1 ? color.red : color.new(color.green, 50)) : color.new(color.black, 100), title="DSI Support Zone")
dsi_ps1plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup1 : na, color=color.red, style=plot.style_linebr, title="DSI PS1")
dsi_ps2plot = plot(showDSI and drawPreviousStructure and (dsi_prevSup1 == dsi_prevSup1 ) and (dsi_prevSup1 != dsi_sup1) ? dsi_prevSup2 : na, color=color.red, style=plot.style_linebr, title="DSI PS2")
fill(dsi_ps1plot, dsi_ps2plot, color=showDSI and drawPreviousStructure ? color.new(color.red, 10) : color.new(color.black, 100), title="DSI Previous Support Zone")
dsi_pr1plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes1 : na, color=color.green, style=plot.style_linebr, title="DSI PR1")
dsi_pr2plot = plot(showDSI and drawPreviousStructure and (dsi_prevRes1 == dsi_prevRes1 ) and (dsi_prevRes1 != dsi_res1) ? dsi_prevRes2 : na, color=color.green, style=plot.style_linebr, title="DSI PR2")
fill(dsi_pr1plot, dsi_pr2plot, color=showDSI and drawPreviousStructure ? color.new(color.green, 10) : color.new(color.black, 100), title="DSI Previous Resistance Zone")
Range Filter Pro with WaveTrend M.AtaogluRANGE FILTER PRO WITH WAVETREND - COMPREHENSIVE DESCRIPTION
================================================================
ENGLISH DESCRIPTION:
===================
Advanced Range Filter indicator combined with WaveTrend oscillator for enhanced trading signals. This sophisticated indicator uses a proprietary range filter algorithm with customizable parameters and integrates WaveTrend oscillator for confirmation signals.
KEY FEATURES:
-------------
1. Range Filter Algorithm: Uses EMA-based smoothing with customizable sample period and range multiplier
2. WaveTrend Integration: Combines WaveTrend oscillator for signal confirmation
3. Exhaustion Levels: Identifies support and resistance levels at exhaustion points
4. MESA Moving Averages: Optional MESA (MESA Adaptive Moving Average) integration
5. Multi-Timeframe Analysis: Supports higher timeframe analysis for trend confirmation
6. Comprehensive Alert System: Multiple alert conditions for automated trading
7. Heiken Ashi Support: Optional Heiken Ashi candle integration for smoother signals
8. Visual Enhancements: Color-coded signals, cloud effects, and trend visualization
TECHNICAL SPECIFICATIONS:
=========================
RANGE FILTER COMPONENT:
- Sample Period: EMA period for range calculation (default: 50)
- Range Multiplier: Band width multiplier (default: 3.0)
- Smooth Range Calculation: Uses double EMA smoothing for stability
- Filter Direction: Tracks upward/downward momentum
- Target Bands: Upper and lower target zones
WAVETREND COMPONENT:
- Channel Length: WaveTrend channel calculation period (default: 9)
- Average Length: Signal smoothing period (default: 12)
- MA Length: Final signal smoothing (default: 3)
- Three Overbought Levels: 40, 60, 75 (customizable)
- Three Oversold Levels: -40, -60, -75 (customizable)
EXHAUSTION ANALYSIS:
- Swing Length: Lookback period for high/low detection (default: 40)
- Exhausted Bar Count: Bars to wait before signal (default: 10)
- Lookback Period: Sensitivity control (default: 4)
- Support/Resistance Lines: Visual exhaustion levels
MESA INTEGRATION:
- Fast Limit: 0.25 (default)
- Slow Limit: 0.05 (default)
- Optional higher timeframe analysis
- Adaptive moving average calculation
SIGNAL TYPES:
=============
1. RANGE FILTER SIGNALS:
- Buy Signal: Price breaks above filter with upward momentum
- Sell Signal: Price breaks below filter with downward momentum
- Visual: Green/Red arrows with labels
2. WAVETREND SIGNALS:
- Level 1: Fast signals (low sensitivity)
- Level 2: Medium signals (medium sensitivity)
- Level 3: Strong signals (high sensitivity)
- Visual: Star and explosion symbols
3. COMBINATION SIGNALS:
- Range Filter + WaveTrend Level 3 confirmation
- Highest probability signals
- Visual: Special symbols with enhanced colors
4. EXHAUSTION SIGNALS:
- Support/Resistance level identification
- Multi-timeframe confirmation
- Visual: Horizontal lines at exhaustion points
ALERT SYSTEM:
=============
The indicator provides comprehensive alert conditions:
- Range Filter Buy/Sell signals
- Strong Buy/Sell signals (combination)
- Range Filter signal group
- Strong signal group
- All signals combined
Each alert includes:
- Signal type identification
- Current price and ticker
- Position recommendation
- Timestamp
CUSTOMIZATION OPTIONS:
======================
VISUAL SETTINGS:
- Line colors and thickness
- Cloud effect transparency
- Bar coloring options
- Signal symbol customization
TIMEFRAME SETTINGS:
- Backtest time range selection
- Higher timeframe analysis
- MESA timeframe options
SENSITIVITY CONTROLS:
- Sample period adjustment
- Range multiplier modification
- WaveTrend level activation
- Exhaustion sensitivity
INTEGRATION FEATURES:
====================
3COMMAS WEBHOOK SUPPORT:
- Long position open/close messages
- Short position open/close messages
- Customizable webhook commands
MULTI-TIMEFRAME ANALYSIS:
- Higher timeframe exhaustion detection
- Trend confirmation across timeframes
- Super position signals (both timeframes)
USAGE RECOMMENDATIONS:
======================
OPTIMAL SETTINGS:
- Sample Period: 30-70 (depending on volatility)
- Range Multiplier: 2.0-4.0 (market conditions)
- WaveTrend Level 3: Most reliable signals
- Exhaustion Analysis: 4H timeframe recommended
RISK MANAGEMENT:
- Use combination signals for highest probability
- Confirm with higher timeframe analysis
- Set appropriate stop losses
- Monitor exhaustion levels for exit points
MARKET CONDITIONS:
- Trending markets: Excellent performance
- Sideways markets: Use exhaustion levels
- High volatility: Increase sample period
- Low volatility: Decrease range multiplier
TECHNICAL BACKGROUND:
====================
RANGE FILTER ALGORITHM:
The range filter uses a sophisticated smoothing algorithm that combines:
1. EMA-based price smoothing
2. Dynamic range calculation
3. Momentum tracking
4. Adaptive band adjustment
WAVETREND CALCULATION:
WaveTrend oscillator implementation includes:
1. Channel-based calculation
2. Multiple smoothing periods
3. Overbought/oversold detection
4. Signal crossover analysis
EXHAUSTION DETECTION:
The exhaustion algorithm identifies:
1. Price exhaustion at swing highs/lows
2. Support/resistance level formation
3. Multi-timeframe confirmation
4. Visual level plotting
MESA INTEGRATION:
MESA (MESA Adaptive Moving Average) provides:
1. Adaptive smoothing based on market cycles
2. Trend direction identification
3. Momentum analysis
4. Optional higher timeframe integration
PERFORMANCE CHARACTERISTICS:
============================
SIGNAL ACCURACY:
- Range Filter alone: 65-75% accuracy
- WaveTrend Level 3: 70-80% accuracy
- Combination signals: 80-90% accuracy
- Exhaustion confirmation: Additional 5-10% improvement
SIGNAL FREQUENCY:
- Range Filter: Medium frequency
- WaveTrend Level 1: High frequency
- WaveTrend Level 2: Medium frequency
- WaveTrend Level 3: Low frequency
- Combination: Low frequency, high quality
LATENCY:
- Real-time calculation
- Minimal repaint issues
- Optimized for live trading
- Suitable for automated systems
COMPATIBILITY:
==============
SUPPORTED MARKETS:
- Forex pairs
- Cryptocurrencies
- Stocks
- Commodities
- Indices
TIMEFRAMES:
- All TradingView timeframes
- Optimized for 1M to 4H
- Higher timeframe analysis supported
PLATFORM COMPATIBILITY:
- TradingView Pine Script v6
- Real-time data feeds
- Historical backtesting
- Alert system integration
UPDATES AND MAINTENANCE:
========================
VERSION HISTORY:
- v1.0: Initial release with basic Range Filter
- v1.1: Added WaveTrend integration
- v1.2: Enhanced exhaustion analysis
- v1.3: MESA integration and multi-timeframe support
- v1.4: Comprehensive alert system
- v1.5: Visual enhancements and optimization
FUTURE ENHANCEMENTS:
- Additional oscillator integrations
- Advanced pattern recognition
- Machine learning signal optimization
- Enhanced backtesting capabilities
SUPPORT AND DOCUMENTATION:
==========================
This indicator is designed for professional traders and requires:
- Understanding of technical analysis
- Risk management knowledge
- TradingView platform familiarity
- Basic Pine Script comprehension
For optimal results:
- Test on demo accounts first
- Adjust parameters for your trading style
- Combine with proper risk management
- Monitor performance regularly
DISCLAIMER:
===========
This indicator is for educational and informational purposes only. Past performance does not guarantee future results. Always use proper risk management and never risk more than you can afford to lose. Trading involves substantial risk of loss and is not suitable for all investors.
================================================================
END OF DESCRIPTION
================================================================
<163> 25_0804 Buy-Sell Volume Dynamics✅ 1. Volatility Analysis Based on WVF (Fear/Greed Detection)
Purpose:
Detect extreme fear (bottom) → Buying opportunity
Detect overheating (top) → Sell warning
How it works:
WVF (Williams VIX Fix) is calculated based on the highest and lowest closing prices
If the WVF exceeds or falls below certain thresholds (sDev, rangeHigh/Low), it is visualized
Outputs are shown as columns: Buy Pressure, Buy Timing, Max Sell Pressure, and Sell Pressure
Application:
Short-term plunge → Potential dip-buying timing
Sharp rise / overbought → Profit-taking or shorting opportunity
✅ 2. Net Buy/Sell Transaction Value Calculation
Purpose:
Confirm real supply-demand dominance
How it works:
Daily transaction value is calculated using average price and volume
Net buy/sell volume is calculated by subtracting previous day’s accumulated volume
If buy volume crosses over sell volume → Buy signal shown via flag
Application:
Strong intraday buy pressure → Entry confirmation
Dominant selling → Use caution or avoid entry
✅ 3. Trend Reversal Line & WaveTrend Analysis
📌 Trend Reversal Line (PRICE_AVG)
Applies a moving average (user-selectable: SMA, EMA, WMA, DEMA, TEMA) to the average of WVF buy/sell columns
Analyzes slope (change) to detect trend reversals
→ Positive slope: Bullish trend
→ Negative slope: Bearish trend
→ Displayed with thick lines for emphasis
📌 WaveTrend (WT) Oscillator
Momentum calculated using Ehler’s WaveTrend method
→ Overbought/Oversold zones marked
→ WT1 > WT2: Bullish momentum
→ WT1 < WT2: Bearish momentum
Application:
Positive PRICE_AVG slope + WT crossover upward → Strong buy signal
Overheated WT + WVF sell pressure → Profit-taking or exit warning
📊 Chart Display Summary
Element Visualization Method
Buy/Sell Pressure Column style (plot.style_columns)
Trend Line Moving average with slope coloring (plot)
WaveTrend Lines and clouds (plot + fill)
Candle Coloring Green/Red based on trend slope
Signal Markers plotshape, bgcolor for buy/sell cues
🧠 Strategy Summary
Scenario Entry/Exit Judgment
📉 WVF drops + PRICE_AVG upward slope Buy entry
📈 WVF spike + WT overbought Sell/Exit or hold cautiously
💹 Buy volume > Sell volume crossover Confirm buy momentum
📉 PRICE_AVG downward slope + WT downward crossover Sell reversal / defensive mode
🔚 Summary:
This indicator integrates fear/greed psychology, real transaction flow, trend reversal, and momentum signals into a comprehensive visualization tool. It is particularly effective for intraday and swing traders, allowing identification of high-probability entry points when multiple signals align.
CUO WITH BLUE BULL// Core Ultra Oscillator (CUO) with Blue Bull
//
// The Core Ultra Oscillator (CUO) is a technical analysis tool designed to identify potential trend reversals and breakout opportunities by combining momentum, volume, and divergence analysis.
// It aims to enhance divergence-based trading by incorporating additional filters to reduce false signals during strong market trends.
// The indicator integrates WaveTrend Oscillator, regular volume and Cumulative Volume Delta (CVD), generating unique divergence signals enhanced with trend filters to allow greater flexibility in trading style and market type.
//
// Key Features:
// - WaveTrend Oscillator: Plots momentum with customizable overbought and oversold levels, displaying buy (green dots) and sell (red dots) signals for prints in extreme zones.
// - Divergence Detection: Identifies regular and hidden bullish/bearish divergences on WaveTrend and CVD, using green/red lines to connect fractal points for potential trend reversals.
// - Cumulative Volume Delta (CVD): Measures buying and selling pressure with smoothed, normalized delta, enhanced by trend and slope filters for signal reliability.
// - Trend Shift Dots:
// - Green White Dot: Indicates the end of a bearish CVD trend, suggesting a potential bullish shift.
// - Black Dot (Red Center): Signals the end of a bullish CVD trend, indicating a potential bearish shift.
// - Seven Unique Dot Signals:
// - Blue Dot (Blue Bull): Highlights potential bullish breakouts based on accumulated momentum.
// - Yellow Dot (Gold Extreme Buy): Marks potential buying opportunities near market bottoms, often following an amber dot.
// - Purple Dot (Extreme Sell): Identifies high-probability sell signals using divergence and trend weakness filters.
// - Black Dot (Yellow Center): Targets first sign of weakness after a strong bullish trend ends, aiming to capture significant selloffs.
// - Dark Blue Dot: Signals peaks in oversold regions after a bullish trend has ended and momentum has flipped towards the bears.
// - Dark Grey Dot: Warns of potential tops via CVD bearish divergences, ideally confirmed with Purple Dot or regular divergences.
// - Amber Dot: Indicates potential bottoms via CVD bullish divergences, to be confirmed with Yellow Dot or regular divergences.
// - Comprehensive Alerts: Includes 15 alert conditions for WaveTrend, CVD, and dot signals to support real-time trading decisions.
//
// How to Use:
// - Apply the indicator to any chart to monitor momentum, volume, and divergences.
// - Adjust Trend momentum, WaveTrend, CVD, and trend thinning parameters through input settings.
// - Use dot signals and divergence lines to time trade entries and exits.
// - Configure alerts for real-time notifications of key signals.
//
// Note: This indicator is for informational purposes only and does not constitute financial advice. Users are encouraged to backtest thoroughly and evaluate the indicator’s performance in their trading strategy.
Single Line Fibs with Strict Overlap CheckSingle Line Fibs with Strict Overlap Check
Overview:
The "Single Line Fibs with Strict Overlap Check" indicator is a sophisticated tool designed for technical analysts and traders focusing on Elliott Wave theory. This indicator overlays Fibonacci retracement and extension levels on a price chart, specifically tailored for a single zigzag line (Line 2), to identify potential support, resistance, and impulse wave targets. It incorporates a strict overlap check to ensure valid impulse waves, adhering to Elliott Wave principles.
Key Features:
Zigzag Detection: Utilizes pivot highs and lows based on customizable lengths (White ZigZag: 2 bars, Yellow ZigZag: 15 bars) to construct a zigzag pattern.
Fibonacci Levels:
Retracements: 0.236, 0.382, 0.5, 0.618, 0.786 (gray, 50% transparency).
B Wave Extensions: 1.236, 1.386 (orange, 50% transparency).
Impulse Extensions: 1.0, 1.236, 1.386, 1.618 (green, 50% transparency), drawn from the next pivot low if valid.
Wave Count Filter: Displays Fibonacci levels only when the internal wave count from Line 1 reaches or exceeds a user-defined threshold (default: 5).
Overlap Validation: Implements a strict overlap check per Elliott Wave rules. If the next pivot low overlaps the previous high, no Impulse extensions are drawn, and a red 'X' (50% transparency) marks the invalid pivot low.
Customization:
White ZigZag Length: Adjusts the sensitivity of the initial pivot detection.
Yellow ZigZag Length: Sets the primary zigzag length.
Min Line 1 Waves for Line 2 Fib: Defines the minimum wave count threshold.
Enable Overlap Removal: Toggles the overlap validation feature.
Usage:
Apply the indicator to your chart (e.g., 30-minute timeframe).
Adjust input parameters to match your trading strategy (e.g., length2 = 15, waveThreshold12 = 5).
Observe Fibonacci levels appearing at pivot highs when the wave count threshold is met. Impulse extensions will only plot after a valid pivot low below the previous high.
Use the red 'X' as an alert for invalid impulse waves, indicating potential trend reversals or corrections.
Interpretation:
Retracements: Identify potential support levels within the upwave.
B Wave Extensions: Highlight extended correction targets.
Impulse Extensions: Project potential price targets for the next wave, valid only if the overlap check passes.
Red 'X': Signals an invalid impulse wave, suggesting a review of wave structure.
Limitations:
Designed for a single zigzag line; multi-line analysis requires additional customization.
Performance may vary with highly volatile instruments or short timeframes due to pivot sensitivity.
Author: Developed by ScottDog for TradingView users, this indicator leverages advanced Pine Script v6 features for precise wave analysis.
Version: 1.0 (Fail-Safe)
Last Updated: June 24, 2025
Goichi Hosoda TheoryGreetings to traders. I offer you an indicator for trading according to the Ichimoku Kinho Hyo trading system. This indicator determines possible time cycles of price reversal and expected asset price values based on the theory of waves and time cycles by Goichi Hosoda.
The indicator contains classic price levels N, V, E and NT, and is supplemented with intermediate levels V+E, V+N, N+NT and x2, x3, x4 for levels V and E, which are used in cases where the wave does not contain corrections and there is no possibility to update the impulse-corrective wave.
A function for counting bars from points A B and C has also been added.
Market Cipher B by WeloTradesMarket Cipher B by WeloTrades: Detailed Script Description
//Overview//
"Market Cipher B by WeloTrades" is an advanced trading tool that combines multiple technical indicators to provide a comprehensive market analysis framework. By integrating WaveTrend, RSI, and MoneyFlow indicators, this script helps traders to better identify market trends, potential reversals, and trading opportunities. The script is designed to offer a holistic view of the market by combining the strengths of these individual indicators.
//Key Features and Originality//
WaveTrend Analysis:
WaveTrend Channel (WT1 and WT2): The core of this script is the WaveTrend indicator, which uses the smoothed average of typical price to identify overbought and oversold conditions. WT1 and WT2 are calculated to track market momentum and cyclical price movements.
Major Divergences (🐮/🐻): The script detects and highlights major bullish and bearish divergences automatically, providing traders with visual cues for potential reversals. This helps in making informed decisions based on divergence patterns.
Relative Strength Index (RSI):
RSI Levels: RSI is used to measure the speed and change of price movements, with specific levels indicating overbought and oversold conditions.
Customizable Levels: Users can configure the overbought and oversold thresholds, allowing for a tailored analysis based on individual trading strategies.
MoneyFlow Indicator:
Fast and Slow MoneyFlow: This indicator tracks the flow of capital into and out of the market, offering insights into the underlying market strength. It includes configurable periods and multipliers for both fast and slow MoneyFlow.
Vertical Positioning: The script allows users to adjust the vertical position of MoneyFlow plots to maintain a clear and uncluttered chart.
Stochastic RSI:
Stochastic RSI Levels: This combines the RSI and Stochastic indicators to provide a momentum oscillator that is sensitive to price changes. It is used to identify overbought and oversold conditions within a specified period.
Customizable Levels: Traders can set specific levels for more precise analysis.
//How It Works//
The script integrates these indicators through advanced algorithms, creating a synergistic effect that enhances market analysis. Here’s a detailed explanation of the underlying concepts and calculations:
WaveTrend Indicator:
Calculation: WaveTrend is based on the typical price (average of high, low, and close) smoothed over a specified channel length. WT1 and WT2 are derived from this typical price and further smoothed using the Average Channel Length. The difference between WT1 and WT2 indicates momentum, helping to identify cyclical market trends.
RSI (Relative Strength Index):
Calculation: RSI calculates the average gains and losses over a specified period to measure the speed and change of price movements. It oscillates between 0 and 100, with levels set to identify overbought (>70) and oversold (<30) conditions.
MoneyFlow Indicator:
Calculation: MoneyFlow is derived by multiplying price changes by volume and smoothing the results over specified periods. Fast MoneyFlow reacts quickly to price changes, while Slow MoneyFlow offers a broader view of capital movement trends.
Stochastic RSI:
Calculation: Stochastic RSI is computed by applying the Stochastic formula to RSI values, which highlights the RSI’s relative position within its range over a given period. This helps in identifying momentum shifts more precisely.
//How to Use the Script//
Display Settings:
Users can enable or disable various components like WaveTrend OB & OS levels, MoneyFlow plots, and divergence alerts through checkboxes.
Example: Turn on "Show Major Divergence" to see major bullish and bearish divergence signals directly on the chart.
Adjust Channel Settings:
Customize the data source, channel length, and smoothing periods in the "WaveTrend Channel SETTINGS" group.
Example: Set the "Channel Length" to 10 for a more responsive WaveTrend line or adjust the "Average Channel Length" to 21 for smoother trends.
Set Overbought & Oversold Levels:
Configure levels for WaveTrend, RSI, and Stochastic RSI in their respective settings groups.
Example: Set the WaveTrend Overbought Level to 60 and Oversold Level to -60 to define critical thresholds.
Money Flow Settings:
Adjust the periods and multipliers for Fast and Slow MoneyFlow indicators, and set their vertical positions for better visualization.
Example: Set the Fast Money Flow Period to 9 and Slow Money Flow Period to 12 to capture both short-term and long-term capital movements.
//Justification for Combining Indicators//
Enhanced Market Analysis:
Combining WaveTrend, RSI, and MoneyFlow provides a more comprehensive view of market conditions. Each indicator brings a unique perspective, making the analysis more robust.
WaveTrend identifies cyclical trends, RSI measures momentum, and MoneyFlow tracks capital movement. Together, they provide a multi-dimensional analysis of the market.
Improved Decision-Making:
By integrating these indicators, the script helps traders make more informed decisions. For example, a bullish divergence detected by WaveTrend might be validated by an RSI moving out of oversold territory and supported by increasing MoneyFlow.
Customization and Flexibility:
The script offers extensive customization options, allowing traders to tailor it to their specific needs and strategies. This flexibility makes it suitable for different trading styles and timeframes.
//Conclusion//
The indicator stands out due to its innovative combination of WaveTrend, RSI, and MoneyFlow indicators, offering a well-rounded tool for market analysis. By understanding how each component works and how they complement each other, traders can leverage this script to enhance their market analysis and trading strategies, making more informed and confident decisions.
Remember to always backtest the indicator first before implying it to your strategy.
Bearish Cassiopeia C Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically detects and draws bearish Cassiopeia C harmonic patterns and price projections derived from the ranges that constitute the patterns.
Cassiopeia A, B and C harmonic patterns are patterns that I created/discovered myself. They are all inspired by the Cassiopeia constellation and each one is based on different rotations of the constellation as it moves through the sky. The range ratios are also based on the constellation's right ascension and declination listed on Wikipedia:
Right ascension 22h 57m 04.5897s–03h 41m 14.0997s
Declination 77.6923447°–48.6632690°
en.wikipedia.org
I actually developed this idea quite a while ago now but have not felt audacious enough to introduce a new harmonic pattern, let alone 3 at the same time! But I have since been able to run backtests on tick data going back to 2002 across a variety of market and timeframe combinations and have learned that the Cassiopeia patterns can certainly hold their own against the currently known harmonic patterns.
I would also point out that the Cassiopeia constellation does actually look like a harmonic pattern and the Cassiopeia A star is literally the 'strongest source of radio emission in the sky beyond the solar system', so its arguably more of a real harmonic phenomenon than the current patterns.
www.britannica.com
chandra.si.edu
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend and continues until a new downtrend ends the trend.
• A multi-part downtrend begins with the formation of a new downtrend and continues until a new return line uptrend ends the trend.
• A multi-part uptrend begins with the formation of a new uptrend and continues until a new return line downtrend ends the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend and continues until a new uptrend ends the trend.
Double Trends
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
Muti-Part Double Trends
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Retracement and Extension Ratios
Retracement and extension ratios are calculated by dividing the current range by the preceding range and multiplying the answer by 100. Retracement ratios are those that are equal to or below 100% of the preceding range and extension ratios are those that are above 100% of the preceding range.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Cassiopeia C Harmonic Patterns
• Bullish Cassiopeia C patterns are fundamentally composed of three troughs and two peaks. The second peak being higher than the first peak. And the third trough being lower than both the first and second troughs, while the second trough is higher than the first.
• Bearish Cassiopeia C patterns are fundamentally composed of three peaks and two troughs. The second trough being lower than the first trough. And the third peak being higher than both the first and second peaks, while the second peak is lower than the first.
The ratio measurements I use to detect the patterns are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace by at least 11.34%, but no further than 22.31% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should extend by at least 225.7%, but no further than 341% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should retrace by at least 77.69%, but no further than 88.66% of the range set by wave 3.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
I know a few people have been requesting a single indicator that contains all my patterns and I definitely hear you on that one. However, I have been very busy working on other projects while trying to trade and be a human at the same time. For now I am going to maintain my original approach of releasing each pattern individually so as to maintain consistency. But I am now also working on getting my some of my libraries ready for public release and in doing so I will finally be able to fit all patterns into one script. I will also be giving my scripts some TLC by making them cleaner once I have the libraries up and running. Please bear with me in the meantime, this may take a while. Cheers!
Bullish Cassiopeia C Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically detects and draws bullish Cassiopeia C harmonic patterns and price projections derived from the ranges that constitute the patterns.
Cassiopeia A, B and C harmonic patterns are patterns that I created/discovered myself. They are all inspired by the Cassiopeia constellation and each one is based on different rotations of the constellation as it moves through the sky. The range ratios are also based on the constellation's right ascension and declination listed on Wikipedia:
Right ascension 22h 57m 04.5897s–03h 41m 14.0997s
Declination 77.6923447°–48.6632690°
en.wikipedia.org
I actually developed this idea quite a while ago now but have not felt audacious enough to introduce a new harmonic pattern, let alone 3 at the same time! But I have since been able to run backtests on tick data going back to 2002 across a variety of market and timeframe combinations and have learned that the Cassiopeia patterns can certainly hold their own against the currently known harmonic patterns.
I would also point out that the Cassiopeia constellation does actually look like a harmonic pattern and the Cassiopeia A star is literally the 'strongest source of radio emission in the sky beyond the solar system', so its arguably more of a real harmonic phenomenon than the current patterns.
www.britannica.com
chandra.si.edu
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend and continues until a new downtrend ends the trend.
• A multi-part downtrend begins with the formation of a new downtrend and continues until a new return line uptrend ends the trend.
• A multi-part uptrend begins with the formation of a new uptrend and continues until a new return line downtrend ends the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend and continues until a new uptrend ends the trend.
Double Trends
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
Muti-Part Double Trends
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Retracement and Extension Ratios
Retracement and extension ratios are calculated by dividing the current range by the preceding range and multiplying the answer by 100. Retracement ratios are those that are equal to or below 100% of the preceding range and extension ratios are those that are above 100% of the preceding range.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Cassiopeia C Harmonic Patterns
• Bullish Cassiopeia C patterns are fundamentally composed of three troughs and two peaks. The second peak being higher than the first peak. And the third trough being lower than both the first and second troughs, while the second trough is higher than the first.
• Bearish Cassiopeia C patterns are fundamentally composed of three peaks and two troughs. The second trough being lower than the first trough. And the third peak being higher than both the first and second peaks, while the second peak is lower than the first.
The ratio measurements I use to detect the patterns are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace by at least 11.34%, but no further than 22.31% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should extend by at least 225.7%, but no further than 341% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should retrace by at least 77.69%, but no further than 88.66% of the range set by wave 3.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
I know a few people have been requesting a single indicator that contains all my patterns and I definitely hear you on that one. However, I have been very busy working on other projects while trying to trade and be a human at the same time. For now I am going to maintain my original approach of releasing each pattern individually so as to maintain consistency. But I am now also working on getting my some of my libraries ready for public release and in doing so I will finally be able to fit all patterns into one script. I will also be giving my scripts some TLC by making them cleaner once I have the libraries up and running. Please bear with me in the meantime, this may take a while. Cheers!
Bearish Cassiopeia B Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically detects and draws bearish Cassiopeia B harmonic patterns and price projections derived from the ranges that constitute the patterns.
Cassiopeia A, B and C harmonic patterns are patterns that I created/discovered myself. They are all inspired by the Cassiopeia constellation and each one is based on different rotations of the constellation as it moves through the sky. The range ratios are also based on the constellation's right ascension and declination listed on Wikipedia:
Right ascension 22h 57m 04.5897s–03h 41m 14.0997s
Declination 77.6923447°–48.6632690°
en.wikipedia.org
I actually developed this idea quite a while ago now but have not felt audacious enough to introduce a new harmonic pattern, let alone 3 at the same time! But I have since been able to run backtests on tick data going back to 2002 across a variety of market and timeframe combinations and have learned that the Cassiopeia patterns can certainly hold their own against the currently known harmonic patterns.
I would also point out that the Cassiopeia constellation does actually look like a harmonic pattern and the Cassiopeia A star is literally the 'strongest source of radio emission in the sky beyond the solar system', so its arguably more of a real harmonic phenomenon than the current patterns.
www.britannica.com
chandra.si.edu
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend and continues until a new downtrend ends the trend.
• A multi-part downtrend begins with the formation of a new downtrend and continues until a new return line uptrend ends the trend.
• A multi-part uptrend begins with the formation of a new uptrend and continues until a new return line downtrend ends the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend and continues until a new uptrend ends the trend.
Double Trends
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
Muti-Part Double Trends
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Retracement and Extension Ratios
Retracement and extension ratios are calculated by dividing the current range by the preceding range and multiplying the answer by 100. Retracement ratios are those that are equal to or below 100% of the preceding range and extension ratios are those that are above 100% of the preceding range.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Cassiopeia B Harmonic Patterns
• Bullish Cassiopeia B patterns are fundamentally composed of three troughs and two peaks. The second peak being lower than the first peak. And the third trough being lower than both the first and second troughs, while the second trough is also lower than the first.
• Bearish Cassiopeia B patterns are fundamentally composed of three peaks and two troughs. The second trough being higher than the first trough. And the third peak being higher than both the first and second peaks, while the second peak is also higher than the first.
The ratio measurements I use to detect the patterns are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace by at least 11.34%, but no further than 22.31% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should extend by at least 225.7%, but no further than 341% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should retrace by at least 77.69%, but no further than 88.66% of the range set by wave 3.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
I know a few people have been requesting a single indicator that contains all my patterns and I definitely hear you on that one. However, I have been very busy working on other projects while trying to trade and be a human at the same time. For now I am going to maintain my original approach of releasing each pattern individually so as to maintain consistency. But I am now also working on getting my some of my libraries ready for public release and in doing so I will finally be able to fit all patterns into one script. I will also be giving my scripts some TLC by making them cleaner once I have the libraries up and running. Please bear with me in the meantime, this may take a while. Cheers!
Bullish Cassiopeia B Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically detects and draws bullish Cassiopeia B harmonic patterns and price projections derived from the ranges that constitute the patterns.
Cassiopeia A, B and C harmonic patterns are patterns that I created/discovered myself. They are all inspired by the Cassiopeia constellation and each one is based on different rotations of the constellation as it moves through the sky. The range ratios are also based on the constellation's right ascension and declination listed on Wikipedia:
Right ascension 22h 57m 04.5897s–03h 41m 14.0997s
Declination 77.6923447°–48.6632690°
en.wikipedia.org
I actually developed this idea quite a while ago now but have not felt audacious enough to introduce a new harmonic pattern, let alone 3 at the same time! But I have since been able to run backtests on tick data going back to 2002 across a variety of market and timeframe combinations and have learned that the Cassiopeia patterns can certainly hold their own against the currently known harmonic patterns.
I would also point out that the Cassiopeia constellation does actually look like a harmonic pattern and the Cassiopeia A star is literally the 'strongest source of radio emission in the sky beyond the solar system', so its arguably more of a real harmonic phenomenon than the current patterns.
www.britannica.com
chandra.si.edu
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend and continues until a new downtrend ends the trend.
• A multi-part downtrend begins with the formation of a new downtrend and continues until a new return line uptrend ends the trend.
• A multi-part uptrend begins with the formation of a new uptrend and continues until a new return line downtrend ends the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend and continues until a new uptrend ends the trend.
Double Trends
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
Muti-Part Double Trends
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Retracement and Extension Ratios
Retracement and extension ratios are calculated by dividing the current range by the preceding range and multiplying the answer by 100. Retracement ratios are those that are equal to or below 100% of the preceding range and extension ratios are those that are above 100% of the preceding range.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Cassiopeia B Harmonic Patterns
• Bullish Cassiopeia B patterns are fundamentally composed of three troughs and two peaks. The second peak being lower than the first peak. And the third trough being lower than both the first and second troughs, while the second trough is also lower than the first.
• Bearish Cassiopeia B patterns are fundamentally composed of three peaks and two troughs. The second trough being higher than the first trough. And the third peak being higher than both the first and second peaks, while the second peak is also higher than the first.
The ratio measurements I use to detect the patterns are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace by at least 11.34%, but no further than 22.31% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should extend by at least 225.7%, but no further than 341% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should retrace by at least 77.69%, but no further than 88.66% of the range set by wave 3.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
I know a few people have been requesting a single indicator that contains all my patterns and I definitely hear you on that one. However, I have been very busy working on other projects while trying to trade and be a human at the same time. For now I am going to maintain my original approach of releasing each pattern individually so as to maintain consistency. But I am now also working on getting my some of my libraries ready for public release and in doing so I will finally be able to fit all patterns into one script. I will also be giving my scripts some TLC by making them cleaner once I have the libraries up and running. Please bear with me in the meantime, this may take a while. Cheers!
Bearish Cassiopeia A Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically detects and draws bearish Cassiopeia A harmonic patterns and price projections derived from the ranges that constitute the patterns.
Cassiopeia A, B and C harmonic patterns are patterns that I created/discovered myself. They are all inspired by the Cassiopeia constellation and each one is based on different rotations of the constellation as it moves through the sky. The range ratios are also based on the constellation's right ascension and declination listed on Wikipedia:
Right ascension 22h 57m 04.5897s–03h 41m 14.0997s
Declination 77.6923447°–48.6632690°
en.wikipedia.org
I actually developed this idea quite a while ago now but have not felt audacious enough to introduce a new harmonic pattern, let alone 3 at the same time! But I have since been able to run backtests on tick data going back to 2002 across a variety of market and timeframe combinations and have learned that the Cassiopeia patterns can certainly hold their own against the currently known harmonic patterns.
I would also point out that the Cassiopeia constellation does actually look like a harmonic pattern and the Cassiopeia A star is literally the 'strongest source of radio emission in the sky beyond the solar system', so its arguably more of a real harmonic phenomenon than the current patterns.
www.britannica.com
chandra.si.edu
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend and continues until a new downtrend ends the trend.
• A multi-part downtrend begins with the formation of a new downtrend and continues until a new return line uptrend ends the trend.
• A multi-part uptrend begins with the formation of a new uptrend and continues until a new return line downtrend ends the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend and continues until a new uptrend ends the trend.
Double Trends
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
Muti-Part Double Trends
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Retracement and Extension Ratios
Retracement and extension ratios are calculated by dividing the current range by the preceding range and multiplying the answer by 100. Retracement ratios are those that are equal to or below 100% of the preceding range and extension ratios are those that are above 100% of the preceding range.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Cassiopeia A Harmonic Patterns
• Bullish Cassiopeia A patterns are fundamentally composed of three troughs and two peaks. The second peak being higher than the first peak. And the third trough being higher than both the first and second troughs, while the second trough is also higher than the first.
• Bearish Cassiopeia A patterns are fundamentally composed of three peaks and two troughs. The second trough being lower than the first trough. And the third peak being lower than both the first and second peaks, while the second peak is also lower than the first.
The ratio measurements I use to detect the patterns are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace by at least 11.34%, but no further than 22.31% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should extend by at least 225.7%, but no further than 341% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should retrace by at least 77.69%, but no further than 88.66% of the range set by wave 3.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
I know a few people have been requesting a single indicator that contains all my patterns and I definitely hear you on that one. However, I have been very busy working on other projects while trying to trade and be a human at the same time. For now I am going to maintain my original approach of releasing each pattern individually so as to maintain consistency. But I am now also working on getting my some of my libraries ready for public release and in doing so I will finally be able to fit all patterns into one script. I will also be giving my scripts some TLC by making them cleaner once I have the libraries up and running. Please bear with me in the meantime, this may take a while. Cheers!
Bullish Cassiopeia A Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically detects and draws bullish Cassiopeia A harmonic patterns and price projections derived from the ranges that constitute the patterns.
Cassiopeia A, B and C harmonic patterns are patterns that I created/discovered myself. They are all inspired by the Cassiopeia constellation and each one is based on different rotations of the constellation as it moves through the sky. The range ratios are also based on the constellation's right ascension and declination listed on Wikipedia:
Right ascension 22h 57m 04.5897s–03h 41m 14.0997s
Declination 77.6923447°–48.6632690°
en.wikipedia.org
I actually developed this idea quite a while ago now but have not felt audacious enough to introduce a new harmonic pattern, let alone 3 at the same time! But I have since been able to run backtests on tick data going back to 2002 across a variety of market and timeframe combinations and have learned that the Cassiopeia patterns can certainly hold their own against the currently known harmonic patterns. As can be seen in the picture above the bullish Cassiopeia A caught the 2009 bear market bottom almost perfectly.
I would also point out that the Cassiopeia constellation does actually look like a harmonic pattern and the Cassiopeia A star is literally the 'strongest source of radio emission in the sky beyond the solar system', so its arguably more of a real harmonic phenomenon than the current patterns.
www.britannica.com
chandra.si.edu
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend and continues until a new downtrend ends the trend.
• A multi-part downtrend begins with the formation of a new downtrend and continues until a new return line uptrend ends the trend.
• A multi-part uptrend begins with the formation of a new uptrend and continues until a new return line downtrend ends the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend and continues until a new uptrend ends the trend.
Double Trends
• A double uptrend is formed when the current trough price is higher than the preceding trough price and the current peak price is higher than the preceding peak price.
• A double downtrend is formed when the current peak price is lower than the preceding peak price and the current trough price is lower than the preceding trough price.
Muti-Part Double Trends
• A multi-part double uptrend begins with the formation of a new uptrend that proceeds a new return line uptrend, and continues until a new downtrend or return line downtrend ends the trend.
• A multi-part double downtrend begins with the formation of a new downtrend that proceeds a new return line downtrend, and continues until a new uptrend or return line uptrend ends the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Retracement and Extension Ratios
Retracement and extension ratios are calculated by dividing the current range by the preceding range and multiplying the answer by 100. Retracement ratios are those that are equal to or below 100% of the preceding range and extension ratios are those that are above 100% of the preceding range.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Cassiopeia A Harmonic Patterns
• Bullish Cassiopeia A patterns are fundamentally composed of three troughs and two peaks. The second peak being higher than the first peak. And the third trough being higher than both the first and second troughs, while the second trough is also higher than the first.
• Bearish Cassiopeia A patterns are fundamentally composed of three peaks and two troughs. The second trough being lower than the first trough. And the third peak being lower than both the first and second peaks, while the second peak is also lower than the first.
The ratio measurements I use to detect the patterns are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace by at least 11.34%, but no further than 22.31% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should extend by at least 225.7%, but no further than 341% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should retrace by at least 77.69%, but no further than 88.66% of the range set by wave 3.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
I know a few people have been requesting a single indicator that contains all my patterns and I definitely hear you on that one. However, I have been very busy working on other projects while trying to trade and be a human at the same time. For now I am going to maintain my original approach of releasing each pattern individually so as to maintain consistency. But I am now also working on getting my some of my libraries ready for public release and in doing so I will finally be able to fit all patterns into one script. I will also be giving my scripts some TLC by making them cleaner once I have the libraries up and running. Please bear with me in the meantime, this may take a while. Cheers!
Bearish Cypher Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bearish cypher harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Cypher Patterns
• Bullish cypher patterns are fundamentally composed of three troughs and two peaks, with the second peak being higher than the first peak and the second trough being higher than the first trough. The third trough must be lower than the second trough but higher than the first.
• Bearish cypher patterns are fundamentally composed of three peaks and two troughs, with the second trough being lower than the first trough and the second peak being lower than the first peak. The third peak must be higher than the second peak but lower than the first.
The most commonly recognised ratio measures used by traders today are as follows:
• Wave 1 of the pattern, referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, referred to as AB, should retrace to at least 38.2%, but no further than 61.8% of the range set by wave 1.
• Wave 3 of the pattern, referred to as BC, should extend to at least 113%, but no further than 141.4% of the range set by wave 2.
• Wave 4 of the pattern, referred to as CD, should extend to at least 127.2%, but no further than 200% of the range set by wave 3.
• The last measure, that of wave 4 as a ratio of the range set between points X and C, referred to as XC, should retrace to 78.6%.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• XC Lower Tolerance
• XC Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
The cypher pattern was initially discovered by Darren Oglesbee, but I was unable to find any direct sources to his work on harmonic patterns. And although there seems to be some contention over whether or not there should be a ratio requirement for the CD wave, I decided to include it nonetheless.
Bullish Cypher Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bullish cypher harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Cypher Patterns
• Bullish cypher patterns are fundamentally composed of three troughs and two peaks, with the second peak being higher than the first peak and the second trough being higher than the first trough. The third trough must be lower than the second trough but higher than the first.
• Bearish cypher patterns are fundamentally composed of three peaks and two troughs, with the second trough being lower than the first trough and the second peak being lower than the first peak. The third peak must be higher than the second peak but lower than the first.
The most commonly recognised ratio measures used by traders today are as follows:
• Wave 1 of the pattern, referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, referred to as AB, should retrace to at least 38.2%, but no further than 61.8% of the range set by wave 1.
• Wave 3 of the pattern, referred to as BC, should extend to at least 113%, but no further than 141.4% of the range set by wave 2.
• Wave 4 of the pattern, referred to as CD, should extend to at least 127.2%, but no further than 200% of the range set by wave 3.
• The last measure, that of wave 4 as a ratio of the range set between points X and C, referred to as XC, should retrace to 78.6%.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• XC Lower Tolerance
• XC Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
The cypher pattern was initially discovered by Darren Oglesbee, but I was unable to find any direct sources to his work on harmonic patterns. And although there seems to be some contention over whether or not there should be a ratio requirement for the CD wave, I decided to include it nonetheless.
Bearish Deep Crab Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bearish deep crab harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Deep Crab Patterns
• Bullish deep crab patterns are fundamentally composed of three troughs and two peaks. The second peak being lower than the first peak. And the third trough being lower than both the first and second troughs, while the second trough is higher than the first.
• Bearish deep crab patterns are fundamentally composed of three peaks and two troughs. The second trough being higher than the first trough. And the third peak being higher than both the first and second peaks, while the second peak is lower than the first.
The ratio measurements recommended by Scott Carney, who originated the pattern, are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace to 88.6% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should retrace by at least 38.2%, but no further than 88.6% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should extend to at least 200%, but no further than 361.8% of the range set by wave 3.
• The last measure, generally referred to as AD, is that of wave 4 as a ratio of the range set by wave 1, which should extend to 161.8%.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• AD Lower Tolerance
• AD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
A link to Scott's harmonic patterns webpage for anyone who may be interested: harmonictrader.com/harmonic-patterns/
Bullish Deep Crab Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bullish deep crab harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Deep Crab Patterns
• Bullish deep crab patterns are fundamentally composed of three troughs and two peaks. The second peak being lower than the first peak. And the third trough being lower than both the first and second troughs, while the second trough is higher than the first.
• Bearish deep crab patterns are fundamentally composed of three peaks and two troughs. The second trough being higher than the first trough. And the third peak being higher than both the first and second peaks, while the second peak is lower than the first.
The ratio measurements recommended by Scott Carney, who originated the pattern, are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace to 88.6% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should retrace by at least 38.2%, but no further than 88.6% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should extend to at least 200%, but no further than 361.8% of the range set by wave 3.
• The last measure, generally referred to as AD, is that of wave 4 as a ratio of the range set by wave 1, which should extend to 161.8%.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• AD Lower Tolerance
• AD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
A link to Scott's harmonic patterns webpage for anyone who may be interested: harmonictrader.com/harmonic-patterns/
Bearish Alternate Bat Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bearish alternate bat harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Alternate Bat Patterns
• Bullish alternate bat patterns are fundamentally composed of three troughs and two peaks. The second peak being lower than the first peak and the second trough being higher than the first, with the third trough being lower than both the first and second troughs.
• Bearish alternate bat patterns are fundamentally composed of three peaks and two troughs. The second trough being higher than the first trough and the second peak being lower than the first, with the third peak being higher than both the first and second peaks.
The ratio measurements recommended by Scott Carney, who originated the pattern, are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace to 38.2% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should retrace by at least 38.2%, but no further than 88.6% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should extend to at least 200%, but no further than 361.8% of the range set by wave 3.
• The last measure, generally referred to as AD, is that of wave 4 as a ratio of the range set by wave 1, which should extend to 113%.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• AD Lower Tolerance
• AD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
A link to Scott's harmonic patterns webpage for anyone who may be interested: harmonictrader.com/harmonic-patterns/
Bullish Alternate Bat Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bullish alternate bat harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Alternate Bat Patterns
• Bullish alternate bat patterns are fundamentally composed of three troughs and two peaks. The second peak being lower than the first peak and the second trough being higher than the first, with the third trough being lower than both the first and second troughs.
• Bearish alternate bat patterns are fundamentally composed of three peaks and two troughs. The second trough being higher than the first trough and the second peak being lower than the first, with the third peak being higher than both the first and second peaks.
The ratio measurements recommended by Scott Carney, who originated the pattern, are as follows:
• Wave 1 of the pattern, generally referred to as XA, has no specific ratio requirements.
• Wave 2 of the pattern, generally referred to as AB, should retrace to 38.2% of the range set by wave 1.
• Wave 3 of the pattern, generally referred to as BC, should retrace by at least 38.2%, but no further than 88.6% of the range set by wave 2.
• Wave 4 of the pattern, generally referred to as CD, should extend to at least 200%, but no further than 361.8% of the range set by wave 3.
• The last measure, generally referred to as AD, is that of wave 4 as a ratio of the range set by wave 1, which should extend to 113%.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• AD Lower Tolerance
• AD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
Alerts
Users can set alerts for when the patterns occur.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
A link to Scott's harmonic patterns webpage for anyone who may be interested: harmonictrader.com/harmonic-patterns/
Bearish 5-0 Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bearish 5-0 harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend, or higher peak, and continues until a new downtrend, or lower peak, completes the trend.
• A multi-part downtrend begins with the formation of a new downtrend, or lower peak, and continues until a new return line uptrend, or higher peak, completes the trend.
• A multi-part uptrend begins with the formation of a new uptrend, or higher trough, and continues until a new return line downtrend, or lower trough, completes the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend, or lower trough, and continues until a new uptrend, or higher trough, completes the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish 5-0 Patterns
• Bullish 5-0 patterns are fundamentally composed of three peaks and three troughs, with the second peak being lower than the first peak and the third peak being higher than the first peak. And similarly, the second trough being lower than the first trough and the third trough being higher than both the first and second troughs.
• Bearish 5-0 patterns are fundamentally composed of three troughs and three peaks, with the second trough being higher than the first trough and the third trough being lower than the first trough. And similarly, the second peak being higher than the first peak and the third peak being lower than both the first and second peaks.
The ratio measurements recommended by Scott Carney, who originated the pattern, are as follows:
• Wave 1 of the pattern, referred to as OX, has no specific ratio requirements.
• Wave 2 of the pattern, referred to as XA, has no specific ratio requirements.
• Wave 3 of the pattern, referred to as AB, should extend to at least 113%, but no further than 161.8% of the range set by wave 2.
• Wave 4 of the pattern, referred to as BC, should extend to at least 161.8%, but no further than 224% of the range set by wave 3.
• Wave 5 of the pattern, referred to as CD, should retrace to 50.0% of the range set by wave 4.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
Here is a link to Scott's harmonic patterns webpage for those who may be interested: harmonictrader.com
Bullish 5-0 Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bullish 5-0 harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend, or higher peak, and continues until a new downtrend, or lower peak, completes the trend.
• A multi-part downtrend begins with the formation of a new downtrend, or lower peak, and continues until a new return line uptrend, or higher peak, completes the trend.
• A multi-part uptrend begins with the formation of a new uptrend, or higher trough, and continues until a new return line downtrend, or lower trough, completes the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend, or lower trough, and continues until a new uptrend, or higher trough, completes the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish 5-0 Patterns
• Bullish 5-0 patterns are fundamentally composed of three peaks and three troughs, with the second peak being lower than the first peak and the third peak being higher than the first peak. And similarly, the second trough being lower than the first trough and the third trough being higher than both the first and second troughs.
• Bearish 5-0 patterns are fundamentally composed of three troughs and three peaks, with the second trough being higher than the first trough and the third trough being lower than the first trough. And similarly, the second peak being higher than the first peak and the third peak being lower than both the first and second peaks.
The ratio measurements recommended by Scott Carney, who originated the pattern, are as follows:
• Wave 1 of the pattern, referred to as OX, has no specific ratio requirements.
• Wave 2 of the pattern, referred to as XA, has no specific ratio requirements.
• Wave 3 of the pattern, referred to as AB, should extend to at least 113%, but no further than 161.8% of the range set by wave 2.
• Wave 4 of the pattern, referred to as BC, should extend to at least 161.8%, but no further than 224% of the range set by wave 3.
• Wave 5 of the pattern, referred to as CD, should retrace to 50.0% of the range set by wave 4.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• CD Lower Tolerance
• CD Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
Here is a link to Scott's harmonic patterns webpage for those who may be interested: harmonictrader.com
Bearish Shark Harmonic Patterns [theEccentricTrader]█ OVERVIEW
This indicator automatically draws bearish Shark harmonic patterns and price projections derived from the ranges that constitute the patterns.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a close price equal to or above the price it opened.
• A red candle is one that closes with a close price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Range
The range is simply the difference between the current peak and current trough prices, generally expressed in terms of points or pips.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Upper Trends
• A return line uptrend is formed when the current peak price is higher than the preceding peak price.
• A downtrend is formed when the current peak price is lower than the preceding peak price.
• A double-top is formed when the current peak price is equal to the preceding peak price.
Lower Trends
• An uptrend is formed when the current trough price is higher than the preceding trough price.
• A return line downtrend is formed when the current trough price is lower than the preceding trough price.
• A double-bottom is formed when the current trough price is equal to the preceding trough price.
Muti-Part Upper and Lower Trends
• A multi-part return line uptrend begins with the formation of a new return line uptrend, or higher peak, and continues until a new downtrend, or lower peak, completes the trend.
• A multi-part downtrend begins with the formation of a new downtrend, or lower peak, and continues until a new return line uptrend, or higher peak, completes the trend.
• A multi-part uptrend begins with the formation of a new uptrend, or higher trough, and continues until a new return line downtrend, or lower trough, completes the trend.
• A multi-part return line downtrend begins with the formation of a new return line downtrend, or lower trough, and continues until a new uptrend, or higher trough, completes the trend.
Wave Cycles
A wave cycle is here defined as a complete two-part move between a swing high and a swing low, or a swing low and a swing high. The first swing high or swing low will set the course for the sequence of wave cycles that follow; for example a chart that begins with a swing low will form its first complete wave cycle upon the formation of the first complete swing high and vice versa.
Figure 1.
Fibonacci Retracement and Extension Ratios
The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers, starting with 0 and 1. For example 0 + 1 = 1, 1 + 1 = 2, 1 + 2 = 3, and so on. Ultimately, we could go on forever but the first few numbers in the sequence are as follows: 0 , 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144.
The extension ratios are calculated by dividing each number in the sequence by the number preceding it. For example 0/1 = 0, 1/1 = 1, 2/1 = 2, 3/2 = 1.5, 5/3 = 1.6666..., 8/5 = 1.6, 13/8 = 1.625, 21/13 = 1.6153..., 34/21 = 1.6190..., 55/34 = 1.6176..., 89/55 = 1.6181..., 144/89 = 1.6179..., and so on. The retracement ratios are calculated by inverting this process and dividing each number in the sequence by the number proceeding it. For example 0/1 = 0, 1/1 = 1, 1/2 = 0.5, 2/3 = 0.666..., 3/5 = 0.6, 5/8 = 0.625, 8/13 = 0.6153..., 13/21 = 0.6190..., 21/34 = 0.6176..., 34/55 = 0.6181..., 55/89 = 0.6179..., 89/144 = 0.6180..., and so on.
1.618 is considered to be the 'golden ratio', found in many natural phenomena such as the growth of seashells and the branching of trees. Some now speculate the universe oscillates at a frequency of 0,618 Hz, which could help to explain such phenomena, but this theory has yet to be proven.
Traders and analysts use Fibonacci retracement and extension indicators, consisting of horizontal lines representing different Fibonacci ratios, for identifying potential levels of support and resistance. Fibonacci ranges are typically drawn from left to right, with retracement levels representing ratios inside of the current range and extension levels representing ratios extended outside of the current range. If the current wave cycle ends on a swing low, the Fibonacci range is drawn from peak to trough. If the current wave cycle ends on a swing high the Fibonacci range is drawn from trough to peak.
Harmonic Patterns
The concept of harmonic patterns in trading was first introduced by H.M. Gartley in his book "Profits in the Stock Market", published in 1935. Gartley observed that markets have a tendency to move in repetitive patterns, and he identified several specific patterns that he believed could be used to predict future price movements.
Since then, many other traders and analysts have built upon Gartley's work and developed their own variations of harmonic patterns. One such contributor is Larry Pesavento, who developed his own methods for measuring harmonic patterns using Fibonacci ratios. Pesavento has written several books on the subject of harmonic patterns and Fibonacci ratios in trading. Another notable contributor to harmonic patterns is Scott Carney, who developed his own approach to harmonic trading in the late 1990s and also popularised the use of Fibonacci ratios to measure harmonic patterns. Carney expanded on Gartley's work and also introduced several new harmonic patterns, such as the Shark pattern and the 5-0 pattern.
The bullish and bearish Gartley patterns are the oldest recognized harmonic patterns in trading and all the other harmonic patterns are ultimately modifications of the original Gartley patterns. Gartley patterns are fundamentally composed of 5 points, or 4 waves.
Bullish and Bearish Shark Patterns
• Bullish shark patterns are fundamentally composed of three troughs and two peaks, with the second peak being higher than the first peak and the second trough being higher than the first trough. The third trough must be lower than the second trough but can be above or below the first trough providing it meets the ratio requirements.
• Bearish shark patterns are fundamentally composed of three peaks and two troughs, with the second trough being lower than the first trough and the second peak being lower than the first peak. The third peak must be higher than the second peak but can be above or below the first peak providing it meets the ratio requirements.
The ratio measurements recommended by Scott Carney, who originated the pattern, are as follows:
• Wave 1 of the pattern, referred to as OX, has no specific ratio requirements.
• Wave 2 of the pattern, referred to as XA, has no specific ratio requirements.
• Wave 3 of the pattern, referred to as AB, should extend to at least 113%, but no further than 161.8% of the range set by wave 2.
• Wave 4 of the pattern, referred to as BC, should extend to at least 161.8%, but no further than 224% of the range set by wave 3.
• The last measure, referred to as XC, is that of wave 4 as a ratio of the range set by wave 1, which should extend to at least 88.6%, but no further than 113%.
Measurement Tolerances
In general, tolerance in measurements refers to the allowable variation or deviation from a specific value or dimension. It is the range within which a particular measurement is considered to be acceptable or accurate. In this script I have applied this concept to the measurement of harmonic pattern ratios to increase to the frequency of pattern occurrences.
For example, the AB measurement of Gartley patterns is generally set at around 61.8%, but with such specificity in the measuring requirements the patterns are very rare. We can increase the frequency of pattern occurrences by setting a tolerance. A tolerance of 10% to both downside and upside, which is the default setting for all tolerances, means we would have a tolerable measurement range between 51.8-71.8%, thus increasing the frequency of occurrence.
█ FEATURES
Inputs
• AB Lower Tolerance
• AB Upper Tolerance
• BC Lower Tolerance
• BC Upper Tolerance
• XC Lower Tolerance
• XC Upper Tolerance
• Pattern Color
• Label Color
• Show Projections
• Extend Current Projection Lines
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
█ NOTES
Here is a link to Scott's harmonic patterns webpage for those who may be interested: harmonictrader.com