PINE LIBRARY
已更新 MaidongFVGLibrary

## Title
`Maidong FVG Library`
## Short Description
Reusable Pine library for detecting and optionally rendering multi-timeframe imbalance zones with midpoint mitigation and pressure overlays.
## Full Description
This library provides a compact API for working with multi-timeframe imbalance zones inside other TradingView indicators.
Core capabilities:
- Detects bullish and bearish imbalance zones from a selectable source timeframe
- Applies a displacement filter using the relationship between candle body size and a smoothed body baseline
- Uses confirmed source-timeframe data for stable MTF evaluation
- Optionally draws active zones directly from the library
- Supports midpoint or full-fill mitigation logic
- Can render midpoint guides and directional pressure slices inside each active zone
- Returns the latest active bullish and bearish zone levels for downstream logic
The library is intended for indicator authors who want reusable imbalance-zone logic without embedding a full standalone chart tool in every script.
## Exported Function
### `scanImbalanceZones(...)`
```pine
import username/MaidongFVGLibrary/1 as iz
[newBullish, bullishStartTime, bullishUpper, bullishLower, bullishMidpoint,
newBearish, bearishStartTime, bearishUpper, bearishLower, bearishMidpoint,
bullishActiveCount, bearishActiveCount] =
iz.scanImbalanceZones(
sourceTimeframe,
displacementFactor,
mitigateAtMidpoint,
projectionBars,
drawBullish,
drawBearish,
drawMidpoint,
drawPressure,
bullishPressureColor,
bearishPressureColor,
zoneColor)
```
## Parameters
- `sourceTimeframe`: Timeframe used to evaluate imbalance conditions. Use `""` to use the chart timeframe.
- `displacementFactor`: Minimum body-strength multiplier relative to the smoothed body baseline.
- `mitigateAtMidpoint`: When `true`, a zone is cleared after price reaches its midpoint. When `false`, full fill is required.
- `projectionBars`: Number of chart bars used to project the rendered zone forward in time.
- `drawBullish`: Draw bullish zones.
- `drawBearish`: Draw bearish zones.
- `drawMidpoint`: Draw a dashed midpoint line inside each rendered zone.
- `drawPressure`: Draw directional pressure slices inside each rendered zone.
- `bullishPressureColor`: Color used for the upper demand slice.
- `bearishPressureColor`: Color used for the lower supply slice.
- `zoneColor`: Base fill and border color for the full zone.
## Return Values
The function returns 12 values:
1. `newBullish`
2. `bullishStartTime`
3. `bullishUpper`
4. `bullishLower`
5. `bullishMidpoint`
6. `newBearish`
7. `bearishStartTime`
8. `bearishUpper`
9. `bearishLower`
10. `bearishMidpoint`
11. `bullishActiveCount`
12. `bearishActiveCount`
These values let the caller build alerts, filters, dashboards, or custom drawings without reimplementing the zone engine.
## Detection Model
Bullish zone:
- current low is above the high from two source bars back
- current close remains above that earlier high
- body size is at least `displacementFactor` times the smoothed body baseline
- evaluation uses confirmed source-timeframe bars
Bearish zone:
- current high is below the low from two source bars back
- current close remains below that earlier low
- body size is at least `displacementFactor` times the smoothed body baseline
- evaluation uses confirmed source-timeframe bars
## Publishing Notes
- Publish as a `Library`
- Add enough `max_boxes_count` and `max_lines_count` in consuming scripts
- If your published script uses the drawing options, mention that the library manages visual objects internally
## Suggested Release Notes
`v1`
- Initial public release
- Added reusable multi-timeframe imbalance-zone scanning
- Added optional midpoint and pressure rendering
- Added active-zone return values for downstream indicators
`Maidong FVG Library`
## Short Description
Reusable Pine library for detecting and optionally rendering multi-timeframe imbalance zones with midpoint mitigation and pressure overlays.
## Full Description
This library provides a compact API for working with multi-timeframe imbalance zones inside other TradingView indicators.
Core capabilities:
- Detects bullish and bearish imbalance zones from a selectable source timeframe
- Applies a displacement filter using the relationship between candle body size and a smoothed body baseline
- Uses confirmed source-timeframe data for stable MTF evaluation
- Optionally draws active zones directly from the library
- Supports midpoint or full-fill mitigation logic
- Can render midpoint guides and directional pressure slices inside each active zone
- Returns the latest active bullish and bearish zone levels for downstream logic
The library is intended for indicator authors who want reusable imbalance-zone logic without embedding a full standalone chart tool in every script.
## Exported Function
### `scanImbalanceZones(...)`
```pine
import username/MaidongFVGLibrary/1 as iz
[newBullish, bullishStartTime, bullishUpper, bullishLower, bullishMidpoint,
newBearish, bearishStartTime, bearishUpper, bearishLower, bearishMidpoint,
bullishActiveCount, bearishActiveCount] =
iz.scanImbalanceZones(
sourceTimeframe,
displacementFactor,
mitigateAtMidpoint,
projectionBars,
drawBullish,
drawBearish,
drawMidpoint,
drawPressure,
bullishPressureColor,
bearishPressureColor,
zoneColor)
```
## Parameters
- `sourceTimeframe`: Timeframe used to evaluate imbalance conditions. Use `""` to use the chart timeframe.
- `displacementFactor`: Minimum body-strength multiplier relative to the smoothed body baseline.
- `mitigateAtMidpoint`: When `true`, a zone is cleared after price reaches its midpoint. When `false`, full fill is required.
- `projectionBars`: Number of chart bars used to project the rendered zone forward in time.
- `drawBullish`: Draw bullish zones.
- `drawBearish`: Draw bearish zones.
- `drawMidpoint`: Draw a dashed midpoint line inside each rendered zone.
- `drawPressure`: Draw directional pressure slices inside each rendered zone.
- `bullishPressureColor`: Color used for the upper demand slice.
- `bearishPressureColor`: Color used for the lower supply slice.
- `zoneColor`: Base fill and border color for the full zone.
## Return Values
The function returns 12 values:
1. `newBullish`
2. `bullishStartTime`
3. `bullishUpper`
4. `bullishLower`
5. `bullishMidpoint`
6. `newBearish`
7. `bearishStartTime`
8. `bearishUpper`
9. `bearishLower`
10. `bearishMidpoint`
11. `bullishActiveCount`
12. `bearishActiveCount`
These values let the caller build alerts, filters, dashboards, or custom drawings without reimplementing the zone engine.
## Detection Model
Bullish zone:
- current low is above the high from two source bars back
- current close remains above that earlier high
- body size is at least `displacementFactor` times the smoothed body baseline
- evaluation uses confirmed source-timeframe bars
Bearish zone:
- current high is below the low from two source bars back
- current close remains below that earlier low
- body size is at least `displacementFactor` times the smoothed body baseline
- evaluation uses confirmed source-timeframe bars
## Publishing Notes
- Publish as a `Library`
- Add enough `max_boxes_count` and `max_lines_count` in consuming scripts
- If your published script uses the drawing options, mention that the library manages visual objects internally
## Suggested Release Notes
`v1`
- Initial public release
- Added reusable multi-timeframe imbalance-zone scanning
- Added optional midpoint and pressure rendering
- Added active-zone return values for downstream indicators
版本注释
v2版本注释
v3版本注释
v4已添加:
scanLegacyFVGState(sourceTimeframe, displacementFactor)
Parameters:
sourceTimeframe (string)
displacementFactor (float)
版本注释
v5Pine脚本库
秉承TradingView的精神,作者已将此Pine代码作为开源库发布,以便我们社区的其他Pine程序员可以重用它。向作者致敬!您可以私下或在其他开源出版物中使用此库,但在出版物中重用此代码须遵守网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
Pine脚本库
秉承TradingView的精神,作者已将此Pine代码作为开源库发布,以便我们社区的其他Pine程序员可以重用它。向作者致敬!您可以私下或在其他开源出版物中使用此库,但在出版物中重用此代码须遵守网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。