Trending True Range (TTR) SE Version

stable
By ajd1107 in Momentum Published October 2022 👁 1,274 views 💬 0 comments

Description

A conversion to SE of bunka 's VE version - original by alexgrover(TV) Original Here - https://www.tradingview.com/script/8e1f2wFW-Trending-True-Range/
HaasScript
-- A conversion of bunka's TTR to SE
-- Original by alexgrover - https://www.tradingview.com/script/8e1f2wFW-Trending-True-Range/

DefineCommand('TTR', 'Trending True Range by Alex Grover - Converted to Haas VE by Bunka - SE by Fogg')

local chartIndex = DefineParameter(NumberType, 'chartIndex', 'Index to plot TTR', false, 99, 'Number')
local ttrl = DefineParameter(NumberType, 'TTR Length', 'Length of Close Prices to build TTR', false, 14, 'TTR Interval')
local ttri = DefineParameter(NumberType, 'interval', '', false, CurrentInterval(), 'Number, InputInterval')

-----
--Prices
-----

local o = OpenPrices(ttri)
local h = HighPrices(ttri)
local l = LowPrices(ttri)
local c = ClosePrices(ttri)


----- variables
local er = Div(Abs(MOM(c, ttrl)), ArraySum(Grab(Abs(Change(c)), 0, ttrl)))

----- indicators
local ind1 = WiMA(er, ttrl)
local ind2 = TRANGE(h, l, c)

----- TTR Calculation
local ttr = Max(Grab(WiMA(Mul(Sign(Sub(er, ind1)), ind2), ttrl), 0, ttrl), 0)

Plot(chartIndex, 'TTR', ttr, Cyan)

DefineOutput(ListNumberType, ttr, 'TTR')

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!