FVG Sessions (LuxAlgo)
FVG Sessions (LuxAlgo)
FVG Sessions (LuxAlgo)
0
International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo
//@version=5
indicator("FVG Sessions [LuxAlgo]", overlay = true, max_lines_count = 500,
max_boxes_count = 500)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
bullCss = input.color(color.teal, 'FVG Level' , inline =
'bull')
bullAreaCss = input.color(color.new(color.teal, 50), 'Area' , inline =
'bull')
bullMitigatedCss = input.color(color.new(color.teal, 80), 'Mitigated', inline =
'bull')
//-----------------------------------------------------------------------------}
//UDT's
//-----------------------------------------------------------------------------{
type fvg
float top
float btm
bool mitigated
bool isnew
bool isbull
line lvl
box area
type session_range
line max
line min
//-----------------------------------------------------------------------------}
//Methods
//-----------------------------------------------------------------------------{
n = bar_index
id.lvl := avg_l
id.area := area
id.max.set_xy2(n, max)
id.max.set_y1(max)
id.min.set_xy2(n, min)
id.min.set_y1(min)
//-----------------------------------------------------------------------------}
//Variables
//-----------------------------------------------------------------------------{
var chartCss = color.new(chart.fg_color, 50)
//Alert conditions
bull_isnew = false
bear_isnew = false
bull_mitigated = false
bear_mitigated = false
within_bull_fvg = false
within_bear_fvg = false
//-----------------------------------------------------------------------------}
//New session
//-----------------------------------------------------------------------------{
dtf = timeframe.change('D')
sfvg.isnew := true
//Set range
else if not na(sesr)
sesr.set_range()
//Set range lines color
sesr.max.set_color(sfvg.isbull ? bullCss : bearCss)
sesr.min.set_color(sfvg.isbull ? bullCss : bearCss)
//-----------------------------------------------------------------------------}
//Set FVG
//-----------------------------------------------------------------------------{
//New session bullish fvg
if bull_fvg and sfvg.isnew
sfvg := fvg.new(low, high[2], false, false, true)
sfvg.set_fvg(2, bullAreaCss, bullCss)
bull_isnew := true
bear_isnew := true
sfvg.mitigated := true
bull_mitigated := true
sfvg.mitigated := true
bear_mitigated := true
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
//On new session fvg
alertcondition(bull_isnew, 'Bullish FVG', 'New session bullish fvg')
alertcondition(bear_isnew, 'Bearish FVG', 'New session bearish fvg')
alertcondition(close >= sfvg.btm and close <= sfvg.top and not sfvg.isbull and not
sfvg.isnew
, 'Price Within Bearish FVG'
, 'Price is within bearish fvg')
//-----------------------------------------------------------------------------}