PINE LIBRARY
Zaktualizowano

PDArrays

482
Library "PDArrays"

Hi all!

This library will help you to draw fair value gaps and order blocks and their broken version; breaker blocks, mitigation blocks and inversion fair value gaps.

It does not contain any example code, but I will create an indicator called 'PD Arrays' that uses this library.

Best of luck trading!

Remove(zones, settings)
  Removes the zone in 'zones.Remove' and its visuals. The visuals will be kept if 'settings.KeepHistoryZones' is true.
  Parameters:
    zones (Zones): The current zone.
    settings (Settings): Set all values in this parameter to define the settings for the zones.

Interactions(zones, settings, trend)
  Sets the interactions (retests\false breakouts\breakouts) from the library 'Touched'.
  Parameters:
    zones (array<Zone>)
    settings (Settings): set all values in this parameter to define the settings for the order block creation.
    trend (int): the market structure trend that's used for the integrations direction. 1 = bullish, -1 = bearish, 0 = both.

HiddenInteractions(zones, settings, marketStructureInfo, trend)
  Sets the hidden interactions (only breakouts) from the library 'Touched'.
  Parameters:
    zones (Zones)
    settings (Settings): set all values in this parameter to define the settings for the order block creation.
    marketStructureInfo (MarketStructureInfo): The state of market structure needed.
    trend (int): the market structure trend that's used for the integrations direction. 1 = bullish, -1 = bearish, 0 = both.

Pivots(settings)
  Creates pivots (high and low) to be used for order block creation.
  Parameters:
    settings (Settings): set all values in this parameter to define the settings for the order block creation.
  Returns: a tuple containing two pivot values (high and low) or 'na'

OrderBlock(settings, pivotHigh, pivotLow)
  Creates an order block if one is found according to the settings parameter.
  Parameters:
    settings (Settings): set all values in this parameter to define the settings for the order block creation.
    pivotHigh (float): The high pivot to use.
    pivotLow (float): The low pivot to use.
  Returns: a Zone object if an order block is found, na otherwise

FairValueGap(settings)
  Creates a fair value gap if one is found according to the settings parameter.
  Parameters:
    settings (Settings): set all values in this parameter to define the settings for the fair value gap creation.
  Returns: a Zone object if a fair value gap is found, na otherwise

SetBarIndex(zone)
  Sets the 'BarIndex' value of the 'zone' object according to 'zone.ChartBaseTime'.
  Parameters:
    zone (Zone): The 'Zone' object to set the bar index on.

MarketStructureZones(marketStructureInfo, foundZones, zones, priceAction, settings)
  Creates/draws zones (order blocks and fair value gaps) depending on the current market structure from the price action.
  Parameters:
    marketStructureInfo (MarketStructureInfo): The infirmation about the market structure from the price action.
    foundZones (array<Zone>): All zones (order blocks and fair value gaps) to take action on.
    zones (Zones): The 'Zones' object that holds the current context.
    priceAction (PriceAction type from mickes/PriceAction/5): The 'PriceAction.PriceAction' object from the library 'PriceAction'.
    settings (Settings): set all values in this parameter to define the settings for the fair value gap creation.

Visual
  Holds the visual elements or the zone.
  Fields:
    Boxes (array<box>): All the visual boxes.
    Lines (array<line>): All the visual lines.
    Labels (array<label>): All the visual labels.

Zone
  Holds the values for visuals for the zone and to handle interactions (retests, false breakouts and breakouts).
  Fields:
    BaseTimeClose (series int): The time close for the start of the zone.
    FoundTimeClose (series int): The time close for the zone when it's found.
    ChartBaseTime (series int): The time for the start of the zone according to the chart bar.
    High (series float): The maximimum price of the zone.
    Low (series float): The minimum price of the zone.
    ReactionLimit (series float): Set a factor (%) of the Average True Range (of length 14) that the total reaction must have.
    TouchedZone (Zone type from mickes/Touched/17): Zone object that will be created and sent to the library 'Touched'.
    Visual (Visual): An object that holds the visual elements for the zone.
    SourceTimeframeSeconds (series int): The 'timeframe.in_seconds' for the zone.
    Direction (series int): Defines if the found zone is bullish (1) or bearish (-1).
    LatestRetestBarIndex (series int): The latest 'bar_index' for a retest.
    LatestFalseBreakoutBarIndex (series int): The latest 'bar_index' for a false breakout.
    LatestBreakoutBarIndex (series int): The latest 'bar_index' for a breakout.
    BarIndex (series int): The chart's timeeframe 'bar_index'.
    OriginType (series Type): The 'Type' for the origin (order block or fair value gap).
    Type (series Type): The type of the zone.
    Visible (series bool): If the zone is drawn and not removed or re-drawn.

Zones
  Holds the values for the charts zones.
  Fields:
    Zones (array<Zone>): The currently active zones.
    Removes (array<Zone>): Reprsents the zones that will be replaced.
    HiddenZones (array<Zone>): The currently hidden zones.

OrderBlockSettings
  The settings specific for order block creation.
  Fields:
    TakeOut (series bool): If the bas candle needs to be higher\lower than the previous candle (liquidity sweep\grab).
    FairValueGap (series bool): If there needs o be a fair value gap between the first and the last (third) candle of the order block.
    ConsecutiveRisingOrFalling (series bool): The candles in the reaction must consecutivly rise or fall (the 'hl2' must be rising/falling).
    ReactionFactor (series float): A factor of the Average True Range (of length 14) that the total reaction must have. A higher value will create fewer zones with a bigger reaction. And check the checkbox if you want the limit to be displayed.
    ShowReaction (series bool): Show a solid line for the reaction limit.
    HideConsecutiveZones (series bool): If multiple order blocks are found after each other only the first one will be found by the indicator.

FairValueGapSettings
  The settings specific for fair value gap creation.
  Fields:
    ConsecutiveRisingOrFalling (series bool): The candles in the reaction must consecutivly rise or fall (the 'hl2' must be rising/falling).
    Strong (series bool): If this is enabled it will force the FVG middle candle to have a higher/lower 'hl2' (middle of the entire candle) than the first candle's high.
    HideConsecutiveZones (series bool): If multiple order blocks are found after each other only the first one will be found by the indicator.
    MinimumSizeFactor (series float): A factor of the Average True Range (of length 14) that the size of the fair value gap must have.

Settings
  The settings for the creation of order blocks and fair value gaps. You will need to set all the containing values in here.
  Fields:
    KeepHistoryZones (series bool): Set to true if you want removed (from previous trend) zones to be displayed.
    Bull (series color): The color of bullish zones.
    Bear (series color): The color of bearish zones.
    CreateCreationZone (series bool): Set to true if you want a box with a border to be drawn at the creation of the zone. This is usefull when the zones comes from a higher timeframe, but not from a lower. If this is false the 'Draw()' function will start at 'time - time_close'.
    AlertRetests (series bool): Enable if you want alerts to fire when the 'Touched' library signals that a retest of the order block has occured.
    AlertFalseBreakouts (series bool): Enable if you want alerts to fire when the 'Touched' library signals that a false breakout of the order block has occured.
    AlertBreakouts (series bool): Enable if you want alerts to fire when the 'Touched' library signals that a breakout of the order block has occured.
    AlertMessageFormat (series string): Set the format of the fired alert uppon 'Touched' library signals. Need to be in the format of '{0} on order block from ...' where '{0}' is replaced with 'retest', 'false breakout' or 'breakout'.
    Types (array<Type>): All types that should be displayed.
    FairValueGapSettings (FairValueGapSettings): The settings for the creation of fair value gaps.
    OrderBlockSettings (OrderBlockSettings): The settings for the creation of order blocks.

MarketStructurePivot
  Pivot The 'PriceAction.Pivot' for the market structure.
  Fields:
    BrokenBarIndex (series int)
    Pivot (Pivot type from mickes/PriceAction/5)

MarketStructureInfo
  Holds the needed market structure pivots needed for this library.
  Fields:
    LatestBreakOfStructure (MarketStructurePivot): The latest break of structure (BOS) found by the 'PriceAction' library.
    LatestChangeOfCharacter (MarketStructurePivot): The latest change of character (CHoCH\CHoCH+) found by the 'PriceAction' library.
Informacje o Wersji
v2

- Add support for incalidating zon creation of no turtle soup has happened during the trend change.

Added:
InvalidateIfNoTurtleSoup(turtleSoupsContext, marketStructureInfo, foundZones, priceAction)
  Invalidates the zone for creation if no turtle soup has happend between the CHoCH/CHoCH+ pivot and the bar that caused the change of trend.
  Parameters:
    turtleSoupsContext (TurtleSoups type from mickes/PriceAction/7): The context for current turtle soup price action.
    marketStructureInfo (MarketStructureInfo): The infirmation about the market structure from the price action.
    foundZones (array<Zone>): All zones (order blocks and fair value gaps) to take action on.
    priceAction (PriceAction type from mickes/PriceAction/7): The 'PriceAction.PriceAction' object from the library 'PriceAction'.

Updated:
MarketStructureZones(marketStructureInfo, foundZones, zones, priceAction, settings)
  Creates/draws zones (order blocks and fair value gaps) depending on the current market structure from the price action.
  Parameters:
    marketStructureInfo (MarketStructureInfo): The infirmation about the market structure from the price action.
    foundZones (array<Zone>): All zones (order blocks and fair value gaps) to take action on.
    zones (Zones): The 'Zones' object that holds the current context.
    priceAction (PriceAction type from mickes/PriceAction/7): The 'PriceAction.PriceAction' object from the library 'PriceAction'.
    settings (Settings): set all values in this parameter to define the settings for the fair value gap creation.

Zone
  Holds the values for visuals for the zone and to handle interactions (retests, false breakouts and breakouts).
  Fields:
    BaseTimeClose (series int): The time close for the start of the zone.
    FoundTimeClose (series int): The time close for the zone when it's found.
    ChartBaseTime (series int): The time for the start of the zone according to the chart bar.
    High (series float): The maximimum price of the zone.
    Low (series float): The minimum price of the zone.
    ReactionLimit (series float): Set a factor (%) of the Average True Range (of length 14) that the total reaction must have.
    TouchedZone (Zone type from mickes/Touched/17): Zone object that will be created and sent to the library 'Touched'.
    Visual (Visual): An object that holds the visual elements for the zone.
    SourceTimeframeSeconds (series int): The 'timeframe.in_seconds' for the zone.
    Direction (series int): Defines if the found zone is bullish (1) or bearish (-1).
    LatestRetestBarIndex (series int): The latest 'bar_index' for a retest.
    LatestFalseBreakoutBarIndex (series int): The latest 'bar_index' for a false breakout.
    LatestBreakoutBarIndex (series int): The latest 'bar_index' for a breakout.
    BarIndex (series int): The chart's timeeframe 'bar_index'.
    OriginType (series Type): The 'Type' for the origin (order block or fair value gap).
    Type (series Type): The type of the zone.
    Visible (series bool): If the zone is drawn and not removed or re-drawn.
    Invalid (series bool): Tells if the zone is valid for creation or not.

MarketStructurePivot
  Pivot The 'PriceAction.Pivot' for the market structure.
  Fields:
    BrokenBarIndex (series int)
    Pivot (Pivot type from mickes/PriceAction/7)
Informacje o Wersji
v3

- Be able to set the intended direction, if the trend is not as the 'Direction' enumeration it vill be invalidated.

Added:
InvalidateIfWrongDirection(foundZones, direction, trend)
  Invalidates the zone for creation if the market structur trend is wrong.
  Parameters:
    foundZones (array<Zone>): All zones (order blocks and fair value gaps) to take action on.
    direction (series Direction): If the trend has has the wrong direction according to this enumeration it will be invalidated.
    trend (int): The market structure trend.
Informacje o Wersji
v4
- rename the type 'Zones'->'Context'
- Introduce the concept of confirmation pivots that's pivots after a CHiCH/CHoCH+ cointaing a turtle soup that lets the zones after this pivot is found to be invalidated.
Informacje o Wersji
v5

- Change alert text to suit integrated zone
- Add possibility for statistics with 'Statistics' containing statistics for trades through 'Trades'
Informacje o Wersji
v6

- Add 'Source' to all trades and 'SourceInt' to be able to screen for different sources.
- Mitigate error when alert is enabled for false breakouts.
- Add deepest retracement in 'MarketStructureInfo'
- This is combinable with a bump of the 'PriceAction' library containing the deepest pullbacks for turtle soups.

Added:
DeepestRetracement(from, t_o, trend)
  Tells you the deepest (lowest/highest) price counter trend.
  Parameters:
    from (int): The bar_index to start with.
    t_o (int): The bar_index to end with.
    trend (int): The market structure trend that's used to find the deepest pullback. 1 = bullish, -1 = bearish, 0 = both.

Updated:
MarketStructureZones(marketStructureInfo, foundZones, context, priceAction, settings)
  Creates/draws zones (order blocks and fair value gaps) depending on the current market structure from the price action.
  Parameters:
    marketStructureInfo (MarketStructureInfo): The infirmation about the market structure from the price action.
    foundZones (array<Zone>): All zones (order blocks and fair value gaps) to take action on.
    context (Context)
    priceAction (PriceAction type from mickes/PriceAction/9): The 'PriceAction.PriceAction' object from the library 'PriceAction'.
    settings (Settings): set all values in this parameter to define the settings for the fair value gap creation.

InvalidateIfNoTurtleSoup(turtleSoupsContext, marketStructureInfo, foundZones, priceAction)
  Invalidates the zone for creation if no turtle soup has happend between the CHoCH/CHoCH+ pivot and the bar that caused the change of trend.
  Parameters:
    turtleSoupsContext (TurtleSoups type from mickes/PriceAction/9): The context for current turtle soup price action.
    marketStructureInfo (MarketStructureInfo): The infirmation about the market structure from the price action.
    foundZones (array<Zone>): All zones (order blocks and fair value gaps) to take action on.
    priceAction (PriceAction type from mickes/PriceAction/9): The 'PriceAction.PriceAction' object from the library 'PriceAction'.

SetConfirmationPivots(context, settings, pivotHigh, pivotLow)
  Sets the found confirmation pivots in 'context'.
  Parameters:
    context (Context): The 'Context' object for PD Arrays.
    settings (ConfirmationPivotSettings): The 'ConfirmationPivotSettings' object that's used.
    pivotHigh (Pivot type from mickes/PriceAction/9): The high pivot.
    pivotLow (Pivot type from mickes/PriceAction/9): T=e low pivot.

Trade
  A statistically informational trade that's openned upon an integration.
  Fields:
    Entry (series float): The entry price of the trade.
    StopLoss (series float): The stop loss price of the trade.
    EntryBarIndex (series int): The 'bar_index' upon entry.
    Source (series Type): The source type that caused the trade.
    SourceInt (series int): An integer representing the source type (this is usefull in the Pine Screener). Fair value gap = 1, order block = 2, inversion fair value gap = 3, breaker block = 4 and mitigation block = 5.
    ProfitPrice (series float): The current highest (for long trades) or lowest (for short trades) that's used to calculate 'Profit' that's a maximum profit bassed on the risk (risk/reward).
    StopLossHit (series bool): If price has reached the stop loss or not.
    Profit (series float): A risk/reward value that's based on maximum 'ProfitPrice' and the difference between entry and stop loss.
    TrailingStopLossHit (series bool): If the market structure trailing stop loss is hit (the trend has changed).
    ProfitIfTrailingStopLoss (series float): The estimated profit if a market structure trailing stop would have been used.

Context
  Holds the values for the charts context.
  Fields:
    Zones (array<Zone>): The currently active context.
    Removes (array<Zone>): Reprsents the zones that will be replaced.
    HiddenZones (array<Zone>): The currently hidden zones.
    ConfirmationHighPivots (array<Pivot> type from mickes/PriceAction/9)
    ConfirmationLowPivots (array<Pivot> type from mickes/PriceAction/9)
    Statistics (Statistics): The statistics for the current context.

TurtleSoupInfo
  Holds contextual information about price action turtle soups.
  Fields:
    LatestTurtleSoupEndBarIndex (series int)
    FirstConfirmationPivotLow (Pivot type from mickes/PriceAction/9)
    FirstConfirmationPivotHigh (Pivot type from mickes/PriceAction/9)

MarketStructurePivot
  Holds the state needed from the 'PriceAction' library for the market structure.
  Fields:
    BrokenBarIndex (series int): The 'bar_index' that the 'Pivot' was broken by price.
    Pivot (Pivot type from mickes/PriceAction/9): The 'PriceAction.Pivot' for the market structure.
    DeepestRetracement (series float)
Informacje o Wersji
v7

- Add formed during rising/falling price for alerts.
-Remove ability to alert for breakouts

Updated:
Interactions(context, settings, trend, marketStructureInfo)
  Sets the interactions (retests\false breakouts\breakouts) from the library 'Touched'. Also enter a trade if the specific integration has alerts enabled.
  Parameters:
    context (Context): The entire context for current PD Arrays.
    settings (Settings): set all values in this parameter to define the settings for the order block creation.
    trend (int): the market structure trend that's used for the integrations direction. 1 = bullish, -1 = bearish, 0 = both.
    marketStructureInfo (MarketStructureInfo): The state of market structure needed.

DeepestRetracement(from, t_o, trend)
  Tells you the deepest (lowest/highest) price counter trend.
  Parameters:
    from (int): The bar_index to start with.
    t_o (int): The bar_index to end with.
    trend (int): The market structure trend that's used to find the deepest pullback. 1 = bullish, -1 = bearish, 0 = both.
  Returns: A tuple with the deepest pullback and the bar_index.

Settings
  The settings for the creation of order blocks and fair value gaps. You will need to set all the containing values in here.
  Fields:
    KeepHistoryZones (series bool): Set to true if you want removed (from previous trend) zones to be displayed.
    Bull (series color): The color of bullish context.
    Bear (series color): The color of bearish context.
    CreateCreationZone (series bool): Set to true if you want a box with a border to be drawn at the creation of the zone. This is usefull when the zones comes from a higher timeframe, but not from a lower. If this is false the 'Draw()' function will start at 'time - time_close'.
    AlertRetests (series bool): Enable if you want alerts to fire when the 'Touched' library signals that a retest of the order block has occured.
    AlertFalseBreakouts (series bool): Enable if you want alerts to fire when the 'Touched' library signals that a false breakout of the order block has occured.
    Types (array<Type>): All types that should be displayed.
    FairValueGapSettings (FairValueGapSettings): The settings for the creation of fair value gaps.
    OrderBlockSettings (OrderBlockSettings): The settings for the creation of order blocks.
    ConfirmationPivotSettings (ConfirmationPivotSettings): The settings for confirmation pivots.
    StatisticsSettings (StatisticsSettings): The settings for statistics.

MarketStructurePivot
  Holds the state needed from the 'PriceAction' library for the market structure.
  Fields:
    BrokenBarIndex (series int): The 'bar_index' that the 'Pivot' was broken by price.
    Pivot (Pivot type from mickes/PriceAction/9): The 'PriceAction.Pivot' for the market structure.
    DeepestRetracement (series float): The deepest retracement before the structure break.
    DeepestRetracementBarIndex (series int): The deepest retracement bar index before the structure break.
Informacje o Wersji
v8

- Add possibility to revalidate zones that have been invalidated because of the wrong direction.

Added:
RevalidateIfRightDirection(foundZones, direction, trend, earliest)
  Revalidates the zones efter 'earliest' for creation if the market structur trend is right now.
  Parameters:
    foundZones (array<Zone>): All zones (order blocks and fair value gaps) to take action on.
    direction (series Direction): If the trend has has the wrong direction according to this enumeration it will be invalidated.
    trend (int): The market structure trend.
    earliest (int): The earliest bar_index for revalidation (the base pivot for the CHoCH).

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.