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)