-
Notifications
You must be signed in to change notification settings - Fork 3
/
Heikin Ashi Bar Color Change Strategy
30 lines (23 loc) · 1.25 KB
/
Heikin Ashi Bar Color Change Strategy
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
// Script originally made by Kozlot on [Tradingview](https://www.tradingview.com/v/6eC8Fznf/)
// Certain modification are made to upgrade script from pinescript v2 to v5
// Other modification are removing background, changing signal shape & it's color
//@version=5
strategy('Heikin Ashi Bar Color Change Strategy', overlay=true)
// Calculate Heikin Ashi Values
haopen = 0.0
haclose = (open + high + low + close) / 4
haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2
hahigh = math.max(high, math.max(haopen, haclose))
halow = math.min(low, math.min(haopen, haclose))
// HA colors
hacolor = haclose > haopen ? color.green : color.red
// Signals
turnGreen = haclose > haopen and haclose[1] <= haopen[1]
turnRed = haclose <= haopen and haclose[1] > haopen[1]
plotshape(turnGreen, style=shape.triangleup, location=location.belowbar, color=color.new(color.white, 0))
plotshape(turnRed, style=shape.triangledown, location=location.abovebar, color=color.new(color.yellow, 0))
// Alerts
strategy.entry('long', strategy.long, when=turnGreen)
strategy.entry('short', strategy.short, when=turnRed)
// below is a custom signal alert message to remind you for buy or sell
// {{ticker}} 4H Heikin Ashi signal to {{strategy.order.action}} @ {{close}} USDT.