[RS]DeMark Range Expansion Index V0

request for jangseohee
adapted from here: https://www.amibroker.com/newsletter/02-2000.html
Remove from Favorite Scripts Add to Favorite Scripts
study(title='[RS]DeMark Range Expansion Index V0', shorttitle='REI', overlay=false)
//  ||  Tom DeMark's Range Expansion Index 
//  ||  AFL Implementation by Tomasz Janeczko 
//  ||  Source:     https://www.amibroker.com/newsletter/02-2000.html
length = input(5)

HighMom = high - high[2]
LowMom = low - low[2]

Cond1 = high >= low[5] or high >= low[6] 
Cond2 = high[2] >= close[7] or high[2] >= close[8] 
Cond3 = low <= high[5] or low <= high[6] 
Cond4 = low[2] <= close[7] or low[2] <= close[8]

Cond = ( Cond1 or Cond2 ) and ( Cond3 or Cond4 )

Num = Cond ? HighMom + LowMom : 0
Den = abs(HighMom) + abs(LowMom)

TDREI = 100 * sum( Num, length )/sum( Den, length ) 

plot(title='REI', series=TDREI, color=black)
hline(title='OB', price=80, color=black)
hline(title='OS', price=-80, color=black)
It's lack some conditions. The original have 12 conditions. : )
I've gone crazy when I saw it.
Thank you Ricardo ^_^
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out