HeikinAshi_Point (HA-P)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © readCrypto

//@version=5
////////////////////////////////////////////////////////////
indicator(title='HeikinAshi_Point', shorttitle='HA-P', overlay=true)


/////////////////
// Heiken Ashi
srcClose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
srcOpen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)

///////////////////////////////
// RSI
A = ta.ema(srcClose - srcClose[1] > 0 ? srcClose - srcClose[1] : 0, 14)
B = ta.ema(srcClose - srcClose[1] < 0 ? math.abs(srcClose - srcClose[1]) : 0, 14)
RS = A / B
rsi10 = 100 - 100 / (1 + RS)

bgcolor(color=rsi10 >= 70 ? color.new(color.maroon, 95) : rsi10 <= 30 ? color.new(color.blue, 95) : color.new(#FFFFFF, 100), title='RSI HA')


HAS = srcClose
HAS := srcClose[2] > srcOpen[2] and srcClose[1] > srcOpen[1] and srcClose[0] < srcOpen[0] and rsi10[2] >= 70 ? srcOpen[2] : HAS[1]

plot(HAS, color=color.new(color.aqua, 50), linewidth=3, style=plot.style_line, title='HA-High')

HAB = srcOpen
HAB := srcClose[2] < srcOpen[2] and srcClose[1] < srcOpen[1] and srcClose[0] > srcOpen[0] and rsi10[2] <= 30 ? srcOpen[2] : HAB[1]

plot(HAB, color=color.new(color.orange, 50), linewidth=3, style=plot.style_line, title='HA-Low')  //, trackprice=true

p4 = plot(srcOpen, color=color.new(#FFFFFF, 100), title='H.A.')
p3 = plot(srcClose, color=color.new(#FFFFFF, 100), title='H.A.')

fill(p3, p4, color=srcClose > srcOpen ? color.new(#EF8E59, 50) : color.new(#59D3E3, 50), title='H.A.')
