PINE LIBRARY

lib_statemachine_modified

Library "lib_statemachine_modified"

Modified to fix bugs and create getState and priorState methods.

method step(this, before, after, condition)
  Namespace types: StateMachine
  Parameters:
    this (StateMachine)
    before (int): (int): Current state before transition
    after (int): (int): State to transition to
    condition (bool): (bool): Condition to trigger the transition
  Returns: (bool): True if the state changed, else False

method step(this, after, condition)
  Namespace types: StateMachine
  Parameters:
    this (StateMachine)
    after (int): (int): State to transition to
    condition (bool): (bool): Condition to trigger the transition
  Returns: (bool): True if the state changed, else False

method currentState(this)
  Namespace types: StateMachine
  Parameters:
    this (StateMachine)

method previousState(this)
  Namespace types: StateMachine
  Parameters:
    this (StateMachine)

method changed(this, within_bars)
  Namespace types: StateMachine
  Parameters:
    this (StateMachine)
    within_bars (int): (int): Number of bars to look back for a state change
  Returns: (bool): True if a state change occurred within the timeframe, else False

method reset(this, condition, min_occurrences)
  Namespace types: StateMachine
  Parameters:
    this (StateMachine)
    condition (bool): (bool): Condition to trigger the reset
    min_occurrences (int): (int): Minimum number of times the condition must be true to reset
  Returns: (bool): True if the state was reset, else False

StateMachine
  Fields:
    state (series int)
    neutral (series int)
    enabled (series bool)
    reset_counter (series int)
    prior_state (series int)
    last_change_bar (series int)
statestrategies

Pine腳本庫

在真正的TradingView精神中,作者將這段Pine程式碼發佈為開源程式庫,以便我們社群的其他Pine程式設計師可以重複使用它。請向作者致敬!您可以私下使用這個函式庫,或在其他開源出版品中使用,但在出版物中再次使用這段程式碼將受到網站規則的約束。

免責聲明