RicardoSantos

[RS]Study of sequence ratio V0

counts N of sequences, N of bars, N of same open/close value, and N of sequences from 1 -> 10+ bar sequences in a direction up/down.
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
study(title='[RS]Study of sequence ratio V0')
up_bar = close > open
down_bar = close < open
doji = close == open

up_sequence = barssince(up_bar == 0)
down_sequence = barssince(down_bar == 0)

n_sequences = cum(change(up_sequence) < 0 or change(down_sequence) < 0)

f_sequence_check(_sequence_series, _sequence_length) => change(_sequence_series) < 0 and _sequence_series[1] == _sequence_length
f_sequence_check_above(_sequence_series, _sequence_length) => change(_sequence_series) < 0 and _sequence_series[1] >= _sequence_length

up_check_01 = cum(f_sequence_check(up_sequence, 1))
up_check_02 = cum(f_sequence_check(up_sequence, 2))
up_check_03 = cum(f_sequence_check(up_sequence, 3))
up_check_04 = cum(f_sequence_check(up_sequence, 4))
up_check_05 = cum(f_sequence_check(up_sequence, 5))
up_check_06 = cum(f_sequence_check(up_sequence, 6))
up_check_07 = cum(f_sequence_check(up_sequence, 7))
up_check_08 = cum(f_sequence_check(up_sequence, 8))
up_check_09 = cum(f_sequence_check(up_sequence, 9))
up_check_10 = cum(f_sequence_check_above(up_sequence, 10))

down_check_01 = cum(f_sequence_check(down_sequence, 1))
down_check_02 = cum(f_sequence_check(down_sequence, 2))
down_check_03 = cum(f_sequence_check(down_sequence, 3))
down_check_04 = cum(f_sequence_check(down_sequence, 4))
down_check_05 = cum(f_sequence_check(down_sequence, 5))
down_check_06 = cum(f_sequence_check(down_sequence, 6))
down_check_07 = cum(f_sequence_check(down_sequence, 7))
down_check_08 = cum(f_sequence_check(down_sequence, 8))
down_check_09 = cum(f_sequence_check(down_sequence, 9))
down_check_10 = cum(f_sequence_check_above(down_sequence, 10))

plot(up_check_01, title='UP-01', color=color(lime, 0))
plot(up_check_02, title='UP-02', color=color(lime, 0))
plot(up_check_03, title='UP-03', color=color(lime, 0))
plot(up_check_04, title='UP-04', color=color(lime, 0))
plot(up_check_05, title='UP-05', color=color(lime, 0))
plot(up_check_06, title='UP-06', color=color(lime, 0))
plot(up_check_07, title='UP-07', color=color(lime, 0))
plot(up_check_08, title='UP-08', color=color(lime, 0))
plot(up_check_09, title='UP-09', color=color(lime, 0))
plot(up_check_10, title='UP-10', color=color(lime, 0))

plot(down_check_01, title='DOWN-01', color=color(red, 0))
plot(down_check_02, title='DOWN-02', color=color(red, 0))
plot(down_check_03, title='DOWN-03', color=color(red, 0))
plot(down_check_04, title='DOWN-04', color=color(red, 0))
plot(down_check_05, title='DOWN-05', color=color(red, 0))
plot(down_check_06, title='DOWN-06', color=color(red, 0))
plot(down_check_07, title='DOWN-07', color=color(red, 0))
plot(down_check_08, title='DOWN-08', color=color(red, 0))
plot(down_check_09, title='DOWN-09', color=color(red, 0))
plot(down_check_10, title='DOWN-10', color=color(red, 0))

plot(n, title='N', color=color(black, 0))
plot(n_sequences, title='NS', color=color(black, 0))
plot(cum(doji), title='D', color=color(black, 0))

hline(0)
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
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