WhiteboxSoftware

The Divergent Library

Library "TheDivergentLibrary"

The Divergent Library is only useful when combined with the Pro version of The Divergent - Advanced divergence indicator. This is because the Basic (free) version of The Divergent does not expose the "Divergence Signal" value.

Usage instructions:

1. Create a new chart
2. Add The Divergent (Pro) indicator to your chart
3. Create a new strategy, import this library, add a "source" input, link it to "The Divergent: Divergence Signal", and use the library to decode the divergence signals from The Divergent (You can find example strategy code published in our profile)
4. Act on the divergences signalled by The Divergent

---

isRegularBullishEnabled(context) Returns a boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
  Parameters:
    context: The context of The Divergent Library.
  Returns: A boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.

isHiddenBullishEnabled(context) Returns a boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
  Parameters:
    context: The context of The Divergent Library.
  Returns: A boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.

isRegularBearishEnabled(context) Returns a boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
  Parameters:
    context: The context of The Divergent Library.
  Returns: A boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.

isHiddenBearishEnabled(context) Returns a boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
  Parameters:
    context: The context of The Divergent Library.
  Returns: A boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.

getPivotDetectionSource(context) Returns the 'Pivot Detection Source' setting of The Divergent. The returned value can be either "Oscillator" or "Price".
  Parameters:
    context: The context of The Divergent Library.
  Returns: One of the following string values: "Oscillator" or "Price".

getPivotDetectionMode(context) Returns the 'Pivot Detection Mode' setting of The Divergent. The returned value can be either "Bodies" or "Wicks".
  Parameters:
    context: The context of The Divergent Library.
  Returns: One of the following string values: "Bodies" or "Wicks".

isLinked(context) Returns a boolean value indicating the link status to The Divergent indicator.
  Parameters:
    context: The context of The Divergent Library.
  Returns: A boolean value indicating the link status to The Divergent indicator.

init(firstBarSignal, displayLinkStatus, debug) Initialises The Divergent Library's context with the signal produced by The Divergent on the first bar. The value returned from this function is called the "context of The Divergent Library". Some of the other functions of this library requires you to pass in this context.
  Parameters:
    firstBarSignal: The signal from The Divergent indicator on the first bar.
    displayLinkStatus: A boolean value indicating whether the Link Status window should be displayed in the bottom left corner of the chart. Defaults to true.
    debug: A boolean value indicating whether the Link Status window should display debug information. Defaults to false.
  Returns: A bool array containing the context of The Divergent Library.

processSignal(signal) Processes a signal from The Divergent and returns a 5-tuple with the decoded signal: [int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd]. `divergenceType` can be one of the following values: na → No divergence was detected, 1 → Regular Bullish, 2 → Regular Bullish early, 3 → Hidden Bullish, 4 → Hidden Bullish early, 5 → Regular Bearish, 6 → Regular Bearish early, 7 → Hidden Bearish, 8 → Hidden Bearish early.
  Parameters:
    signal: The signal from The Divergent indicator.
  Returns: A 5-tuple with the following values: [int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd].

Experiment with popular trading strategies without risking your capital: whitebox.so

Get access to The Divergent Pro indicator at thedivergent.io
Библиотека Pine

В истинном духе TradingView автор опубликовал этот код Pine как библиотеку с открытым исходным кодом, чтобы другие разработчики Pine из нашего сообщества могли использовать его повторно. Поблагодарим автора! Вы можете использовать эту библиотеку приватно или в других публикациях с открытым исходным кодом, но повторное использование этого кода в публикации регулируется Правилами поведения.

Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.

Хотите использовать эту библиотеку?

Скопируйте текст в буфер обмена и вставьте в свой скрипт.