PINE LIBRARY
Actualizado 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
Notas de prensa
v2Notas de prensa
v3Notas de prensa
v4已添加:
scanLegacyFVGState(sourceTimeframe, displacementFactor)
Parameters:
sourceTimeframe (string)
displacementFactor (float)
Notas de prensa
v5Biblioteca Pine
Fiel al espíritu de TradingView, el autor ha publicado este código de Pine como biblioteca de código abierto, para que otros programadores de nuestra comunidad puedan reutilizarlo. ¡Enhorabuena al autor! Puede usar esta biblioteca de forma privada o en otras publicaciones de código abierto, pero su reutilización en publicaciones está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Biblioteca Pine
Fiel al espíritu de TradingView, el autor ha publicado este código de Pine como biblioteca de código abierto, para que otros programadores de nuestra comunidad puedan reutilizarlo. ¡Enhorabuena al autor! Puede usar esta biblioteca de forma privada o en otras publicaciones de código abierto, pero su reutilización en publicaciones está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.