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)
Libreria Pine

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzare questa libreria in privato o all'interno di altre pubblicazioni open-source, ma il riutilizzo del codice è subordinato al rispetto del Regolamento.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questa libreria?

Copia il testo ed incollalo nel tuo script.