PINE LIBRARY

MarketStructure

Atualizado
Library "MarketStructure"
Will draw out the market structure for the disired pivot length. The code is from my indicator "Marker structure" (tradingview.com/script/ud6AQSm2-Market-structure/).

Create(type, length, source, equalPivotsFactor, extendEqualPivotsZones, equalPivotsStyle, equalPivotsColor, alertFrequency)
  Call on each bar. Will create a Structure object.
  Parameters:
    type (int): the type of the Structure to create. 0 = internal, 1 = swing.
    length (int): The lenghts (left and right) for pivots to use.
    source (string): The source to be used for structural changes ('Close', 'High/low (aggresive)' (low in an uptrend) or 'High/low (passive)' (high in an uptrend)).
    equalPivotsFactor (float): Set how the limits are for an equal pivot. This is a factor of the Average True Length (ATR) of length 14. If a low pivot is considered to be equal if it doesn't break the low pivot (is at a lower value) and is inside the previous low pivot + this limit.
    extendEqualPivotsZones (bool): Set to true if you want the equal pivots zones to be extended.
    equalPivotsStyle (string): Set the style of equal pivot zones.
    equalPivotsColor (color): Set the color of equal pivot zones.
    alertFrequency (string)
  Returns: The 'structure' object.

Pivot(structure)
  Sets the pivots in the structure.
  Parameters:
    structure (Structure)
  Returns: The 'structure' object.

PivotLabels(structure)
  Draws labels for the pivots found.
  Parameters:
    structure (Structure)
  Returns: The 'structure' object.

EqualHighOrLow(structure)
  Draws the boxsa for equal highs/lows. Also creates labels for the pivots included.
  Parameters:
    structure (Structure)
  Returns: The 'structure' object.

BreakOfStructure(structure)
  Will create lines when a break of strycture occures.
  Parameters:
    structure (Structure)
  Returns: The 'structure' object.

ChangeOfCharacter(structure)
  Will create lines when a change of character occures.
  Parameters:
    structure (Structure)
  Returns: The 'structure' object.

StructureBreak
  Holds drawings for a structure break.
  Fields:
    Line (series line): The line object.
    Label (series label): The label object.

Pivot
  Holds all the values for a found pivot.
  Fields:
    Price (series float): The price of the pivot.
    BarIndex (series int): The bar_index where the pivot occured.
    Type (series int): The type of the pivot (-1 = low, 1 = high).
    ChangeOfCharacterBroken (series bool): Sets to true if a change of character has happened.
    BreakOfStructureBroken (series bool): Sets to true if a break of structure has happened.

Structure
  Holds all the values for the market structure.
  Fields:
    Length (series int): Define the left and right lengths of the pivots used.
    Type (series int): Set the type of the market structure. Two types can be used, 'internal' and 'swing' (0 = internal, 1 = swing).
    Trend (series int): This will be set internally and can be -1 = downtrend, 1 = uptrend.
    Source (series string): Set the source for structural chandeg. Can be 'Close', 'High/low (aggresive)' (low in an uptrend) or 'High/low (passive)' (high in an uptrend).
    EqualPivotsFactor (series float): Set how the limits are for an equal pivot. This is a factor of the Average True Length (ATR) of length 14. If a low pivot is considered to be equal if it doesn't break the low pivot (is at a lower value) and is inside the previous low pivot + this limit.
    ExtendEqualPivotsZones (series bool): Set to true if you want the equal pivots zones to be extended.
    ExtendEqualPivotsStyle (series string): Set the style of equal pivot zones.
    ExtendEqualPivotsColor (series color): Set the color of equal pivot zones.
    EqualHighs (array<box>): Holds the boxes for zones that contains equal highs.
    EqualLows (array<box>): Holds the boxes for zones that contains equal lows.
    BreakOfStructures (array<StructureBreak>): Holds all the break of structures within the trend (before a change of character).
    Pivots (array<Pivot>): All the pivots in the current trend, added with the latest first, this is cleared when the trend changes.
    AlertFrequency (series string): set the frequency for alerts.
Notas de Lançamento
v2

- Remove faultly commited 'AlertFrequency'
Notas de Lançamento
v3

- Mitigate error of removal of previous break of structure if a later pivot is not broken.
- Remove unused code
displaymarketstructurepriceaction

Biblioteca do Pine

De acordo com o verdadeiro espírito do TradingView, o autor publicou esse código Pine como uma biblioteca de código aberto para que outros programadores Pine de nossa comunidade possam reutilizá-lo. Parabéns ao autor! Você pode usar essa biblioteca de forma privada ou em outras publicações de código aberto, mas a reutilização desse código em uma publicação é regida pelas Regras da Casa.

Aviso legal