Pine mitigated FVG - Stack Overflow

I created a FVG detector but I would like to change the color of the box (gray) after the gap is 50% mi

I created a FVG detector but I would like to change the color of the box (gray) after the gap is 50% mitigated (price revisit). also I would like to extend the box (for n bars) until the FVG is mitigated

` //@version=5 indicator("FVG Detector", overlay=true)

// Highlight FVG areas 
var float fvgUpStart = na
var float fvgUpEnd = na
var float fvgDownStart = na
var float fvgDownEnd = na
var box boxUp = na
var box boxDown = na

// Function to detect Fair Value Gaps (FVG)
fvgUp = ta.highest(high[2], 1) < low[0]
fvgDown = ta.lowest(low[2], 1) > high[0]

// Calculate 50% level of FVGs
var float fvgUpMid = na
var float fvgDownMid = na
if fvgUp
    fvgUpMid := (high[2] + low[0]) / 2
if fvgDown
    fvgDownMid := (low[2] + high[0]) / 2

// Define mitigation check (mitigated when 50% is filled)
mitigatedUp = fvgUp and ta.lowest(low, 2) <= fvgUpMid
mitigatedDown = fvgDown and ta.highest(high, 2) >= fvgDownMid

// Plot FVG zones
fvgUpColor = mitigatedUp ? color.gray : color.green
fvgDownColor = mitigatedDown ? color.gray : color.red

if fvgUp
    fvgUpStart := high[2]
    fvgUpEnd := low[0]
        
    boxUp := box.new(left=bar_index[2], right=bar_index, top=fvgUpStart, 
    bottom=fvgUpEnd, bgcolor=color.new(fvgUpColor, 80), border_width = 0)
    
if fvgDown
    fvgDownStart := low[2]
    fvgDownEnd := high[0]
    
    boxDown := box.new(left=bar_index[2], right=bar_index, top=fvgDownEnd, 
    bottom=fvgDownStart, bgcolor=color.new(fvgDownColor, 80),border_width = 0)

// Change box color if mitigated
if mitigatedUp
    box.set_bgcolor(boxUp, color.new(color.gray, 80))
if mitigatedDown
    box.set_bgcolor(boxDown, color.new(color.gray, 80))
// Alerts for FVG mitigation

`

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744282109a4566619.html

相关推荐

  • Pine mitigated FVG - Stack Overflow

    I created a FVG detector but I would like to change the color of the box (gray) after the gap is 50% mi

    7天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信