Dtfxalgo
Dtfxalgo
0
International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator("DTFX Algo Zones [LuxAlgo]", shorttitle = "LuxAlgo - DTFX Algo Zones",
overlay = true, max_boxes_count = 500, max_lines_count = 500)
///--------------------------------------------------------------------------------
-------------------------------------}
//Inputs
//---------------------------------------------------------------------------------
------------------------------------{
//---------------------------------------------------------------------------------
------------------------------------}
//UDTs
//---------------------------------------------------------------------------------
------------------------------------{
type pb
float price
int bar
type fs
line f1
line f2
line f3
line f4
line f5
//---------------------------------------------------------------------------------
------------------------------------}
//Functions
//---------------------------------------------------------------------------------
------------------------------------{
linestyle(_input) =>
_input == "___"?line.style_solid:
_input == "- - -"?line.style_dashed:
_input == ". . ."?line.style_dotted:
na
get_fibs(_top,_bot,_dir,_fl1,_fl2,_fl3,_fl4,_fl5) =>
rng = _dir == 1 ? _top - _bot : _bot - _top
anchor = _dir == 1 ? _bot : _top
fib1 = anchor + (rng*_fl1)
fib2 = anchor + (rng*_fl2)
fib3 = anchor + (rng*_fl3)
fib4 = anchor + (rng*_fl4)
fib5 = anchor + (rng*_fl5)
[fib1,fib2,fib3,fib4,fib5]
//---------------------------------------------------------------------------------
------------------------------------}
//Calcs
//---------------------------------------------------------------------------------
------------------------------------{
float top = na
float btm = na
var pb t = pb.new(na,na)
var pb b = pb.new(na,na)
upper = ta.highest(structureLen)
lower = ta.lowest(structureLen)
int structure_confirmed = 0
if top_conf
t := pb.new(top,bar_index-structureLen)
bos_up_check := true
if structureTog
structure_confirmed := 1
if bot_conf
b := pb.new(btm,bar_index-structureLen)
bos_down_check := true
if structureTog
structure_confirmed := -1
last_top := HH?"HH":LH?"LH":last_top
last_bot := LL?"LL":HL?"HL":last_bot
var int t_dir = 0
if choch_up
t_dir := 1
if choch_down
t_dir := -1
if mss_up
bos_up_check := false
if zoneFilter != "Bearish Only"
_top = t.price
_bot = dir == -1 ? lower : dir == 1 ? b.price : 0
[fib1,fib2,fib3,fib4,fib5] =
get_fibs(_top,_bot,1,f1Lvl,f2Lvl,f3Lvl,f4Lvl,f5Lvl)
live_zone := box.new(t.bar,_top,bar_index,_bot,bgcolor =
bullZoneColor,border_color = na)
live_lvls := fs.new(
line.new(t.bar,(f1Tog?fib1:na),bar_index,fib1, color = f1BullColor, style
= linestyle(f1Style)),
line.new(t.bar,(f2Tog?fib2:na),bar_index,fib2, color = f2BullColor, style
= linestyle(f2Style)),
line.new(t.bar,(f3Tog?fib3:na),bar_index,fib3, color = f3BullColor, style
= linestyle(f3Style)),
line.new(t.bar,(f4Tog?fib4:na),bar_index,fib4, color = f4BullColor, style
= linestyle(f4Style)),
line.new(t.bar,(f5Tog?fib5:na),bar_index,fib5, color = f5BullColor, style
= linestyle(f5Style))
)
zones.push(live_zone)
lvls.push(live_lvls)
if mss_down
bos_down_check := false
if zoneFilter != "Bullish Only"
_top = dir == 1 ? upper : dir == -1 ? t.price : 0
_bot = b.price
[fib1,fib2,fib3,fib4,fib5] = get_fibs(_top,_bot,-
1,f1Lvl,f2Lvl,f3Lvl,f4Lvl,f5Lvl)
live_zone := box.new(b.bar,_top,bar_index,_bot,bgcolor =
bearZoneColor,border_color = na)
live_lvls := fs.new(
line.new(b.bar,(f1Tog?fib1:na),bar_index,fib1, color = f1BearColor, style
= linestyle(f1Style)),
line.new(b.bar,(f2Tog?fib2:na),bar_index,fib2, color = f2BearColor, style
= linestyle(f2Style)),
line.new(b.bar,(f3Tog?fib3:na),bar_index,fib3, color = f3BearColor, style
= linestyle(f3Style)),
line.new(b.bar,(f4Tog?fib4:na),bar_index,fib4, color = f4BearColor, style
= linestyle(f4Style)),
line.new(b.bar,(f5Tog?fib5:na),bar_index,fib5, color = f5BearColor, style
= linestyle(f5Style))
)
zones.push(live_zone)
lvls.push(live_lvls)
live_lvls.f1.set_x1(math.max(live_zone.get_left(),last_zone.get_right()))
live_lvls.f2.set_x1(math.max(live_zone.get_left(),last_zone.get_right()))
live_lvls.f3.set_x1(math.max(live_zone.get_left(),last_zone.get_right()))
live_lvls.f4.set_x1(math.max(live_zone.get_left(),last_zone.get_right()))
live_lvls.f5.set_x1(math.max(live_zone.get_left(),last_zone.get_right()))
live_lvls.f1.set_x2(bar_index)
live_lvls.f2.set_x2(bar_index)
live_lvls.f3.set_x2(bar_index)
live_lvls.f4.set_x2(bar_index)
live_lvls.f5.set_x2(bar_index)
//---------------------------------------------------------------------------------
------------------------------------}