[pshaiCmd] Hirashima Sugita Support & Resistance
stableDescription
R/S is a indicator invented by Hirashima Sugita. The purpose of R/S is to provide automatic Support and Resisstance lines.
Original author: alexgrover @ TradingView (https://www.tradingview.com/script/GCcUC752/)
Ported by: pshai
HaasScript
DefineCommand('HSSR', 'Hirashima Sugita Support & Resistance levels')
local length = DefineParameter(NumberType, 'length', 'Length of the calculation period.', true, 100, 'Input, Number')
local interval = DefineParameter(NumberType, 'interval', 'Interval of the calculation data.', false, 0, 'InputInterval, Number')
if length > 100 then
LogWarning('[HSSR] Limiting the length from '..length..' to 100. Use interval parameter for "longer" calculations periods (i.e. 100 length with 10min data overlayed on 1min data will be the same as 1000 length with 1min data).')
length = 100
end
if interval == 0 then
interval = CurrentInterval()
end
local c = ClosePrices(interval)
local ma = EMA(c, length)
local d = c - ma
local s = LINEARREG(d, length)
local x = ma + s
local d_ = c - x
local s_ = LINEARREG(d_, length)
local basis = (ma + s) + Change(s_)
local add = WMA(Abs(d), length)
local upper = basis + add
local lower = basis - add
local upper_ = upper + add
local lower_ = lower - add
DefineOutput(ListDynamicType, {upper_, upper, basis, lower, lower_}, 'Output values of HSSR', 'Plot')
DefineOutputIndex(1, ListNumberType, 'upper2', 'Highest upper band')
DefineOutputIndex(2, ListNumberType, 'upper1', 'High upper band')
DefineOutputIndex(3, ListNumberType, 'basis', 'Basis, aka middle-line')
DefineOutputIndex(4, ListNumberType, 'lower1', 'Low lower band')
DefineOutputIndex(5, ListNumberType, 'lower2', 'Lowest lower band')
0 Comments
Sign in to leave a comment.
No comments yet. Be the first!