RicardoSantos

[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
//@version=2
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)
Thank you Ricardo ^_^
Reply
It's lack some conditions. The original have 12 conditions. : )
I've gone crazy when I saw it.
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out