robbatt

lib_statemachine

Library "lib_statemachine"
simple state machine that allows tracking a state an manipulating it with conditions

method step(this, before, after, condition)
  will step the state of the state machine from one to the next in case of condition
  Namespace types: StateMachine
  Parameters:
    this (StateMachine): (StateMachine) the state machine to use
    before (int): (int) from state
    after (int): (int) to state
    condition (bool): (bool) if condition is true
  Returns: true (bool) if the state of the statemachine changed

method step(this, after, condition)
  will change the state of the state machine to the next in case of condition (not depending on previous state)
  Namespace types: StateMachine
  Parameters:
    this (StateMachine): (StateMachine) the state machine to use
    after (int): (int) to state
    condition (bool): (bool) if condition is true
  Returns: true (bool) if the state of the statemachine changed

method changed(this, within_bars)
  will return true if the state of the state machine was changed in this iteration
  Namespace types: StateMachine
  Parameters:
    this (StateMachine): (StateMachine) the state machine to use
    within_bars (int)
  Returns: true (bool) if the state of the statemachine changed

method reset(this, condition, min_occurrences)
  will reset the state machine if a certain 'condition' appears 'min_occurrences' times
  Namespace types: StateMachine
  Parameters:
    this (StateMachine): (StateMachine) the state machine to use
    condition (bool): (bool) reset condition
    min_occurrences (int): (int) min times 'condition' must appear for the reset to happen
  Returns: true (bool) if the state of the statemachine changed

StateMachine
  Fields:
    state (series__integer)
    neutral (series__integer)
    enabled (series__bool)
    reset_counter (series__integer)
Bibliothèque Pine

Dans le véritable esprit de TradingView, l'auteur a publié ce code Pine en tant que bibliothèque open-source afin que d'autres programmeurs Pine de notre communauté puissent le réutiliser. Bravo à l'auteur ! Vous pouvez utiliser cette bibliothèque à titre privé ou dans d'autres publications open-source, mais la réutilisation de ce code dans une publication est régie par notre Règlement.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser cette bibliothèque?

Copiez le texte dans le presse-papiers et collez-le dans votre script.