BETA 1 + LAOL
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «indicator bank manipulation for tradingview.pine» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
Этот индикатор для TradingView на языке Pine Script v6 отображает на графике ценовые зоны и уровни, рассчитанные по данным нескольких таймфреймов. Он получает данные с 25 различных таймфреймов (от 1 минуты до 100 минут) через request.security и анализирует их для формирования визуальных прямоугольников (боксов) и линий. Индикатор предназначен для визуального анализа рыночных структур и не является торговым советником или стратегией.
Индикатор отображает боксы, которые могут находиться в состояниях FORMING, ESTABLISHED, EST_RETEST, RESPECTED и других. Боксы создаются на основе комбинаций свечных паттернов, определённых в коде. Также отображаются линии LAOL (Level At Or Above/Below) и боксы HCS. Все элементы визуализируются с помощью графических примитивов: box, line, label.
Индикатор поддерживает создание условий для оповещений TradingView через alertcondition и alert. Оповещения срабатывают при определённых событиях, например, при касании уровня LAOL внутри бокса. Пользователь может включить или отключить обработку старших таймфреймов с помощью настройки SOFT START.
Важно: индикатор не выполняет автоматическую торговлю, не рассчитывает прибыль и не содержит торговых правил для входа или выхода. Все отображаемые элементы являются результатом анализа ценовых данных и предназначены только для визуализации.
Настройки программы
| Настройка | Описание |
|---|---|
| soft_start | Логический переключатель. При включении активируется обработка дополнительных таймфреймов (от 30 до 100 минут), которые относятся к категории INTRA. При выключении эти таймфреймы не обрабатываются. |
Поиск по коду файла
indicator("BETA 1 + LAOL", overlay=true, max_lines_count=500, max_bars_back=500, max_labels_count=500, max_boxes_count=500)
soft_start = input.bool(false, "SOFT START", group="||--- MUST BE ENABLED ---||")
show_hcs_boxes = true
var color rr_sl_color = color.new(color.red, 70)
var color rr_tp_color = color.new(color.green, 70)
const int TF_COUNT = 25
var string[] TFS = array.from("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","20","30","35","40","45","50","55","60","90","100")
const int ENTRY_MIN_IDX = 0
const int ENTRY_MAX_IDX = 4
const int SCALP_MIN_IDX = 5
const int SCALP_MAX_IDX = 15
const int INTRA_MIN_IDX = 16
const int INTRA_MAX_IDX = 24
var color entry_box_color = color.new(color.blue, 95)
var color entry_border_color = color.new(color.blue, 50)
var color scalp_box_color = color.new(color.green, 90)
var color scalp_border_color = color.new(color.green, 50)
var color intra_box_color = color.new(color.red, 95)
var color intra_border_color = color.new(color.red, 50)
const int unretested_border_transparency = 100
const int TP_MULTIPLIER = 8
const int SETUP_LOOKBACK = 5
const float PIP_TARGET = 40.0
const int LAOL_DELETE_DELAY = 2
pip_value = syminfo.mintick * 10
type seq_state
int step = 0
float level = na
float body = na
int start_time = na
type tracked_box
string direction = na
string state = "FORMING"
float top_val = na
float bottom_val = na
float original_top = na
float original_bottom = na
int creation_time = na
int protection_end_time = na
string pattern_text = na
string timeframe = na
box box_obj = na
bool has_est_retest = false
string retest_type = "FRESH"
bool protection_active = true
int hcs_count = 0
string base_pattern = na
color box_color = na
color border_color = na
bool has_been_retested = false
bool is_intra = false
float est_wick_high = na
float est_wick_low = na
bool completed_est_retest = false
bool is_em_forming = false
bool just_established = false
type laol_line_data
line line_obj = na
label label_obj = na
float level = na
string tf_labels = ""
int creation_bar = na
bool is_bear = false
bool is_broken = false
int break_bar = na
int tf_count = 1
bool has_entry = false
bool has_scalp = false
bool has_intra = false
type last_valid_info
string pattern_text = "None"
string original_text = "None"
float level = na
int est_time = 0
string direction = ""
bool is_broken = false
type hcs_box_data
box box_obj = na
float top_val = na
float bottom_val = na
int creation_bar = na
string tf_label = na
string direction = ""
bool is_broken = false
type rr_box_set
box sl_box = na
box tp_box = na
line pip_line = na
string direction = ""
float sl_level = na
int creation_bar = na
var hcs_box_data[] hcs_boxes_bear = array.new<hcs_box_data>()
var hcs_box_data[] hcs_boxes_bull = array.new<hcs_box_data>()
var color hcs_bear_bg = color.new(color.orange, 80)
var color hcs_bear_border = color.new(color.orange, 30)
var color hcs_bull_bg = color.new(#2196F3, 80)
var color hcs_bull_border = color.new(#2196F3, 30)
var bool[] arr_bear_hcs_broken = array.new_bool(TF_COUNT, false)
var bool[] arr_bull_hcs_broken = array.new_bool(TF_COUNT, false)
var bool[] arr_bear_hcs_retesting = array.new_bool(TF_COUNT, false)
var bool[] arr_bull_hcs_retesting = array.new_bool(TF_COUNT, false)
var laol_line_data[] bear_laol_lines = array.new<laol_line_data>()
var laol_line_data[] bull_laol_lines = array.new<laol_line_data>()
var laol_line_data[] bear_intra_laol_lines = array.new<laol_line_data>()
var laol_line_data[] bull_intra_laol_lines = array.new<laol_line_data>()
var laol_line_data[] bear_scalp_laol_lines = array.new<laol_line_data>()
var laol_line_data[] bull_scalp_laol_lines = array.new<laol_line_data>()
var int last_bear_scalp_laol_break_time = 0
var int last_bull_scalp_laol_break_time = 0
var string last_bear_scalp_laol_tf = ""
var string last_bull_scalp_laol_tf = ""
var int final_entry_bear_setup_bar = na
var int final_entry_bull_setup_bar = na
var string final_entry_bear_pattern = ""
var string final_entry_bull_pattern = ""
var bool[] arr_laol_candle_bear = array.new_bool(TF_COUNT, false)
var bool[] arr_laol_candle_bull = array.new_bool(TF_COUNT, false)
var bool[] arr_bear_retesting = array.new_bool(TF_COUNT, false)
var bool[] arr_bull_retesting = array.new_bool(TF_COUNT, false)
var bool[] arr_bear_est_retest = array.new_bool(TF_COUNT, false)
var bool[] arr_bull_est_retest = array.new_bool(TF_COUNT, false)
var bool[] arr_bear_est_retest_VALID = array.new_bool(TF_COUNT, false)
var bool[] arr_bull_est_retest_VALID = array.new_bool(TF_COUNT, false)
var bool[] arr_bear_est_retest_VALID_prev = array.new_bool(TF_COUNT, false)
var bool[] arr_bull_est_retest_VALID_prev = array.new_bool(TF_COUNT, false)
var string[] arr_bear_retest_pattern = array.new_string(TF_COUNT, "")
var string[] arr_bull_retest_pattern = array.new_string(TF_COUNT, "")
var float[] arr_bear_retest_level = array.new_float(TF_COUNT, na)
var float[] arr_bull_retest_level = array.new_float(TF_COUNT, na)
var string[] TF_LABELS = array.new_string(TF_COUNT, "")
var string[] TF_CATEGORIES = array.new_string(TF_COUNT, "")
var bool[] arr_fu_bear = array.new_bool(TF_COUNT, false)
var bool[] arr_fu_bull = array.new_bool(TF_COUNT, false)
var bool[] arr_sn_bear = array.new_bool(TF_COUNT, false)
var bool[] arr_sn_bull = array.new_bool(TF_COUNT, false)
var bool[] arr_first_bear = array.new_bool(TF_COUNT, false)
var bool[] arr_first_bull = array.new_bool(TF_COUNT, false)
var bool[] arr_second_bear = array.new_bool(TF_COUNT, false)
var bool[] arr_second_bull = array.new_bool(TF_COUNT, false)
var bool[] arr_third_bear = array.new_bool(TF_COUNT, false)
var bool[] arr_third_bull = array.new_bool(TF_COUNT, false)
var bool[] arr_laol_bear = array.new_bool(TF_COUNT, false)
var bool[] arr_laol_bull = array.new_bool(TF_COUNT, false)
var bool[] arr_laol_first_bear = array.new_bool(TF_COUNT, false)
var bool[] arr_laol_first_bull = array.new_bool(TF_COUNT, false)
var float[] arr_tf_h = array.new_float(TF_COUNT, na)
var float[] arr_tf_l = array.new_float(TF_COUNT, na)
var float[] arr_tf_bt = array.new_float(TF_COUNT, na)
var float[] arr_tf_bb = array.new_float(TF_COUNT, na)
var int[] arr_tf_t = array.new_int(TF_COUNT, na)
var bool[] arr_tf_conf = array.new_bool(TF_COUNT, false)
var seq_state[] arr_bear_seq = array.new<seq_state>(TF_COUNT)
var seq_state[] arr_bull_seq = array.new<seq_state>(TF_COUNT)
var bool[] arr_bear_hcs = array.new_bool(TF_COUNT, false)
var bool[] arr_bull_hcs = array.new_bool(TF_COUNT, false)
var bool[] arr_bear_hcs_forming = array.new_bool(TF_COUNT, false)
var bool[] arr_bull_hcs_forming = array.new_bool(TF_COUNT, false)
var int[] arr_last_bear_hcs_time = array.new_int(TF_COUNT, 0)
var int[] arr_last_bull_hcs_time = array.new_int(TF_COUNT, 0)
var int[] arr_bear_third_step = array.new_int(TF_COUNT, 0)
var float[] arr_bear_third_ref_h = array.new_float(TF_COUNT, na)
var float[] arr_bear_third_ref_l = array.new_float(TF_COUNT, na)
var int[] arr_bear_third_ref_time = array.new_int(TF_COUNT, na)
var int[] arr_bull_third_step = array.new_int(TF_COUNT, 0)
var float[] arr_bull_third_ref_h = array.new_float(TF_COUNT, na)
var float[] arr_bull_third_ref_l = array.new_float(TF_COUNT, na)
var int[] arr_bull_third_ref_time = array.new_int(TF_COUNT, na)
var int[] arr_bear_laol_step = array.new_int(TF_COUNT, 0)
var float[] arr_bear_laol_ref_h = array.new_float(TF_COUNT, na)
var float[] arr_bear_laol_ref_l = array.new_float(TF_COUNT, na)
var int[] arr_bear_laol_ref_time = array.new_int(TF_COUNT, na)
var int[] arr_bull_laol_step = array.new_int(TF_COUNT, 0)
var float[] arr_bull_laol_ref_h = array.new_float(TF_COUNT, na)
var float[] arr_bull_laol_ref_l = array.new_float(TF_COUNT, na)
var int[] arr_bull_laol_ref_time = array.new_int(TF_COUNT, na)
var tracked_box[] tf1_boxes = array.new<tracked_box>()
var tracked_box[] tf2_boxes = array.new<tracked_box>()
var tracked_box[] tf3_boxes = array.new<tracked_box>()
var tracked_box[] tf4_boxes = array.new<tracked_box>()
var tracked_box[] tf5_boxes = array.new<tracked_box>()
var tracked_box[] tf6_boxes = array.new<tracked_box>()
var tracked_box[] tf7_boxes = array.new<tracked_box>()
var tracked_box[] tf8_boxes = array.new<tracked_box>()
var tracked_box[] tf9_boxes = array.new<tracked_box>()
var tracked_box[] tf10_boxes = array.new<tracked_box>()
var tracked_box[] tf11_boxes = array.new<tracked_box>()
var tracked_box[] tf12_boxes = array.new<tracked_box>()
var tracked_box[] tf13_boxes = array.new<tracked_box>()
var tracked_box[] tf14_boxes = array.new<tracked_box>()
var tracked_box[] tf15_boxes = array.new<tracked_box>()
var tracked_box[] tf16_boxes = array.new<tracked_box>()
var tracked_box[] tf17_boxes = array.new<tracked_box>()
var tracked_box[] tf18_boxes = array.new<tracked_box>()
var tracked_box[] tf19_boxes = array.new<tracked_box>()
var tracked_box[] tf20_boxes = array.new<tracked_box>()
var tracked_box[] tf21_boxes = array.new<tracked_box>()
var tracked_box[] tf22_boxes = array.new<tracked_box>()
var tracked_box[] tf23_boxes = array.new<tracked_box>()
var tracked_box[] tf24_boxes = array.new<tracked_box>()
var tracked_box[] tf25_boxes = array.new<tracked_box>()
var string[] entry_forming = array.new_string()
var string[] entry_retesting = array.new_string()
var string[] scalp_forming = array.new_string()
var string[] scalp_retesting = array.new_string()
var string[] intra_forming = array.new_string()
var string[] intra_retesting = array.new_string()
var string[] intra_negation = array.new_string()
var int last_bear_forming_bar = -1
var int last_bear_confirmed_bar = -1
var int last_bull_forming_bar = -1
var int last_bull_confirmed_bar = -1
var bool intra_bear_negating = false
var bool intra_bull_negating = false
var string intra_bear_negating_pattern = ""
var string intra_bull_negating_pattern = ""
var int last_bear_laol_break_time = 0
var int last_bull_laol_break_time = 0
var string last_bear_laol_tf = ""
var string last_bull_laol_tf = ""
var int last_bear_intra_laol_break_time = 0
var int last_bull_intra_laol_break_time = 0
var string last_bear_intra_laol_tf = ""
var string last_bull_intra_laol_tf = ""
var last_valid_info entry_bear_lv = last_valid_info.new()
var last_valid_info entry_bull_lv = last_valid_info.new()
var last_valid_info scalp_bear_lv = last_valid_info.new()
var last_valid_info scalp_bull_lv = last_valid_info.new()
var last_valid_info intra_bear_lv = last_valid_info.new()
var last_valid_info intra_bull_lv = last_valid_info.new()
var box bear_forming_rr_sl = na
var box bear_forming_rr_tp = na
var line bear_forming_rr_pip = na
var int bear_forming_rr_bar = na
var box bull_forming_rr_sl = na
var box bull_forming_rr_tp = na
var line bull_forming_rr_pip = na
var int bull_forming_rr_bar = na
var rr_box_set[] rr_boxes_bear = array.new<rr_box_set>()
var rr_box_set[] rr_boxes_bull = array.new<rr_box_set>()
var line[] _xlaol_lines = array.new<line>()
var label[] _xlaol_labels = array.new<label>()
var float[] _xlaol_levels = array.new<float>()
var bool[] _xlaol_bear = array.new<bool>()
var string[] _xlaol_cat = array.new<string>()
var int[] _xlaol_off = array.new<int>()
show_intra_est_retest = true
show_intra_em_forming = true
show_intra_lv_aligned = false
show_intra_negation = true
show_final_entry = true
show_final_s1_s4 = true
show_final_intra_est = true
show_final_intra_em = true
show_final_intra_lv = false
show_final_intra_negation = true
final_entry_multi_laol = false
f_tf_to_minutes(string tf_str) => timeframe.in_seconds(tf_str) / 60
f_format_tf_label(string tf_str) =>
mins = f_tf_to_minutes(tf_str)
mins >= 60 and mins % 60 == 0 ? str.tostring(mins / 60) + "H" : str.tostring(mins) + "m"
f_is_entry(string tf_str) =>
mins = f_tf_to_minutes(tf_str)
mins >= 1 and mins <= 5
f_get_full_category(string tf_str) =>
tf_minutes = f_tf_to_minutes(tf_str)
if tf_minutes >= 1 and tf_minutes <= 5
"ENTRY"
else if tf_minutes >= 6 and tf_minutes <= 20
"SCALP"
else if tf_minutes >= 30 and tf_minutes <= 120
"INTRA"
else
"NONE"
f_pattern_str(bool is_bear, bool third, bool first, bool laol, bool sn, bool sn_dbl, bool fu, bool tbe, bool hcs, bool hcs_forming) =>
string result = ""
if third
result := "X3 Third"
if first
result := result == "" ? "X3 First" : result + " + X3 First"
if laol
result := result == "" ? "LAOL Neg" : result + " + LAOL Neg"
if sn
sn_txt = sn_dbl ? "SN [EM]" : "SN"
result := result == "" ? sn_txt : result + " + " + sn_txt
if fu
fu_txt = tbe ? "FU [TBE✓]" : "FU"
result := result == "" ? fu_txt : result + " + " + fu_txt
if hcs
result := result == "" ? "[HCS ✓]" : result + " + [HCS ✓]"
else if hcs_forming
result := result == "" ? "[HCS]" : result + " + [HCS]"
result != "" ? (is_bear ? "Bear " : "Bull ") + result : ""
f_get_boxes(int i) =>
switch i
0 => tf1_boxes
1 => tf2_boxes
2 => tf3_boxes
3 => tf4_boxes
4 => tf5_boxes
5 => tf6_boxes
6 => tf7_boxes
7 => tf8_boxes
8 => tf9_boxes
9 => tf10_boxes
10 => tf11_boxes
11 => tf12_boxes
12 => tf13_boxes
13 => tf14_boxes
14 => tf15_boxes
15 => tf16_boxes
16 => tf17_boxes
17 => tf18_boxes
18 => tf19_boxes
19 => tf20_boxes
20 => tf21_boxes
21 => tf22_boxes
22 => tf23_boxes
23 => tf24_boxes
24 => tf25_boxes
=> tf1_boxes
f_is_fu_pattern(string pattern) =>
if pattern == ""
false
else
has_fu = str.contains(pattern, "FU")
has_sn = str.contains(pattern, "SN")
has_em_modifier = str.contains(pattern, "HCS") or str.contains(pattern, "Third") or str.contains(pattern, "First") or str.contains(pattern, "LAOL") or str.contains(pattern, "TBE")
(has_fu or has_sn) and not has_em_modifier
f_is_em_pattern(string pattern) =>
if pattern == ""
false
else
str.contains(pattern, "HCS") or str.contains(pattern, "Third") or str.contains(pattern, "First") or str.contains(pattern, "LAOL") or str.contains(pattern, "TBE") or str.contains(pattern, "[EM]")
f_has_both_wicks(float o, float h, float l, float c) =>
math.max(o, c) < h and math.min(o, c) > l
f_is_inside_bar(float p_h, float p_l, float p_h1, float p_l1) =>
p_h < p_h1 and p_l > p_l1
f_bullish_ib_confirmation(float p_o1, float p_h1, float p_l1, float p_c1) =>
(math.min(p_o1, p_c1) - p_l1) > (p_h1 - math.max(p_o1, p_c1))
f_bearish_ib_confirmation(float p_o1, float p_h1, float p_l1, float p_c1) =>
(p_h1 - math.max(p_o1, p_c1)) > (math.min(p_o1, p_c1) - p_l1)
f_update_seq(seq_state seq, bool is_fu, bool is_x3, bool counter_fu, bool counter_x3, float level, float body, string tf_str, bool confirmed, bool is_bear, float p_h, float p_l) =>
if not confirmed
[seq.step, false]
else
tf_seconds = timeframe.in_seconds(tf_str)
candles_since = not na(seq.start_time) ? math.round((time - seq.start_time) / (tf_seconds * 1000)) : 0
if seq.step > 0 and seq.step < 5 and candles_since > 5
seq.step := 0
seq.level := na
seq.body := na
seq.start_time := na
is_valid = false
if seq.step == 5
seq.step := 0
seq.level := na
seq.body := na
seq.start_time := na
else if seq.step == 4
broke_level = is_bear ? (p_h > seq.level) : (p_l < seq.level)
if broke_level
seq.step := 0
seq.level := na
seq.body := na
seq.start_time := na
else if is_fu
seq.step := 5
is_valid := true
else if seq.step == 3
broke_level = is_bear ? (p_h > seq.level) : (p_l < seq.level)
in_zone = is_bear ? (p_h > seq.body and p_h < seq.level) : (p_l < seq.body and p_l > seq.level)
if broke_level
seq.step := 0
seq.level := na
seq.body := na
seq.start_time := na
else if in_zone
seq.step := 4
else if seq.step == 2
broke_level = is_bear ? (p_h > seq.level) : (p_l < seq.level)
if broke_level
seq.step := 0
seq.level := na
seq.body := na
seq.start_time := na
else if counter_fu or counter_x3
seq.step := 3
else if seq.step == 1
broke_level = is_bear ? (p_h > seq.level) : (p_l < seq.level)
in_zone = is_bear ? (p_h >= seq.body and p_h <= seq.level) : (p_l <= seq.body and p_l >= seq.level)
if broke_level
seq.step := 0
seq.level := na
seq.body := na
seq.start_time := na
else if in_zone
seq.step := 2
else
seq.step := 0
seq.level := na
seq.body := na
seq.start_time := na
if (is_fu or is_x3) and seq.step == 0
seq.step := 1
seq.level := level
seq.body := body
seq.start_time := time
[seq.step, is_valid]
f_time_ago(int past_time) =>
if past_time == 0
""
else
elapsed_ms = time - past_time
elapsed_min = math.floor(elapsed_ms / 60000)
if elapsed_min < 1
" (<1m ago)"
else if elapsed_min < 60
" (" + str.tostring(elapsed_min) + "m ago)"
else if elapsed_min < 1440
hours = math.floor(elapsed_min / 60)
mins = elapsed_min % 60
" (" + str.tostring(hours) + "h" + (mins > 0 ? str.tostring(mins) + "m" : "") + " ago)"
else
days = math.floor(elapsed_min / 1440)
" (" + str.tostring(days) + "d ago)"
f_push_unique(string[] arr, string txt) =>
bool found = false
for existing in arr
if existing == txt
found := true
break
if not found
array.push(arr, txt)
0
f_check_break(last_valid_info lv, float h, float l) =>
if lv.original_text != "None" and not na(lv.level)
if lv.direction == "bear" and h > lv.level
lv.pattern_text := "BROKEN (was " + lv.original_text + ")"
lv.is_broken := true
if lv.direction == "bull" and l < lv.level
lv.pattern_text := "BROKEN (was " + lv.original_text + ")"
lv.is_broken := true
0
f_resolve_last_valid(last_valid_info bear_lv, last_valid_info bull_lv) =>
string lv_text = "None"
string lv_dir = ""
string lv_orig_dir = ""
bool lv_broken = false
if bear_lv.est_time > 0 or bull_lv.est_time > 0
if bear_lv.est_time > bull_lv.est_time
lv_text := bear_lv.pattern_text + f_time_ago(bear_lv.est_time)
lv_dir := bear_lv.is_broken ? "bull" : "bear"
lv_orig_dir := "bear"
lv_broken := bear_lv.is_broken
else
lv_text := bull_lv.pattern_text + f_time_ago(bull_lv.est_time)
lv_dir := bull_lv.is_broken ? "bear" : "bull"
lv_orig_dir := "bull"
lv_broken := bull_lv.is_broken
[lv_text, lv_dir, lv_orig_dir, lv_broken]
f_find_next_extreme_candle(string direction, float original_sl, int lookback = 500) =>
float extreme_level = na
if direction == "bear"
for i = 1 to lookback
if high[i] > original_sl
extreme_level := high[i]
break
else
for i = 1 to lookback
if low[i] < original_sl
extreme_level := low[i]
break
extreme_level
if barstate.isfirst
for i = 0 to TF_COUNT - 1
tf_str = array.get(TFS, i)
array.set(TF_LABELS, i, f_format_tf_label(tf_str))
array.set(TF_CATEGORIES, i, f_get_full_category(tf_str))
array.set(arr_bear_seq, i, seq_state.new())
array.set(arr_bull_seq, i, seq_state.new())
f_get_tf_data(string tf) =>
request.security(syminfo.tickerid, tf, [open[2], high[2], low[2], close[2], open[1], high[1], low[1], close[1], open, high, low, close, time, barstate.isconfirmed], lookahead=barmerge.lookahead_off)
[tf1_o2, tf1_h2, tf1_l2, tf1_c2, tf1_o1, tf1_h1, tf1_l1, tf1_c1, tf1_o, tf1_h, tf1_l, tf1_c, tf1_t, tf1_conf] = f_get_tf_data(array.get(TFS, 0))
[tf2_o2, tf2_h2, tf2_l2, tf2_c2, tf2_o1, tf2_h1, tf2_l1, tf2_c1, tf2_o, tf2_h, tf2_l, tf2_c, tf2_t, tf2_conf] = f_get_tf_data(array.get(TFS, 1))
[tf3_o2, tf3_h2, tf3_l2, tf3_c2, tf3_o1, tf3_h1, tf3_l1, tf3_c1, tf3_o, tf3_h, tf3_l, tf3_c, tf3_t, tf3_conf] = f_get_tf_data(array.get(TFS, 2))
[tf4_o2, tf4_h2, tf4_l2, tf4_c2, tf4_o1, tf4_h1, tf4_l1, tf4_c1, tf4_o, tf4_h, tf4_l, tf4_c, tf4_t, tf4_conf] = f_get_tf_data(array.get(TFS, 3))
[tf5_o2, tf5_h2, tf5_l2, tf5_c2, tf5_o1, tf5_h1, tf5_l1, tf5_c1, tf5_o, tf5_h, tf5_l, tf5_c, tf5_t, tf5_conf] = f_get_tf_data(array.get(TFS, 4))
[tf6_o2, tf6_h2, tf6_l2, tf6_c2, tf6_o1, tf6_h1, tf6_l1, tf6_c1, tf6_o, tf6_h, tf6_l, tf6_c, tf6_t, tf6_conf] = f_get_tf_data(array.get(TFS, 5))
[tf7_o2, tf7_h2, tf7_l2, tf7_c2, tf7_o1, tf7_h1, tf7_l1, tf7_c1, tf7_o, tf7_h, tf7_l, tf7_c, tf7_t, tf7_conf] = f_get_tf_data(array.get(TFS, 6))
[tf8_o2, tf8_h2, tf8_l2, tf8_c2, tf8_o1, tf8_h1, tf8_l1, tf8_c1, tf8_o, tf8_h, tf8_l, tf8_c, tf8_t, tf8_conf] = f_get_tf_data(array.get(TFS, 7))
[tf9_o2, tf9_h2, tf9_l2, tf9_c2, tf9_o1, tf9_h1, tf9_l1, tf9_c1, tf9_o, tf9_h, tf9_l, tf9_c, tf9_t, tf9_conf] = f_get_tf_data(array.get(TFS, 8))
[tf10_o2, tf10_h2, tf10_l2, tf10_c2, tf10_o1, tf10_h1, tf10_l1, tf10_c1, tf10_o, tf10_h, tf10_l, tf10_c, tf10_t, tf10_conf] = f_get_tf_data(array.get(TFS, 9))
[tf11_o2, tf11_h2, tf11_l2, tf11_c2, tf11_o1, tf11_h1, tf11_l1, tf11_c1, tf11_o, tf11_h, tf11_l, tf11_c, tf11_t, tf11_conf] = f_get_tf_data(array.get(TFS, 10))
[tf12_o2, tf12_h2, tf12_l2, tf12_c2, tf12_o1, tf12_h1, tf12_l1, tf12_c1, tf12_o, tf12_h, tf12_l, tf12_c, tf12_t, tf12_conf] = f_get_tf_data(array.get(TFS, 11))
[tf13_o2, tf13_h2, tf13_l2, tf13_c2, tf13_o1, tf13_h1, tf13_l1, tf13_c1, tf13_o, tf13_h, tf13_l, tf13_c, tf13_t, tf13_conf] = f_get_tf_data(array.get(TFS, 12))
[tf14_o2, tf14_h2, tf14_l2, tf14_c2, tf14_o1, tf14_h1, tf14_l1, tf14_c1, tf14_o, tf14_h, tf14_l, tf14_c, tf14_t, tf14_conf] = f_get_tf_data(array.get(TFS, 13))
[tf15_o2, tf15_h2, tf15_l2, tf15_c2, tf15_o1, tf15_h1, tf15_l1, tf15_c1, tf15_o, tf15_h, tf15_l, tf15_c, tf15_t, tf15_conf] = f_get_tf_data(array.get(TFS, 14))
[tf16_o2, tf16_h2, tf16_l2, tf16_c2, tf16_o1, tf16_h1, tf16_l1, tf16_c1, tf16_o, tf16_h, tf16_l, tf16_c, tf16_t, tf16_conf] = f_get_tf_data(array.get(TFS, 15))
[tf17_o2, tf17_h2, tf17_l2, tf17_c2, tf17_o1, tf17_h1, tf17_l1, tf17_c1, tf17_o, tf17_h, tf17_l, tf17_c, tf17_t, tf17_conf] = f_get_tf_data(array.get(TFS, 16))
[tf18_o2, tf18_h2, tf18_l2, tf18_c2, tf18_o1, tf18_h1, tf18_l1, tf18_c1, tf18_o, tf18_h, tf18_l, tf18_c, tf18_t, tf18_conf] = f_get_tf_data(array.get(TFS, 17))
[tf19_o2, tf19_h2, tf19_l2, tf19_c2, tf19_o1, tf19_h1, tf19_l1, tf19_c1, tf19_o, tf19_h, tf19_l, tf19_c, tf19_t, tf19_conf] = f_get_tf_data(array.get(TFS, 18))
[tf20_o2, tf20_h2, tf20_l2, tf20_c2, tf20_o1, tf20_h1, tf20_l1, tf20_c1, tf20_o, tf20_h, tf20_l, tf20_c, tf20_t, tf20_conf] = f_get_tf_data(array.get(TFS, 19))
[tf21_o2, tf21_h2, tf21_l2, tf21_c2, tf21_o1, tf21_h1, tf21_l1, tf21_c1, tf21_o, tf21_h, tf21_l, tf21_c, tf21_t, tf21_conf] = f_get_tf_data(array.get(TFS, 20))
[tf22_o2, tf22_h2, tf22_l2, tf22_c2, tf22_o1, tf22_h1, tf22_l1, tf22_c1, tf22_o, tf22_h, tf22_l, tf22_c, tf22_t, tf22_conf] = f_get_tf_data(array.get(TFS, 21))
[tf23_o2, tf23_h2, tf23_l2, tf23_c2, tf23_o1, tf23_h1, tf23_l1, tf23_c1, tf23_o, tf23_h, tf23_l, tf23_c, tf23_t, tf23_conf] = f_get_tf_data(array.get(TFS, 22))
[tf24_o2, tf24_h2, tf24_l2, tf24_c2, tf24_o1, tf24_h1, tf24_l1, tf24_c1, tf24_o, tf24_h, tf24_l, tf24_c, tf24_t, tf24_conf] = f_get_tf_data(array.get(TFS, 23))
[tf25_o2, tf25_h2, tf25_l2, tf25_c2, tf25_o1, tf25_h1, tf25_l1, tf25_c1, tf25_o, tf25_h, tf25_l, tf25_c, tf25_t, tf25_conf] = f_get_tf_data(array.get(TFS, 24))
f_calculate_patterns(int idx, float p_o2, float p_h2, float p_l2, float p_c2, float p_o1, float p_h1, float p_l1, float p_c1, float p_o, float p_h, float p_l, float p_c, int p_t, bool p_conf) =>
valid_data = not na(p_h) and not na(p_l) and not na(p_c) and not na(p_o)
valid_data_1 = not na(p_h1) and not na(p_l1) and not na(p_c1) and not na(p_o1)
valid_data_2 = not na(p_h2) and not na(p_l2) and not na(p_c2) and not na(p_o2)
both_sides = valid_data ? f_has_both_wicks(p_o, p_h, p_l, p_c) : false
both_sides_1 = valid_data_1 ? f_has_both_wicks(p_o1, p_h1, p_l1, p_c1) : false
body_top = valid_data ? math.max(p_o, p_c) : na
body_bottom = valid_data ? math.min(p_o, p_c) : na
is_ib = valid_data and valid_data_1 ? f_is_inside_bar(p_h, p_l, p_h1, p_l1) : false
bear_x3 = valid_data and valid_data_1 and p_h > p_h1 and p_l < p_l1 and both_sides and p_c < p_o
bull_x3 = valid_data and valid_data_1 and p_h > p_h1 and p_l < p_l1 and both_sides and p_c > p_o
is_x3 = bear_x3 or bull_x3
bear_x3_1 = valid_data_1 and valid_data_2 ? p_h1 > p_h2 and p_l1 < p_l2 and both_sides_1 and p_c1 < p_o1 : false
bull_x3_1 = valid_data_1 and valid_data_2 ? p_h1 > p_h2 and p_l1 < p_l2 and both_sides_1 and p_c1 > p_o1 : false
is_x3_1 = bear_x3_1 or bull_x3_1
sn_bull = p_h > p_h1 and p_l < p_l1 and math.max(p_o, p_c) < p_h1 and math.min(p_o, p_c) > p_l1 and p_o < p_c
sn_bear = p_h > p_h1 and p_l < p_l1 and math.min(p_o, p_c) > p_l1 and math.max(p_o, p_c) < p_h1 and p_o > p_c
sn_together = (sn_bull or sn_bear) and not is_x3
sn_bull_candle_1 = p_h1 > p_h2 and p_l1 < p_l2 and p_c1 > p_o1 and math.max(p_o1, p_c1) < p_h2
sn_bear_candle_1 = p_h1 > p_h2 and p_l1 < p_l2 and p_c1 < p_o1 and math.min(p_o1, p_c1) > p_l2
sn_together_1 = (sn_bull_candle_1 or sn_bear_candle_1) and not is_x3_1
bull_laol_first = valid_data and valid_data_1 and valid_data_2 and p_l1 == math.min(p_o1, p_c1) and p_h1 < p_h2 and p_h < p_h1 and p_l < p_l1
bear_laol_first = valid_data and valid_data_1 and valid_data_2 and p_h1 == math.max(p_o1, p_c1) and p_l1 > p_l2 and p_l > p_l1 and p_h > p_h1
bear_first_em = (bull_x3_1 or sn_together_1) and p_h > p_h1 and p_l > p_l1
bull_first_em = (bear_x3_1 or sn_together_1) and p_l < p_l1 and p_h < p_h1
bear_laol_candle = is_ib //and f_bearish_ib_confirmation(p_o1, p_h1, p_l1, p_c1)
bull_laol_candle = is_ib //and f_bullish_ib_confirmation(p_o1, p_h1, p_l1, p_c1)
fu_bear_em = valid_data and valid_data_1 and p_h > p_h1 and p_c < p_h1 and p_c > p_l1 and not is_x3 and not sn_together
fu_bull_em = valid_data and valid_data_1 and p_l < p_l1 and p_c > p_l1 and p_c < p_h1 and not is_x3 and not sn_together
array.set(arr_fu_bear, idx, fu_bear_em)
array.set(arr_fu_bull, idx, fu_bull_em)
array.set(arr_sn_bear, idx, sn_bear)
array.set(arr_sn_bull, idx, sn_bull)
array.set(arr_first_bear, idx, bear_first_em)
array.set(arr_first_bull, idx, bull_first_em)
array.set(arr_laol_bear, idx, bear_laol_first)
array.set(arr_laol_bull, idx, bull_laol_first)
array.set(arr_laol_first_bear, idx, bear_laol_first)
array.set(arr_laol_first_bull, idx, bull_laol_first)
array.set(arr_tf_h, idx, p_h)
array.set(arr_tf_l, idx, p_l)
array.set(arr_tf_bt, idx, body_top)
array.set(arr_tf_bb, idx, body_bottom)
array.set(arr_tf_t, idx, p_t)
array.set(arr_tf_conf, idx, p_conf)
array.set(arr_laol_candle_bear, idx, bear_laol_candle)
array.set(arr_laol_candle_bull, idx, bull_laol_candle)
f_calculate_patterns(0, tf1_o2, tf1_h2, tf1_l2, tf1_c2, tf1_o1, tf1_h1, tf1_l1, tf1_c1, tf1_o, tf1_h, tf1_l, tf1_c, tf1_t, tf1_conf)
f_calculate_patterns(1, tf2_o2, tf2_h2, tf2_l2, tf2_c2, tf2_o1, tf2_h1, tf2_l1, tf2_c1, tf2_o, tf2_h, tf2_l, tf2_c, tf2_t, tf2_conf)
f_calculate_patterns(2, tf3_o2, tf3_h2, tf3_l2, tf3_c2, tf3_o1, tf3_h1, tf3_l1, tf3_c1, tf3_o, tf3_h, tf3_l, tf3_c, tf3_t, tf3_conf)
f_calculate_patterns(3, tf4_o2, tf4_h2, tf4_l2, tf4_c2, tf4_o1, tf4_h1, tf4_l1, tf4_c1, tf4_o, tf4_h, tf4_l, tf4_c, tf4_t, tf4_conf)
f_calculate_patterns(4, tf5_o2, tf5_h2, tf5_l2, tf5_c2, tf5_o1, tf5_h1, tf5_l1, tf5_c1, tf5_o, tf5_h, tf5_l, tf5_c, tf5_t, tf5_conf)
f_calculate_patterns(5, tf6_o2, tf6_h2, tf6_l2, tf6_c2, tf6_o1, tf6_h1, tf6_l1, tf6_c1, tf6_o, tf6_h, tf6_l, tf6_c, tf6_t, tf6_conf)
f_calculate_patterns(6, tf7_o2, tf7_h2, tf7_l2, tf7_c2, tf7_o1, tf7_h1, tf7_l1, tf7_c1, tf7_o, tf7_h, tf7_l, tf7_c, tf7_t, tf7_conf)
f_calculate_patterns(7, tf8_o2, tf8_h2, tf8_l2, tf8_c2, tf8_o1, tf8_h1, tf8_l1, tf8_c1, tf8_o, tf8_h, tf8_l, tf8_c, tf8_t, tf8_conf)
f_calculate_patterns(8, tf9_o2, tf9_h2, tf9_l2, tf9_c2, tf9_o1, tf9_h1, tf9_l1, tf9_c1, tf9_o, tf9_h, tf9_l, tf9_c, tf9_t, tf9_conf)
f_calculate_patterns(9, tf10_o2, tf10_h2, tf10_l2, tf10_c2, tf10_o1, tf10_h1, tf10_l1, tf10_c1, tf10_o, tf10_h, tf10_l, tf10_c, tf10_t, tf10_conf)
f_calculate_patterns(10, tf11_o2, tf11_h2, tf11_l2, tf11_c2, tf11_o1, tf11_h1, tf11_l1, tf11_c1, tf11_o, tf11_h, tf11_l, tf11_c, tf11_t, tf11_conf)
f_calculate_patterns(11, tf12_o2, tf12_h2, tf12_l2, tf12_c2, tf12_o1, tf12_h1, tf12_l1, tf12_c1, tf12_o, tf12_h, tf12_l, tf12_c, tf12_t, tf12_conf)
f_calculate_patterns(12, tf13_o2, tf13_h2, tf13_l2, tf13_c2, tf13_o1, tf13_h1, tf13_l1, tf13_c1, tf13_o, tf13_h, tf13_l, tf13_c, tf13_t, tf13_conf)
f_calculate_patterns(13, tf14_o2, tf14_h2, tf14_l2, tf14_c2, tf14_o1, tf14_h1, tf14_l1, tf14_c1, tf14_o, tf14_h, tf14_l, tf14_c, tf14_t, tf14_conf)
f_calculate_patterns(14, tf15_o2, tf15_h2, tf15_l2, tf15_c2, tf15_o1, tf15_h1, tf15_l1, tf15_c1, tf15_o, tf15_h, tf15_l, tf15_c, tf15_t, tf15_conf)
f_calculate_patterns(15, tf16_o2, tf16_h2, tf16_l2, tf16_c2, tf16_o1, tf16_h1, tf16_l1, tf16_c1, tf16_o, tf16_h, tf16_l, tf16_c, tf16_t, tf16_conf)
if soft_start
f_calculate_patterns(16, tf17_o2, tf17_h2, tf17_l2, tf17_c2, tf17_o1, tf17_h1, tf17_l1, tf17_c1, tf17_o, tf17_h, tf17_l, tf17_c, tf17_t, tf17_conf)
f_calculate_patterns(17, tf18_o2, tf18_h2, tf18_l2, tf18_c2, tf18_o1, tf18_h1, tf18_l1, tf18_c1, tf18_o, tf18_h, tf18_l, tf18_c, tf18_t, tf18_conf)
f_calculate_patterns(18, tf19_o2, tf19_h2, tf19_l2, tf19_c2, tf19_o1, tf19_h1, tf19_l1, tf19_c1, tf19_o, tf19_h, tf19_l, tf19_c, tf19_t, tf19_conf)
f_calculate_patterns(19, tf20_o2, tf20_h2, tf20_l2, tf20_c2, tf20_o1, tf20_h1, tf20_l1, tf20_c1, tf20_o, tf20_h, tf20_l, tf20_c, tf20_t, tf20_conf)
f_calculate_patterns(20, tf21_o2, tf21_h2, tf21_l2, tf21_c2, tf21_o1, tf21_h1, tf21_l1, tf21_c1, tf21_o, tf21_h, tf21_l, tf21_c, tf21_t, tf21_conf)
f_calculate_patterns(21, tf22_o2, tf22_h2, tf22_l2, tf22_c2, tf22_o1, tf22_h1, tf22_l1, tf22_c1, tf22_o, tf22_h, tf22_l, tf22_c, tf22_t, tf22_conf)
f_calculate_patterns(22, tf23_o2, tf23_h2, tf23_l2, tf23_c2, tf23_o1, tf23_h1, tf23_l1, tf23_c1, tf23_o, tf23_h, tf23_l, tf23_c, tf23_t, tf23_conf)
f_calculate_patterns(23, tf24_o2, tf24_h2, tf24_l2, tf24_c2, tf24_o1, tf24_h1, tf24_l1, tf24_c1, tf24_o, tf24_h, tf24_l, tf24_c, tf24_t, tf24_conf)
f_calculate_patterns(24, tf25_o2, tf25_h2, tf25_l2, tf25_c2, tf25_o1, tf25_h1, tf25_l1, tf25_c1, tf25_o, tf25_h, tf25_l, tf25_c, tf25_t, tf25_conf)
f_add_or_merge_laol_line(laol_line_data[] lines, float level, string tf_label, bool is_bear, string category) =>
tolerance = syminfo.mintick * 2
merged = false
bool found_broken = false
if array.size(lines) > 0
for laol in lines
if math.abs(laol.level - level) < tolerance
if laol.is_broken
found_broken := true
break
if not str.contains(laol.tf_labels, tf_label)
laol.tf_labels := laol.tf_labels + "," + tf_label
laol.tf_count := laol.tf_count + 1
if category == "INTRA"
laol.has_intra := true
else if category == "SCALP"
laol.has_scalp := true
else
laol.has_entry := true
merged := true
break
if not merged and not found_broken
new_laol = laol_line_data.new()
new_laol.level := level
new_laol.tf_labels := tf_label
new_laol.creation_bar := bar_index
new_laol.is_bear := is_bear
new_laol.tf_count := 1
new_laol.has_entry := category == "ENTRY"
new_laol.has_scalp := category == "SCALP"
new_laol.has_intra := category == "INTRA"
array.push(lines, new_laol)
0
f_update_laol_lines(laol_line_data[] lines, bool is_bear, float current_price) =>
int break_time = 0
string break_tf = ""
int intra_break_time = 0
string intra_break_tf = ""
int scalp_break_time = 0
string scalp_break_tf = ""
if array.size(lines) > 0
for idx = array.size(lines) - 1 to 0
if idx >= array.size(lines)
continue
laol = array.get(lines, idx)
crossed = is_bear ? (current_price > laol.level) : (current_price < laol.level)
if crossed and not laol.is_broken
laol.is_broken := true
laol.break_bar := bar_index
if laol.has_intra
intra_break_time := time
intra_break_tf := laol.tf_labels
else if laol.has_scalp
scalp_break_time := time
scalp_break_tf := laol.tf_labels
else
break_time := time
break_tf := laol.tf_labels
if laol.is_broken and bar_index >= laol.break_bar + LAOL_DELETE_DELAY
array.remove(lines, idx)
[break_time, break_tf, intra_break_time, intra_break_tf, scalp_break_time, scalp_break_tf]
f_get_broken_laol(laol_line_data[] lines, bool require_multi) =>
float result_level = na
int result_tf_count = 0
if array.size(lines) > 0
for laol in lines
if laol.is_broken and bar_index == laol.break_bar
if not require_multi or laol.tf_count >= 2
result_level := laol.level
result_tf_count := laol.tf_count
break
[result_level, result_tf_count]
f_merge_cross_category(laol_line_data[] entry_lines, laol_line_data[] scalp_lines, laol_line_data[] intra_lines, float level, string tf_label, bool is_bear) =>
tolerance = syminfo.mintick * 2
bool merged = false
if array.size(intra_lines) > 0
for laol in intra_lines
if math.abs(laol.level - level) < tolerance and not laol.is_broken
if not str.contains(laol.tf_labels, tf_label)
laol.tf_labels := laol.tf_labels + "," + tf_label
laol.tf_count += 1
merged := true
break
if not merged and array.size(scalp_lines) > 0
for laol in scalp_lines
if math.abs(laol.level - level) < tolerance and not laol.is_broken
if not str.contains(laol.tf_labels, tf_label)
laol.tf_labels := laol.tf_labels + "," + tf_label
laol.tf_count += 1
merged := true
break
if not merged and array.size(entry_lines) > 0
for laol in entry_lines
if math.abs(laol.level - level) < tolerance and not laol.is_broken
if not str.contains(laol.tf_labels, tf_label)
laol.tf_labels := laol.tf_labels + "," + tf_label
laol.tf_count += 1
merged := true
break
merged
f_scan_laol_in_box(laol_line_data[] laol_arr, float _top, float _bot, bool _is_bear, string _laol_cat, string _box_cat) =>
color _col = _laol_cat == "ENTRY" ? color.new(color.blue, 0) : color.new(color.green, 0)
color _lcol = _laol_cat == "ENTRY" ? color.new(color.blue, 50) : color.new(color.green, 50)
int _off = _laol_cat == "ENTRY" ? 15 : 30
float _tol = syminfo.mintick * 3
for _ll in laol_arr
if _ll.is_broken
continue
if _ll.level <= _top and _ll.level >= _bot
bool _already = false
int _sz = array.size(_xlaol_levels)
if _sz > 0
for _ei = 0 to _sz - 1
if math.abs(array.get(_xlaol_levels, _ei) - _ll.level) < _tol and array.get(_xlaol_cat, _ei) == _laol_cat
_elbl = array.get(_xlaol_labels, _ei)
if not na(_elbl)
_cur_txt = label.get_text(_elbl)
if not str.contains(_cur_txt, _box_cat)
label.set_text(_elbl, _cur_txt + "+" + _box_cat)
label.set_color(_elbl, color.new(color.purple, 40))
_already := true
break
if not _already
_ln = line.new(bar_index, _ll.level, bar_index + _off, _ll.level,
color=_col, width=1, style=line.style_dashed, extend=extend.none)
_lb = label.new(bar_index + _off, _ll.level,
_laol_cat + " LAOL [" + _ll.tf_labels + "] in " + _box_cat,
style=label.style_label_left, color=_lcol,
textcolor=color.white, size=size.tiny)
array.push(_xlaol_lines, _ln)
array.push(_xlaol_labels, _lb)
array.push(_xlaol_levels, _ll.level)
array.push(_xlaol_bear, _is_bear)
array.push(_xlaol_cat, _laol_cat)
array.push(_xlaol_off, _off)
0
f_manage_tf_boxes(tracked_box[] boxes, float p_h, float p_l, int p_t, bool p_conf, string tf_str) =>
bear_retesting = false
bull_retesting = false
bear_retest_pattern = ""
bull_retest_pattern = ""
bear_retest_level = float(na)
bull_retest_level = float(na)
bear_est_retest = false
bull_est_retest = false
bear_est_retest_valid = false
bull_est_retest_valid = false
if array.size(boxes) > 0
for idx = array.size(boxes) - 1 to 0
if idx >= array.size(boxes)
continue
bx = array.get(boxes, idx)
bool is_em = f_is_em_pattern(bx.pattern_text)
if bx.state == "FORMING" and na(bx.box_obj) and p_conf
bx.box_obj := box.new(bar_index, bx.top_val, bar_index + 50, bx.bottom_val,
border_color = is_em ? color.new(bx.border_color, unretested_border_transparency) : bx.border_color,
bgcolor = bx.box_color, extend = extend.right, border_style = line.style_dashed, border_width = 1,
text = is_em ? bx.pattern_text : "", text_size = size.small,
text_color = color.new(color.white, 100), text_halign = text.align_left, text_valign = text.align_top)
if not na(bx.box_obj)
if bx.has_been_retested
box.set_border_style(bx.box_obj, line.style_solid)
box.set_border_color(bx.box_obj, bx.border_color)
else
box.set_border_style(bx.box_obj, line.style_dashed)
box.set_border_color(bx.box_obj, color.new(bx.border_color, unretested_border_transparency))
box.set_bgcolor(bx.box_obj, bx.box_color)
if bx.direction == "bear"
if not na(p_h) and p_h > bx.original_top
if not na(bx.box_obj)
box.delete(bx.box_obj)
array.remove(boxes, idx)
continue
if bx.state == "FORMING"
if p_conf
bx.state := "ESTABLISHED"
bx.just_established := true
tf_seconds = timeframe.in_seconds(tf_str)
protection_candles = f_is_entry(tf_str) ? 3 : 1
bx.protection_end_time := p_t + (tf_seconds * 1000 * protection_candles)
bx.protection_active := true
bx.est_wick_high := p_h
bx.est_wick_low := p_l
else if bx.state == "ESTABLISHED"
wick_zone_touched = not na(p_h) and p_h >= bx.bottom_val and p_h < bx.original_top
if bx.protection_active
if wick_zone_touched
wick_in_range = not na(bx.est_wick_high) and not na(bx.est_wick_low) and p_h >= bx.est_wick_low and p_h <= bx.est_wick_high
if wick_in_range
bx.state := "EST_RETEST"
bx.has_est_retest := true
bx.has_been_retested := true
bx.retest_type := "EST+RETEST"
bear_est_retest := true
bear_retest_pattern := bx.pattern_text + " [EST+RET]"
bear_retest_level := bx.original_top
if not na(bx.box_obj)
box.set_border_style(bx.box_obj, line.style_solid)
box.set_border_color(bx.box_obj, bx.border_color)
else
bx.state := "FORMING_FRESH"
bx.has_been_retested := true
bear_retesting := true
bear_retest_pattern := bx.pattern_text + " [FRESH FORMING]"
bear_retest_level := bx.original_top
if p_conf and p_t >= bx.protection_end_time
bx.protection_active := false
if bx.state == "ESTABLISHED"
bx.retest_type := "FRESH"
bx.completed_est_retest := true
else
if wick_zone_touched
bx.state := "RESPECTED"
bx.has_been_retested := true
bear_retesting := true
bear_retest_pattern := bx.pattern_text + " [FRESH]"
bear_retest_level := bx.original_top
if not na(bx.box_obj)
box.set_border_style(bx.box_obj, line.style_solid)
box.set_border_color(bx.box_obj, bx.border_color)
if p_h > bx.bottom_val and p_h < bx.top_val
bx.bottom_val := p_h
if not na(bx.box_obj)
box.set_bottom(bx.box_obj, bx.bottom_val)
else if bx.state == "FORMING_FRESH"
wick_zone_touched = not na(p_h) and p_h >= bx.bottom_val and p_h < bx.original_top
if wick_zone_touched
bear_retesting := true
bear_retest_pattern := bx.pattern_text + " [FRESH FORMING]"
bear_retest_level := bx.original_top
if p_conf and p_t >= bx.protection_end_time
bx.state := "RESPECTED"
bx.protection_active := false
bx.retest_type := "FRESH"
bx.completed_est_retest := true
else if bx.state == "EST_RETEST"
wick_zone_touched = not na(p_h) and p_h >= bx.bottom_val and p_h < bx.original_top
bear_est_retest := true
bear_retest_pattern := bx.pattern_text + " [EST+RET]"
bear_retest_level := bx.original_top
if wick_zone_touched
bear_retesting := true
if p_conf and p_t >= bx.protection_end_time
bear_est_retest_valid := true
bx.state := "RESPECTED"
bx.protection_active := false
bx.retest_type := "FRESH"
bx.completed_est_retest := true
else if bx.state == "RESPECTED"
is_touching = not na(p_h) and p_h >= bx.bottom_val and p_l <= bx.top_val
if is_touching
bear_retesting := true
bear_retest_pattern := bx.pattern_text + " [" + bx.retest_type + "]"
bear_retest_level := bx.original_top
if p_h > bx.bottom_val and p_h < bx.top_val
bx.bottom_val := p_h
if not na(bx.box_obj)
box.set_bottom(bx.box_obj, bx.bottom_val)
else if bx.direction == "bull"
if not na(p_l) and p_l < bx.original_bottom
if not na(bx.box_obj)
box.delete(bx.box_obj)
array.remove(boxes, idx)
continue
if bx.state == "FORMING"
if p_conf
bx.state := "ESTABLISHED"
bx.just_established := true
tf_seconds = timeframe.in_seconds(tf_str)
protection_candles = f_is_entry(tf_str) ? 3 : 1
bx.protection_end_time := p_t + (tf_seconds * 1000 * protection_candles)
bx.protection_active := true
bx.est_wick_high := p_h
bx.est_wick_low := p_l
else if bx.state == "ESTABLISHED"
wick_zone_touched = not na(p_l) and p_l <= bx.top_val and p_l > bx.original_bottom
if bx.protection_active
if wick_zone_touched
wick_in_range = not na(bx.est_wick_high) and not na(bx.est_wick_low) and p_l >= bx.est_wick_low and p_l <= bx.est_wick_high
if wick_in_range
bx.state := "EST_RETEST"
bx.has_est_retest := true
bx.has_been_retested := true
bx.retest_type := "EST+RETEST"
bull_est_retest := true
bull_retest_pattern := bx.pattern_text + " [EST+RET]"
bull_retest_level := bx.original_bottom
if not na(bx.box_obj)
box.set_border_style(bx.box_obj, line.style_solid)
box.set_border_color(bx.box_obj, bx.border_color)
else
bx.state := "FORMING_FRESH"
bx.has_been_retested := true
bull_retesting := true
bull_retest_pattern := bx.pattern_text + " [FRESH FORMING]"
bull_retest_level := bx.original_bottom
if p_conf and p_t >= bx.protection_end_time
bx.protection_active := false
if bx.state == "ESTABLISHED"
bx.retest_type := "FRESH"
bx.completed_est_retest := true
else
if wick_zone_touched
bx.state := "RESPECTED"
bx.has_been_retested := true
bull_retesting := true
bull_retest_pattern := bx.pattern_text + " [FRESH]"
bull_retest_level := bx.original_bottom
if not na(bx.box_obj)
box.set_border_style(bx.box_obj, line.style_solid)
box.set_border_color(bx.box_obj, bx.border_color)
if p_l < bx.top_val and p_l > bx.bottom_val
bx.top_val := p_l
if not na(bx.box_obj)
box.set_top(bx.box_obj, bx.top_val)
else if bx.state == "FORMING_FRESH"
wick_zone_touched = not na(p_l) and p_l <= bx.top_val and p_l > bx.original_bottom
if wick_zone_touched
bull_retesting := true
bull_retest_pattern := bx.pattern_text + " [FRESH FORMING]"
bull_retest_level := bx.original_bottom
if p_conf and p_t >= bx.protection_end_time
bx.state := "RESPECTED"
bx.protection_active := false
bx.retest_type := "FRESH"
bx.completed_est_retest := true
else if bx.state == "EST_RETEST"
wick_zone_touched = not na(p_l) and p_l <= bx.top_val and p_l > bx.original_bottom
bull_est_retest := true
bull_retest_pattern := bx.pattern_text + " [EST+RET]"
bull_retest_level := bx.original_bottom
if wick_zone_touched
bull_retesting := true
if p_conf and p_t >= bx.protection_end_time
bull_est_retest_valid := true
bx.state := "RESPECTED"
bx.protection_active := false
bx.retest_type := "FRESH"
bx.completed_est_retest := true
else if bx.state == "RESPECTED"
is_touching = not na(p_l) and p_l <= bx.top_val and p_h >= bx.bottom_val
if is_touching
bull_retesting := true
bull_retest_pattern := bx.pattern_text + " [" + bx.retest_type + "]"
bull_retest_level := bx.original_bottom
if p_l < bx.top_val and p_l > bx.bottom_val
bx.top_val := p_l
if not na(bx.box_obj)
box.set_top(bx.box_obj, bx.top_val)
[bear_retesting, bull_retesting, bear_retest_pattern, bull_retest_pattern, bear_retest_level, bull_retest_level, bear_est_retest, bull_est_retest, bear_est_retest_valid, bull_est_retest_valid]
f_create_box(tracked_box[] boxes, string direction, float top_v, float bottom_v, int creation_t, string pattern, string tf_str, bool is_intra, bool should_show) =>
bool result = false
if pattern != "" and not na(top_v) and not na(bottom_v) and not na(creation_t)
exists = false
for bx in boxes
if bx.creation_time == creation_t and bx.direction == direction and bx.timeframe == tf_str
exists := true
break
if not exists
new_box = tracked_box.new()
new_box.direction := direction
new_box.state := "FORMING"
new_box.top_val := top_v
new_box.bottom_val := bottom_v
new_box.original_top := top_v
new_box.original_bottom := bottom_v
new_box.creation_time := creation_t
new_box.pattern_text := pattern
new_box.base_pattern := pattern
new_box.timeframe := tf_str
new_box.is_intra := is_intra
bool is_em = f_is_em_pattern(pattern)
new_box.is_em_forming := is_em
if is_em
tf_category = f_get_full_category(tf_str)
if tf_category == "ENTRY"
new_box.box_color := entry_box_color
new_box.border_color := entry_border_color
else if tf_category == "SCALP"
new_box.box_color := scalp_box_color
new_box.border_color := scalp_border_color
else
new_box.box_color := intra_box_color
new_box.border_color := intra_border_color
else
new_box.box_color := color.new(color.white, 100)
new_box.border_color := color.new(color.white, 100)
array.unshift(boxes, new_box)
result := true
result
f_manage_hcs_boxes(hcs_box_data[] hcs_boxes, bool is_bear) =>
bool any_retesting = false
if array.size(hcs_boxes) > 0
for idx = array.size(hcs_boxes) - 1 to 0
if idx >= array.size(hcs_boxes)
continue
hcs = array.get(hcs_boxes, idx)
if is_bear
if not hcs.is_broken and high > hcs.top_val
hcs.is_broken := true
hcs.box_obj := box.new(hcs.creation_bar, hcs.top_val, bar_index + 50, hcs.bottom_val,
border_color = hcs_bear_border, bgcolor = hcs_bear_bg,
extend = extend.right, border_width = 2, border_style = line.style_solid,
text = "HCS BROKEN [" + hcs.tf_label + "]", text_size = size.small,
text_color = color.white, text_halign = text.align_left, text_valign = text.align_top)
if hcs.is_broken and not na(hcs.box_obj)
if high >= hcs.bottom_val and high <= hcs.top_val
any_retesting := true
if low < hcs.bottom_val
box.delete(hcs.box_obj)
array.remove(hcs_boxes, idx)
continue
if low <= hcs.top_val and low >= hcs.bottom_val
if low < hcs.top_val
hcs.top_val := low
box.set_top(hcs.box_obj, hcs.top_val)
else
if not hcs.is_broken and low < hcs.bottom_val
hcs.is_broken := true
hcs.box_obj := box.new(hcs.creation_bar, hcs.top_val, bar_index + 50, hcs.bottom_val,
border_color = hcs_bull_border, bgcolor = hcs_bull_bg,
extend = extend.right, border_width = 2, border_style = line.style_solid,
text = "HCS BROKEN [" + hcs.tf_label + "]", text_size = size.small,
text_color = color.white, text_halign = text.align_left, text_valign = text.align_top)
if hcs.is_broken and not na(hcs.box_obj)
if low >= hcs.bottom_val and low <= hcs.top_val
any_retesting := true
if high > hcs.top_val
box.delete(hcs.box_obj)
array.remove(hcs_boxes, idx)
continue
if low >= hcs.bottom_val and low <= hcs.top_val
if low > hcs.bottom_val
hcs.bottom_val := low
box.set_bottom(hcs.box_obj, hcs.bottom_val)
any_retesting
int entry_sn_bear_count = 0
int entry_sn_bull_count = 0
int scalp_sn_bear_count = 0
int scalp_sn_bull_count = 0
int intra_sn_bear_count = 0
int intra_sn_bull_count = 0
for i = 0 to TF_COUNT - 1
tf_str = array.get(TFS, i)
tf_category = array.get(TF_CATEGORIES, i)
if tf_category == "NONE"
continue
should_show = tf_category == "ENTRY"or tf_category == "SCALP"or (tf_category == "INTRA" and soft_start)
i_h = array.get(arr_tf_h, i)
i_l = array.get(arr_tf_l, i)
i_t = array.get(arr_tf_t, i)
i_conf = array.get(arr_tf_conf, i)
i_bt = array.get(arr_tf_bt, i)
i_bb = array.get(arr_tf_bb, i)
i_fu_bear = array.get(arr_fu_bear, i)
i_fu_bull = array.get(arr_fu_bull, i)
i_sn_bear = array.get(arr_sn_bear, i)
i_sn_bull = array.get(arr_sn_bull, i)
if i_sn_bear
if tf_category == "ENTRY"
entry_sn_bear_count += 1
else if tf_category == "SCALP"
scalp_sn_bear_count += 1
else if tf_category == "INTRA"
intra_sn_bear_count += 1
if i_sn_bull
if tf_category == "ENTRY"
entry_sn_bull_count += 1
else if tf_category == "SCALP"
scalp_sn_bull_count += 1
else if tf_category == "INTRA"
intra_sn_bull_count += 1
i_second_bear = array.get(arr_second_bear, i)
i_second_bull = array.get(arr_second_bull, i)
i_laol_first_bear = array.get(arr_laol_first_bear, i)
i_laol_first_bull = array.get(arr_laol_first_bull, i)
if array.get(arr_bear_third_step, i) == 1 and i_conf
ref_time = array.get(arr_bear_third_ref_time, i)
if not na(ref_time) and i_t > ref_time
ref_h = array.get(arr_bear_third_ref_h, i)
ref_l = array.get(arr_bear_third_ref_l, i)
if not na(ref_h) and not na(ref_l) and i_h > ref_h and i_l > ref_l
array.set(arr_third_bear, i, true)
array.set(arr_bear_third_step, i, 0)
array.set(arr_bear_third_ref_h, i, na)
array.set(arr_bear_third_ref_l, i, na)
array.set(arr_bear_third_ref_time, i, na)
if i_second_bear and i_conf
array.set(arr_bear_third_step, i, 1)
array.set(arr_bear_third_ref_h, i, i_h)
array.set(arr_bear_third_ref_l, i, i_l)
array.set(arr_bear_third_ref_time, i, i_t)
if array.get(arr_bull_third_step, i) == 1 and i_conf
ref_time = array.get(arr_bull_third_ref_time, i)
if not na(ref_time) and i_t > ref_time
ref_h = array.get(arr_bull_third_ref_h, i)
ref_l = array.get(arr_bull_third_ref_l, i)
if not na(ref_h) and not na(ref_l) and i_l < ref_l and i_h < ref_h
array.set(arr_third_bull, i, true)
array.set(arr_bull_third_step, i, 0)
array.set(arr_bull_third_ref_h, i, na)
array.set(arr_bull_third_ref_l, i, na)
array.set(arr_bull_third_ref_time, i, na)
if i_second_bull and i_conf
array.set(arr_bull_third_step, i, 1)
array.set(arr_bull_third_ref_h, i, i_h)
array.set(arr_bull_third_ref_l, i, i_l)
array.set(arr_bull_third_ref_time, i, i_t)
if array.get(arr_bear_laol_step, i) == 1 and i_conf
ref_time = array.get(arr_bear_laol_ref_time, i)
if not na(ref_time) and i_t > ref_time
ref_h = array.get(arr_bear_laol_ref_h, i)
ref_l = array.get(arr_bear_laol_ref_l, i)
if not na(ref_h) and not na(ref_l) and i_h > ref_h and i_l > ref_l
array.set(arr_laol_bear, i, true)
array.set(arr_bear_laol_step, i, 0)
array.set(arr_bear_laol_ref_h, i, na)
array.set(arr_bear_laol_ref_l, i, na)
array.set(arr_bear_laol_ref_time, i, na)
if i_laol_first_bear and i_conf
array.set(arr_bear_laol_step, i, 1)
array.set(arr_bear_laol_ref_h, i, i_h)
array.set(arr_bear_laol_ref_l, i, i_l)
array.set(arr_bear_laol_ref_time, i, i_t)
if array.get(arr_bull_laol_step, i) == 1 and i_conf
ref_time = array.get(arr_bull_laol_ref_time, i)
if not na(ref_time) and i_t > ref_time
ref_h = array.get(arr_bull_laol_ref_h, i)
ref_l = array.get(arr_bull_laol_ref_l, i)
if not na(ref_h) and not na(ref_l) and i_h < ref_h and i_l < ref_l
array.set(arr_laol_bull, i, true)
array.set(arr_bull_laol_step, i, 0)
array.set(arr_bull_laol_ref_h, i, na)
array.set(arr_bull_laol_ref_l, i, na)
array.set(arr_bull_laol_ref_time, i, na)
if i_laol_first_bull and i_conf
array.set(arr_bull_laol_step, i, 1)
array.set(arr_bull_laol_ref_h, i, i_h)
array.set(arr_bull_laol_ref_l, i, i_l)
array.set(arr_bull_laol_ref_time, i, i_t)
i_third_bear = array.get(arr_third_bear, i)
i_third_bull = array.get(arr_third_bull, i)
i_first_bear = array.get(arr_first_bear, i)
i_first_bull = array.get(arr_first_bull, i)
i_laol_bear = array.get(arr_laol_bear, i)
i_laol_bull = array.get(arr_laol_bull, i)
bear_seq = array.get(arr_bear_seq, i)
bull_seq = array.get(arr_bull_seq, i)
i_x3_bear = i_third_bear or i_first_bear
i_x3_bull = i_third_bull or i_first_bull
[bear_step, bear_tbe] = f_update_seq(bear_seq, i_fu_bear, i_x3_bear, i_fu_bull, i_x3_bull, i_h, i_bt, tf_str, i_conf, true, i_h, i_l)
[bull_step, bull_tbe] = f_update_seq(bull_seq, i_fu_bull, i_x3_bull, i_fu_bear, i_x3_bear, i_l, i_bb, tf_str, i_conf, false, i_h, i_l)
array.set(arr_bear_seq, i, bear_seq)
array.set(arr_bull_seq, i, bull_seq)
sn_dbl_bear = i_sn_bear and (tf_category == "ENTRY" ? entry_sn_bear_count >= 2 : tf_category == "SCALP" ? scalp_sn_bear_count >= 2 : intra_sn_bear_count >= 2)
sn_dbl_bull = i_sn_bull and (tf_category == "ENTRY" ? entry_sn_bull_count >= 2 : tf_category == "SCALP" ? scalp_sn_bull_count >= 2 : intra_sn_bull_count >= 2)
bear_hcs = false
bull_hcs = false
bear_hcs_forming = false
bull_hcs_forming = false
if should_show
tracked_box[] boxes = f_get_boxes(i)
new_bear_fu_sn = i_fu_bear or i_sn_bear
new_bull_fu_sn = i_fu_bull or i_sn_bull
if array.size(boxes) > 0 and (new_bear_fu_sn or new_bull_fu_sn)
for bx in boxes
if bx.timeframe != tf_str or bx.creation_time == i_t or bx.state == "FORMING"
continue
bx_has_fu_sn = str.contains(bx.base_pattern, "FU") or str.contains(bx.base_pattern, "SN")
if not bx_has_fu_sn
continue
if bx.direction == "bear" and new_bear_fu_sn
if not na(i_h) and i_h >= bx.bottom_val and i_h <= bx.original_top
if i_conf
if array.get(arr_last_bear_hcs_time, i) != i_t
bear_hcs := true
bx.hcs_count := bx.hcs_count + 1
bx.pattern_text := bx.base_pattern + " [HCS X" + str.tostring(bx.hcs_count) + "]"
array.set(arr_last_bear_hcs_time, i, i_t)
if show_hcs_boxes and bx.hcs_count == 1 and (tf_str == "50" or tf_str == "60")
new_hcs = hcs_box_data.new()
new_hcs.top_val := bx.original_top
new_hcs.bottom_val := bx.original_bottom
new_hcs.creation_bar := bar_index
new_hcs.tf_label := array.get(TF_LABELS, i)
new_hcs.direction := "bear"
new_hcs.is_broken := false
array.push(hcs_boxes_bear, new_hcs)
else
bear_hcs_forming := true
if bx.direction == "bull" and new_bull_fu_sn
if not na(i_l) and i_l <= bx.top_val and i_l >= bx.original_bottom
if i_conf
if array.get(arr_last_bull_hcs_time, i) != i_t
bull_hcs := true
bx.hcs_count := bx.hcs_count + 1
bx.pattern_text := bx.base_pattern + " [HCS X" + str.tostring(bx.hcs_count) + "]"
array.set(arr_last_bull_hcs_time, i, i_t)
if show_hcs_boxes and bx.hcs_count == 1 and (tf_str == "50" or tf_str == "60")
new_hcs = hcs_box_data.new()
new_hcs.top_val := bx.original_top
new_hcs.bottom_val := bx.original_bottom
new_hcs.creation_bar := bar_index
new_hcs.tf_label := array.get(TF_LABELS, i)
new_hcs.direction := "bull"
new_hcs.is_broken := false
array.push(hcs_boxes_bull, new_hcs)
else
bull_hcs_forming := true
array.set(arr_bear_hcs, i, bear_hcs)
array.set(arr_bull_hcs, i, bull_hcs)
array.set(arr_bear_hcs_forming, i, bear_hcs_forming)
array.set(arr_bull_hcs_forming, i, bull_hcs_forming)
bear_pattern = f_pattern_str(true, i_third_bear, i_first_bear, i_laol_bear, i_sn_bear, sn_dbl_bear, i_fu_bear, bear_tbe, bear_hcs, bear_hcs_forming)
bull_pattern = f_pattern_str(false, i_third_bull, i_first_bull, i_laol_bull, i_sn_bull, sn_dbl_bull, i_fu_bull, bull_tbe, bull_hcs, bull_hcs_forming)
if bear_pattern != "" and not na(i_h) and not na(i_bt) and not na(i_t)
f_create_box(boxes, "bear", i_h, i_bt, i_t, bear_pattern, tf_str, tf_category == "INTRA", should_show)
if bull_pattern != "" and not na(i_l) and not na(i_bb) and not na(i_t)
f_create_box(boxes, "bull", i_bb, i_l, i_t, bull_pattern, tf_str, tf_category == "INTRA", should_show)
[bear_ret, bull_ret, bear_pat, bull_pat, bear_lvl, bull_lvl, bear_est, bull_est, bear_est_valid, bull_est_valid] = f_manage_tf_boxes(boxes, i_h, i_l, i_t, i_conf, tf_str)
array.set(arr_bear_retesting, i, bear_ret)
array.set(arr_bull_retesting, i, bull_ret)
array.set(arr_bear_retest_pattern, i, bear_pat)
array.set(arr_bull_retest_pattern, i, bull_pat)
array.set(arr_bear_retest_level, i, bear_lvl)
array.set(arr_bull_retest_level, i, bull_lvl)
arrayПоказано первые 50% кода (символов: 100004)
Открыть по тарифу
Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.
Разовая покупка файла
На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.
Зачем нужен email? После подтверждения оплаты файл сохранится в кабинете на этот email. Если аккаунта ещё нет, мы создадим его и пришлём ссылку для задания пароля. Если аккаунт уже есть, покупка добавится в него. Укажите адрес, к которому у вас есть доступ.
Чтобы оформить заказ, введите email и перейдите к оплате.