Skip to content

Commit 1673423

Browse files
committed
Add esearch folder
1 parent d89a1b7 commit 1673423

16 files changed

+578
-0
lines changed

‎research/chart_type_identifier.pine

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
//@version=4
2+
// Copyright (c) 2019-present, Alex Orekhov (everget)
3+
// Chart Type Identifier script may be freely distributed under the terms of the GPL-3.0 license.
4+
study("Chart Type Identifier", overlay=true)
5+
6+
max = max(open, close)
7+
min = min(open, close)
8+
body = abs(close - open)
9+
10+
var int horizCount = -1
11+
if open[1] == close or close[1] == open
12+
horizCount := horizCount + 1
13+
14+
var int gapsCount = -1
15+
if low[1] > high or high[1] < low
16+
gapsCount := gapsCount + 1
17+
18+
var int noWicksCount = -1
19+
if max == high and min == low
20+
noWicksCount := noWicksCount + 1
21+
22+
//------------------------------------------------------------------------------
23+
24+
_isHA() =>
25+
var int oc2Count = -1
26+
oc2Count := open == (open[1] + close[1]) / 2 ? oc2Count + 1 : oc2Count
27+
out = oc2Count == bar_index - 1 and oc2Count != -1 and gapsCount == -1
28+
out
29+
30+
isHA = _isHA()
31+
32+
_isRenko() =>
33+
bodySum = cum(body)
34+
avg = bodySum / (bar_index + 1)
35+
out = avg == body and gapsCount == -1
36+
out
37+
38+
isRenko = _isRenko()
39+
40+
_isKagi() =>
41+
out = noWicksCount == bar_index and horizCount == bar_index - 1 and gapsCount == -1
42+
out
43+
44+
isKagi = _isKagi()
45+
46+
_isPnF() =>
47+
var int sum = 0
48+
sum := close > close[1] ? sum + 1 : close < close[1] ? sum - 1 : sum
49+
out = (sum == 1 or sum == 0 or sum == -1) and horizCount < bar_index - 1
50+
out
51+
52+
isPnF = _isPnF()
53+
54+
_isLineBreak() =>
55+
out = noWicksCount == bar_index and horizCount < bar_index - 1 and gapsCount == -1
56+
out
57+
58+
isLineBreak = not isPnF and _isLineBreak()
59+
60+
monthData = security(syminfo.tickerid, "M", close)
61+
weekData = security(syminfo.tickerid, "W", close)
62+
dayData = security(syminfo.tickerid, "D", close)
63+
hourData = security(syminfo.tickerid, "60", close)
64+
minuteData = security(syminfo.tickerid, "1", close)
65+
66+
_isRangeBars() =>
67+
out =
68+
timeframe.period != "S" and
69+
minuteData == monthData and
70+
minuteData == weekData and
71+
minuteData == dayData and
72+
minuteData == hourData and
73+
minuteData == close
74+
out
75+
76+
isRangeBars = _isRangeBars()
77+
78+
isClassic =
79+
not isHA and
80+
not isRenko and
81+
not isKagi and
82+
not isPnF and
83+
not isLineBreak and
84+
not isRangeBars
85+
86+
labelText =
87+
bar_index < 2 ? "\nNot enough bars to identify Chart Type\n" :
88+
isHA ? "\nThis is Heikin-Ashi Chart\n" :
89+
isRenko ? "\nThis is Renko Chart\n" :
90+
isKagi ? "\nThis is Kagi Chart\n" :
91+
isRangeBars ? "\nThis is Range Bars Chart\n" :
92+
isPnF ? "\nThis is P&F Chart\n" :
93+
isLineBreak ? "\nThis is Line Break Chart\n" :
94+
isClassic ? "\nThis is Classic Chart\n" :
95+
"\nUnknown Chart Type\n"
96+
97+
labelColor = #1e90ff
98+
whiteColor = color.white
99+
100+
var label l = label.new(
101+
x=bar_index,
102+
y=na,
103+
text="",
104+
color=labelColor,
105+
textcolor=whiteColor,
106+
style=label.style_labeldown,
107+
size=size.normal
108+
)
109+
110+
_highest(length) =>
111+
out = high
112+
for i = 1 to length - 1
113+
prev = nz(high[i])
114+
out := out < prev ? prev : out
115+
out
116+
117+
lookback = min(bar_index + 2, 50)
118+
yPos = _highest(lookback)
119+
120+
// debug =
121+
// "\nBar Index: " + tostring(int(bar_index)) +
122+
// "\nGaps: " + tostring(gapsCount) +
123+
// "\nHoriz: " + tostring(horizCount) +
124+
// "\nNo Wicks: " + tostring(noWicksCount)
125+
126+
label.set_text(l, labelText) // + debug
127+
label.set_xy(l, bar_index, yPos)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//@version=3
2+
// Copyright (c) 2018-present, Alex Orekhov (everget)
3+
// Custom Median vs Built-in Median script may be freely distributed under the GPL-3.0 license.
4+
study("Custom Median vs Built-in Median", shorttitle="CMvsBM")
5+
6+
length = input(title="Length", type=integer, minval=1, defval=14)
7+
src = input(title="Source", type=source, defval=close)
8+
9+
// Built-in Median
10+
median(src, length) =>
11+
percentile_nearest_rank(src, length, 50)
12+
13+
sort(src, length, i) =>
14+
min = -10000.0
15+
16+
for j = 0 to i
17+
min_local = 10000.0
18+
19+
for l = 0 to length - 1
20+
if (nz(src[l]) <= min)
21+
continue
22+
23+
min_local := min(min_local, max(min, nz(src[l])))
24+
25+
if min_local != 10000
26+
min := min_local
27+
min
28+
29+
// Custom Median
30+
customMedian(src, length) =>
31+
out = 0.0
32+
33+
if length % 2 == 0
34+
out := (sort(src, length, length / 2 - 1) + sort(src, length, length / 2)) / 2
35+
else
36+
out := sort(src, length, length / 2 - 0.5)
37+
out
38+
39+
diff = median(src, length) - customMedian(src, length)
40+
41+
plot(diff, title="CMvsBM", transp=0)

‎research/dashed_line_style.pine

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@version=3
2+
// Copyright (c) 2019-present, Alex Orekhov (everget)
3+
// Dashed Line Style script may be freely distributed under the GPL-3.0 license.
4+
study("Dashed Line Style", overlay=true)
5+
6+
sma = sma(close, 14)
7+
8+
plot(n % 3 != 0 ? sma : na, style=linebr, linewidth=3, color=black, transp=0)

‎research/fancy_shapes.pine

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
//@version=4
2+
// Copyright (c) 2019-present, Alex Orekhov (everget)
3+
// Fancy Shapes script may be freely distributed under the terms of the GPL-3.0 license.
4+
study("Fancy Shapes")
5+
6+
y0 = 0
7+
offset0 = 0
8+
9+
y1 = 0
10+
offset1 = -20
11+
12+
y2 = 0
13+
offset2 = -40
14+
15+
y3 = 0
16+
offset3 = -60
17+
18+
y4 = 0
19+
offset4 = -80
20+
21+
y5 = 0
22+
offset5 = -100
23+
24+
y6 = 0
25+
offset6 = -120
26+
27+
plotshape(y0, location=location.absolute, style=shape.flag, size=size.huge, color=color.blue, transp=80, show_last=1, offset=offset0)
28+
plotshape(y0, location=location.absolute, style=shape.flag, size=size.large, color=color.blue, transp=80, show_last=1, offset=offset0)
29+
plotshape(y0, location=location.absolute, style=shape.flag, size=size.normal, color=color.blue, transp=80, show_last=1, offset=offset0)
30+
plotshape(y0, location=location.absolute, style=shape.flag, size=size.small, color=color.blue, transp=80, show_last=1, offset=offset0)
31+
plotshape(y0, location=location.absolute, style=shape.flag, size=size.tiny, color=color.blue, transp=80, show_last=1, offset=offset0)
32+
33+
plotshape(y1, location=location.absolute, style=shape.square, size=size.huge, color=color.blue, transp=80, show_last=1, offset=offset1)
34+
plotshape(y1, location=location.absolute, style=shape.square, size=size.large, color=color.blue, transp=80, show_last=1, offset=offset1)
35+
plotshape(y1, location=location.absolute, style=shape.square, size=size.normal, color=color.blue, transp=80, show_last=1, offset=offset1)
36+
plotshape(y1, location=location.absolute, style=shape.square, size=size.small, color=color.blue, transp=80, show_last=1, offset=offset1)
37+
plotshape(y1, location=location.absolute, style=shape.square, size=size.tiny, color=color.blue, transp=80, show_last=1, offset=offset1)
38+
39+
plotshape(y2, location=location.absolute, style=shape.diamond, size=size.huge, color=color.blue, transp=80, show_last=1, offset=offset2)
40+
plotshape(y2, location=location.absolute, style=shape.diamond, size=size.large, color=color.blue, transp=80, show_last=1, offset=offset2)
41+
plotshape(y2, location=location.absolute, style=shape.diamond, size=size.normal, color=color.blue, transp=80, show_last=1, offset=offset2)
42+
plotshape(y2, location=location.absolute, style=shape.diamond, size=size.small, color=color.blue, transp=80, show_last=1, offset=offset2)
43+
plotshape(y2, location=location.absolute, style=shape.diamond, size=size.tiny, color=color.blue, transp=80, show_last=1, offset=offset2)
44+
45+
plotshape(y3, location=location.absolute, style=shape.triangleup, size=size.huge, color=color.blue, transp=80, show_last=1, offset=offset3)
46+
plotshape(y3, location=location.absolute, style=shape.triangleup, size=size.large, color=color.blue, transp=80, show_last=1, offset=offset3)
47+
plotshape(y3, location=location.absolute, style=shape.triangleup, size=size.normal, color=color.blue, transp=80, show_last=1, offset=offset3)
48+
plotshape(y3, location=location.absolute, style=shape.triangleup, size=size.small, color=color.blue, transp=80, show_last=1, offset=offset3)
49+
plotshape(y3, location=location.absolute, style=shape.triangleup, size=size.tiny, color=color.blue, transp=80, show_last=1, offset=offset3)
50+
51+
plotshape(y4, location=location.absolute, style=shape.circle, size=size.huge, color=color.blue, transp=80, show_last=1, offset=offset4)
52+
plotshape(y4, location=location.absolute, style=shape.circle, size=size.large, color=color.blue, transp=80, show_last=1, offset=offset4)
53+
plotshape(y4, location=location.absolute, style=shape.circle, size=size.normal, color=color.blue, transp=80, show_last=1, offset=offset4)
54+
plotshape(y4, location=location.absolute, style=shape.circle, size=size.small, color=color.blue, transp=80, show_last=1, offset=offset4)
55+
plotshape(y4, location=location.absolute, style=shape.circle, size=size.tiny, color=color.blue, transp=80, show_last=1, offset=offset4)
56+
57+
plotshape(y5, location=location.absolute, style=shape.labelup, size=size.huge, color=color.blue, transp=80, show_last=1, offset=offset5)
58+
plotshape(y5, location=location.absolute, style=shape.labelup, size=size.large, color=color.blue, transp=80, show_last=1, offset=offset5)
59+
plotshape(y5, location=location.absolute, style=shape.labelup, size=size.normal, color=color.blue, transp=80, show_last=1, offset=offset5)
60+
plotshape(y5, location=location.absolute, style=shape.labelup, size=size.small, color=color.blue, transp=80, show_last=1, offset=offset5)
61+
plotshape(y5, location=location.absolute, style=shape.labelup, size=size.tiny, color=color.blue, transp=80, show_last=1, offset=offset5)
62+
63+
plotshape(y6, location=location.absolute, style=shape.labeldown, size=size.huge, color=color.blue, transp=80, show_last=1, offset=offset6)
64+
plotshape(y6, location=location.absolute, style=shape.labeldown, size=size.large, color=color.blue, transp=80, show_last=1, offset=offset6)
65+
plotshape(y6, location=location.absolute, style=shape.labeldown, size=size.normal, color=color.blue, transp=80, show_last=1, offset=offset6)
66+
plotshape(y6, location=location.absolute, style=shape.labeldown, size=size.small, color=color.blue, transp=80, show_last=1, offset=offset6)
67+
plotshape(y6, location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.blue, transp=80, show_last=1, offset=offset6)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@version=4
2+
// Copyright (c) 2019-present, Alex Orekhov (everget)
3+
// Heikin-Ashi Chart Identifier script may be freely distributed under the terms of the GPL-3.0 license.
4+
study("Heikin-Ashi Chart Identifier", overlay=true)
5+
6+
var int gapsCount = -1
7+
gapsCount := low[1] > high or high[1] < low ? gapsCount + 1 : gapsCount
8+
9+
var int matchedCandles = -1
10+
matchedCandles := open == (open[1] + close[1]) / 2 ? matchedCandles + 1 : matchedCandles
11+
12+
isHA = matchedCandles == bar_index - 1 and matchedCandles != -1 and gapsCount == -1
13+
14+
labelText = isHA ? "This is Heikin-Ashi Chart" : "This is not Heikin-Ashi Chart"
15+
stats = "\n------------------------------------" +
16+
"\nBar Index: " + tostring(int(bar_index)) +
17+
"\nMatched: " + tostring(matchedCandles)
18+
19+
labelColor = #1e90ff
20+
whiteColor = color.white
21+
22+
var label l = label.new(
23+
x=bar_index,
24+
y=na,
25+
text="",
26+
color=labelColor,
27+
textcolor=whiteColor,
28+
style=label.style_labeldown,
29+
size=size.normal
30+
)
31+
32+
label.set_text(l, labelText + stats)
33+
label.set_xy(l, bar_index, highest(high, 50))

‎research/kagi_chart_identifier.pine

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//@version=4
2+
// Copyright (c) 2019-present, Alex Orekhov (everget)
3+
// Kagi Chart Identifier script may be freely distributed under the terms of the GPL-3.0 license.
4+
study("Kagi Chart Identifier", overlay=true)
5+
6+
var ocCount = -1
7+
if open[1] == close or close[1] == open
8+
ocCount := ocCount + 1
9+
10+
var hCount = -1
11+
if open == high or close == high
12+
hCount := hCount + 1
13+
14+
var lCount = -1
15+
if open == low or close == low
16+
lCount := lCount + 1
17+
18+
isKagi = hCount == bar_index and lCount == bar_index and ocCount == bar_index - 1
19+
20+
labelText = isKagi ? "This is Kagi Chart" : "This is not Kagi Chart"
21+
stats = "\n------------------------------" +
22+
"\nBar Index: " + tostring(int(bar_index)) +
23+
"\nO==C Candles: " + tostring(ocCount) +
24+
"\nOC==H Candles: " + tostring(hCount) +
25+
"\nOC==L Candles: " + tostring(lCount)
26+
labelColor = #1e90ff
27+
whiteColor = color.white
28+
29+
var label kagiLabel = label.new(
30+
x=bar_index,
31+
y=na,
32+
text="",
33+
color=labelColor,
34+
textcolor=whiteColor,
35+
style=label.style_labeldown,
36+
size=size.normal
37+
)
38+
39+
label.set_text(kagiLabel, labelText + stats)
40+
label.set_xy(kagiLabel, bar_index, highest(close, 10))
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//@version=4
2+
// Copyright (c) 2019-present, Alex Orekhov (everget)
3+
// Litecoin Halving UTC Countdown script may be freely distributed under the terms of the GPL-3.0 license.
4+
study("Litecoin Halving UTC Countdown", overlay=true)
5+
6+
halvingDay = input(title="Halving Day", minval=1, maxval=31, defval=5)
7+
halvingHour = input(title="Halving Hour", minval=1, maxval=24, defval=11)
8+
halvingMinute = input(title="Halving Minute", minval=1, maxval=60, defval=55)
9+
10+
halvingStamp = timestamp('GMT', 2019, 8, halvingDay, halvingHour, halvingMinute)
11+
12+
secondsRaw = floor((halvingStamp - timenow) / 1000)
13+
minutesRaw = floor(secondsRaw / 60)
14+
hoursRaw = floor(minutesRaw / 60)
15+
16+
seconds = secondsRaw % 60
17+
minutes = minutesRaw % 60
18+
hours = hoursRaw % 24
19+
days = floor(hoursRaw / 24)
20+
21+
f_format(_val) =>
22+
(0 < _val and _val < 10 ? "0" : "") + tostring(_val, "##") + (_val == 0 ? "0" : "")
23+
24+
labelText = f_format(days) + "d " + f_format(hours) + ":" + f_format(minutes) + ":" + f_format(seconds)
25+
26+
var label l = label.new(
27+
x=bar_index,
28+
y=na,
29+
text="",
30+
textcolor=color.black,
31+
style=label.style_none,
32+
size=size.huge
33+
)
34+
35+
label.set_text(l, labelText)
36+
label.set_xy(l, bar_index, highest(100))

‎research/mean_absolute_deviation.pine

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@version=3
2+
// Copyright (c) 2018-present, Alex Orekhov (everget)
3+
// Mean Absolute Deviation script may be freely distributed under the GPL-3.0 license.
4+
study("Mean Absolute Deviation", shorttitle="MAD")
5+
6+
src = close
7+
len = 14
8+
9+
sma = sma(src, len)
10+
11+
median(src, length) =>
12+
percentile_nearest_rank(src, length, 50)
13+
14+
dev0 = dev(src, len)
15+
dev1 = src - sma
16+
dev2 = sum(abs(src - sma), len) / len
17+
dev3 = abs(src - sma) / len
18+
dev4 = (src - sma) / len
19+
dev5 = median(src - median(src, len), len)
20+
21+
sum = 0.0
22+
for i = 0 to len - 1
23+
sum := sum + abs(src[i] - sma)
24+
25+
dev6 = sum / len
26+
27+
plot(dev0, title="Built-in", color=purple)
28+
plot(dev1, title="1", color=olive)
29+
plot(dev2, title="2", color=teal)
30+
plot(dev3, title="3", color=green)
31+
plot(dev4, title="4", color=red)
32+
plot(dev5, title="5", color=blue)
33+
plot(dev6, title="6", color=orange)

0 commit comments

Comments
 (0)