-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKairiKotegawaTracker.pinescript
196 lines (169 loc) · 6.73 KB
/
KairiKotegawaTracker.pinescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// © 2025 David C Cavalcante
// Version: 1.0.3
// @version=6
// =================================
// PLEASE SUPPORT THE TEAM
// =================================
//
// If this project has been helpful, consider making a donation:
// USDT (TRC-20): `TP6zpvjt2ZNGfWKPevfp65ZrcbKMWSQXDi`
//
// https://github.com/Takk8IS/KotegawaPumpTracker
// https://www.linkedin.com/in/hellodav
//@variable = "small"
//@description="A profitable adaptation of Takashi Kotegawa's trading principles for crypto markets, focusing on finding opportunities in oversold conditions with consistent risk management."
// =================================
// KOTEGAWA INDICATOR SETTINGS
// =================================
//
// Adaptation of legendary Japanese trader Takashi Kotegawa's (BNF) method
// who turned $13,600 into $153 million in 8 years.
//
// ENTRY SIGNALS:
// - Buy: KAIRI crosses below support line (blue) and RSI < 30
// - Sell: KAIRI crosses above resistance line (pink) and RSI > 65
//
// RISK MANAGEMENT:
// - Stop Loss: 1x ATR of current value
// - Take Profit: 2.5x ATR of current value
//
// RECOMMENDED TIMEFRAMES:
// - Short term: 1m, 3m, 5m (limit: 35.0)
// - Medium term: 15m, 1h (limit: 30.0)
// - Long term: 4h+ (limit: 25.0)
//
// =================================
// The "Kairi Kotegawa Tracker" is a sophisticated strategy that combines multiple technical indicators to identify buying and selling opportunities, featuring a standard 25-day Kotegawa period, multiple moving average options and dynamic adjustments optimized for crypto with an adaptive volatility system.
strategy("Kairi Kotegawa Tracker", "KAIRIGAWA", overlay=false, max_lines_count=500, max_boxes_count=500, default_qty_type=strategy.percent_of_equity, default_qty_value=20, initial_capital=5)
// =================================
// Advanced settings inspired by Kotegawa strategy
// =================================
length = input.int(title='Kotegawa Period', minval=2, defval=25, tooltip="Standard 25-day period used by Kotegawa")
maInput = input.string(title='Moving Average Type', defval='EMA', options=['SMA', 'EMA', 'WMA', 'TMA', 'VIDYA', 'WWMA', 'ZLEMA', 'TSF', 'HMA', 'VWMA'])
src = input(title='Price Source', defval=close)
// =================================
// Dynamic limits optimized for crypto
// =================================
tf = timeframe.period
dynamicUpper = if timeframe.isintraday and (tf == '1' or tf == '3' or tf == '5')
35.0
else if timeframe.isintraday and (tf == '15' or tf == '60')
30.0
else
25.0
dynamicLower = -1.0 * dynamicUpper
// =================================
// Adaptive volatility system
// =================================
atrPeriod = 14
atrValue = ta.atr(atrPeriod)
atrPercentage = (atrValue / src) * 100.0
// =================================
// Volatility adjustment based on Kotegawa method
// =================================
volatilityFactor = math.min(atrPercentage / 4.0, 1.75)
ust = dynamicUpper * volatilityFactor
alt = dynamicLower * volatilityFactor
// =================================
// VIDYA optimized for high volatility
// =================================
var float VIDYA = 0.0
valpha = 2.0 / (length + 1)
vud1 = src > src[1] ? src - src[1] : 0.0
vdd1 = src < src[1] ? src[1] - src : 0.0
vUD = math.sum(vud1, 9)
vDD = math.sum(vdd1, 9)
vCMO = (vUD - vDD) / (vUD + vDD)
VIDYA := valpha * math.abs(vCMO) * src + (1 - valpha * math.abs(vCMO)) * nz(VIDYA[1])
// =================================
// WWMA with momentum adjustment
// =================================
var float WWMA = 0.0
wwalpha = 1.0 / length
WWMA := wwalpha * src + (1 - wwalpha) * nz(WWMA[1])
// =================================
// ZLEMA for fast trend detection
// =================================
zxLag = length / 2 == math.round(length / 2) ? length / 2 : (length - 1) / 2
zxEMAData = src + src - src[int(zxLag)]
ZLEMA = ta.ema(zxEMAData, length)
// =================================
// TSF for target projection
// =================================
lrc = ta.linreg(src, length, 0)
lrc1 = ta.linreg(src, length, 1)
lrs = lrc - lrc1
TSF = ta.linreg(src, length, 0) + lrs
// =================================
// HMA for lag reduction
// =================================
HMA = ta.wma(2 * ta.wma(src, length / 2) - ta.wma(src, length), math.round(math.sqrt(length)))
// =================================
// VWMA with volume confirmation
// =================================
VWMA = ta.vwma(src, length)
// =================================
// Optimized MA selector
// =================================
getMA(float src, int length) =>
float ma = switch maInput
'SMA' => ta.sma(src, length)
'EMA' => ta.ema(src, length)
'WMA' => ta.wma(src, length)
'TMA' => ta.sma(ta.sma(src, math.ceil(length / 2)), math.floor(length / 2) + 1)
'VIDYA' => VIDYA
'WWMA' => WWMA
'ZLEMA' => ZLEMA
'TSF' => TSF
'HMA' => HMA
'VWMA' => VWMA
=> ta.ema(src, length)
ALL = getMA(src, length)
kairi = (src - ALL) * 100.0 / ALL
// =================================
// Color scheme
// =================================
TechNoirBlue = #00c3ff
TechNoirPink = #ff0081
TechNoirPurple = #9100ff
TechNoirGreen = #00ffb3
TechNoirOrange = #ff5900
TechNoirYellow = #ffe600
TechNoirTeal = #00d9d2
TechNoirRed = #ff1130
TechNoirMagenta = #ff009d
TechNoirAqua = #00eaff
TechNoirLime = #9dff00
TechNoirWhite = #dcf0ff
TechNoirGray = #595b6e
// =================================
// Dynamic signal visualization
// =================================
kairiColor = kairi > ust ? TechNoirPink : kairi < alt ? TechNoirBlue : TechNoirPurple
plot(kairi, color=kairiColor, linewidth=2, title='KAIRI')
plot(0, color=TechNoirPurple, title='Base Line', style=plot.style_circles)
plot(ust, color=TechNoirPink, title='Resistance', style=plot.style_circles)
plot(alt, color=TechNoirBlue, title='Support', style=plot.style_circles)
// =================================
// Calculate RSI once for consistency
// =================================
rsiValue = ta.rsi(src, 14)
// =================================
// Refined entry signals
// =================================
longCondition = kairi < alt and rsiValue < 30
shortCondition = kairi > ust and rsiValue > 65
// =================================
// Precise execution
// =================================
if (longCondition)
strategy.entry("Buy", strategy.long)
if (shortCondition)
strategy.entry("Sell", strategy.short)
// =================================
// Kotegawa risk management
// =================================
stopLoss = atrValue * 0.75
takeProfit = atrValue * 2.0
strategy.exit("Buy Exit", from_entry="Buy", stop=strategy.position_avg_price - stopLoss, limit=strategy.position_avg_price + takeProfit)
strategy.exit("Sell Exit", from_entry="Sell", stop=strategy.position_avg_price + stopLoss, limit=strategy.position_avg_price - takeProfit)