Docs  /  Builder Guide: State Machine Block

Fusion Builder State Machine Block – User Guide

Version: 1.0 Last Updated: January 25, 2026 For: Fusion Builder V1.0


Table of Contents

  1. What is a State Machine Block?
  2. When to Use State Machines
  3. Creating Your First State Machine
  4. Understanding the Properties Panel
  5. Wiring Stage Inputs
  6. Test Configurations
  7. Real Trading Examples
  8. Troubleshooting
  9. Best Practices

1. What is a State Machine Block?

A State Machine Block allows you to build multi-step sequential entry logic visually – without writing any code.

The Core Concept

Think of it like a checklist that must be completed in order:

SCANNING  →  ARMED  →  CONFIRMED  →  ENTRY
   ↑           ↓           ↓          ↓
   └───────────┴───────────┴──────────┘
          (Timeout or Abort resets)
  1. SCANNING – Waiting for the first condition
  2. ARMED – First condition met, now waiting for second
  3. CONFIRMED – Second condition met, waiting for final trigger
  4. ENTRY – All conditions met → Signal fires!

Why This Matters

Without a State Machine, building “RSI drops below 30, THEN within 10 bars price touches support, THEN RSI crosses back above 30” would require 8+ blocks (SR Latches, Signal Extenders, AND gates, etc.).

With a State Machine: 1 block.


2. When to Use State Machines

✅ USE State Machine When:

ScenarioExample
Sequential conditions“First X happens, then Y, then Z”
Timed windows“Y must happen within 10 bars of X”
Complex entriesBreakout → Pullback → Continuation
Pattern completionDivergence detection with confirmation
Multi-step filtersVolume spike → Reversal → Confirmation

❌ DON’T USE State Machine When:

ScenarioBetter Alternative
Simple threshold crossingCondition Block
Two conditions at same timeAND Gate
Either/or logicOR Gate
Toggle between statesSR Latch or Toggle Gate

3. Creating Your First State Machine

Step 1: Add the Block

  1. Open Fusion Builder
  2. Click State Machine in the block toolbar
  3. A State Machine block appears with default 3 stages

Step 2: Understand the Ports

INPUT PORTS (Left Side):

PortPurpose
S1Stage 1 trigger (ARM condition)
S2Stage 2 trigger (CONFIRM condition)
S3Stage 3 trigger (ENTRY condition)
S4-S6Additional stages (when StageCount > 3)
AbortGlobal reset trigger (optional)

OUTPUT PORTS (Right Side):

PortPurpose
SignalFires when terminal stage reached (1.0 or -1.0)
StateCurrent state number (0-6) for debugging

Step 3: Configure Properties

Click the State Machine block to open the Properties Panel.


4. Understanding the Properties Panel

Signal Configuration

PropertyWhat It DoesOptions
Signal NameIdentifier for your state machineAny text (e.g., “RSI_Bounce”)
DirectionSignal direction when entry firesLong (+1), Short (-1), Both (±1)
Long OutputValue output for Long signalsDefault: 1.0
Short OutputValue output for Short signalsDefault: -1.0

Stages Section

PropertyWhat It DoesNotes
Stage CountHow many stages (2-6)Default: 3
Stage N NameLabel for the stageShows in block body
Timeout (bars)Max bars to wait0 = infinite (no timeout)
Reset on timeoutReturn to Scanning if timeoutUsually ON

Abort Configuration

PropertyWhat It Does
Enable AbortAllow abort condition to resetShows/hides Abort port
Abort Resets ToWhere to reset on abort0=Scanning, 1-6=specific stage

Reset Behavior

PropertyWhat It Does
Auto-reset after signalReturn to Scanning after signal fires
Reset Delay (bars)Cooldown before re-arming

Visualization

PropertyWhat It Does
Show state on blockDisplay current state on block body
Plot state outputEnable State output port

5. Wiring Stage Inputs

What Can Connect to Stage Ports?

Stage inputs expect a truthy value (non-zero, non-NaN):

Source BlockHow to Wire
Condition BlockWire output directly → S1/S2/S3
Gate BlockWire output directly → S1/S2/S3
Indicator BlockUse with Condition to create true/false
Math BlockUse if result should trigger stage

Wiring Pattern

┌─────────────────┐
│ Condition Block │───► S1 (Arms when condition true)
│ "RSI < 30"      │
└─────────────────┘

┌─────────────────┐
│ Condition Block │───► S2 (Confirms when condition true)
│ "Price < LowerBB"│
└─────────────────┘

┌─────────────────┐
│ Condition Block │───► S3 (Entry triggers when condition true)
│ "RSI CrossAbove" │
└─────────────────┘

┌─────────────────┐
│ Condition Block │───► Abort (Resets entire state machine)
│ "RSI < 20"      │
└─────────────────┘

6. Test Configurations

Test 1: Basic 3-Stage State Machine

Purpose: Verify basic state transitions work

Setup:

ComponentConfiguration
Indicator 1RSI(14)
Condition 1RSI CrossBelow 30 → wire to S1
Condition 2RSI CrossAbove 25 → wire to S2
Condition 3RSI CrossAbove 30 → wire to S3
State MachineStageCount=3, Stage1Timeout=0, Stage2Timeout=20, Stage3Timeout=10

Expected Behavior:

  1. Block shows “Scanning” initially
  2. When RSI crosses below 30 → Block shows “Armed”
  3. When RSI crosses above 25 (within 20 bars) → Block shows “Confirmed”
  4. When RSI crosses above 30 (within 10 bars) → Signal fires (1.0)
  5. After signal → Block returns to “Scanning”

Verification:


Test 2: Timeout Reset

Purpose: Verify timeout resets to Scanning

Setup:

ComponentConfiguration
Indicator 1RSI(14)
Condition 1RSI CrossBelow 30 → wire to S1
Condition 2RSI CrossAbove 50 → wire to S2 (unlikely to trigger quickly)
State MachineStage1Timeout=0, Stage2Timeout=5

Expected Behavior:

  1. RSI crosses below 30 → Armed
  2. Wait 5+ bars without RSI crossing 50
  3. Block resets to “Scanning” (timeout triggered)

Test 3: Abort Condition

Purpose: Verify abort resets state machine

Setup:

ComponentConfiguration
Indicator 1RSI(14)
Condition 1RSI CrossBelow 30 → wire to S1
Condition 2RSI CrossAbove 30 → wire to S2
Condition 3RSI > 25 → wire to S3
Condition 4RSI < 20 → wire to Abort
State MachineAbortEnabled=true, AbortResetsTo=0

Expected Behavior:

  1. RSI crosses below 30 → Armed
  2. RSI drops below 20 → Abort fires → Back to Scanning
  3. (Even if S2/S3 would have triggered, abort takes priority)

Test 4: Reset Delay

Purpose: Verify cooldown prevents immediate re-arming

Setup:

ComponentConfiguration
Indicator 1RSI(14)
Condition 1RSI < 30 → wire to S1
Condition 2RSI < 28 → wire to S2
Condition 3RSI < 25 → wire to S3
State MachineAutoResetAfterSignal=true, ResetDelayBars=3

Expected Behavior:

  1. RSI drops below 30, 28, 25 rapidly → Signal fires
  2. Block shows Scanning but won’t re-arm for 3 bars
  3. After 3 bars, S1 can trigger again

Test 5: Direction “Both”

Purpose: Verify Both direction uses input sign

Setup:

ComponentConfiguration
Indicator 1RSI(14)
Math BlockSubtract RSI from 50 (result positive if RSI<50, negative if RSI>50)
Condition 1Abs(Result) > 20 → wire to S1 (signed value)
Condition 2Abs(Result) > 15 → wire to S2
Condition 3Abs(Result) > 10 → wire to S3 (pass the signed value)
State MachineDirection=Both

Expected Behavior:


Test 6: Multi-Stage (5 Stages)

Purpose: Verify extended stage count works

Setup:

ComponentConfiguration
State MachineStageCount=5
Condition 1RSI < 40 → S1
Condition 2RSI < 35 → S2
Condition 3RSI < 30 → S3
Condition 4RSI < 25 → S4
Condition 5RSI CrossAbove 30 → S5

Expected Behavior:

  1. Verify S4 and S5 ports are visible
  2. State progresses through all 5 stages
  3. Signal fires only after S5 triggers

7. Real Trading Examples

Example 1: RSI Oversold Bounce

The Pattern:

  1. Wait for RSI < 30 (market is oversold)
  2. Within 10 bars, price touches lower Bollinger Band
  3. Within 5 bars, RSI crosses back above 30
  4. If RSI drops below 20 (extreme oversold), cancel

Block Configuration:

┌────────────────────────────────────────────────────┐
│ INDICATOR: RSI(14)                                  │
│ INDICATOR: Bollinger(20,2)                          │
│                                                     │
│ CONDITION: RSI < 30              ────► S1 (Armed)   │
│ CONDITION: Close < LowerBB       ────► S2 (Confirm) │
│ CONDITION: RSI CrossAbove 30     ────► S3 (Entry)   │
│ CONDITION: RSI < 20              ────► Abort        │
│                                                     │
│ STATE MACHINE SETTINGS:                             │
│   Stage1Timeout = 0 (wait forever)                  │
│   Stage2Timeout = 10 bars                           │
│   Stage3Timeout = 5 bars                            │
│   Direction = Long                                   │
└────────────────────────────────────────────────────┘

Example 2: Breakout-Pullback-Continuation

The Pattern:

  1. Price breaks above 20-bar high (breakout)
  2. Within 15 bars, price pulls back to 50% of breakout move
  3. Within 10 bars, price makes new high

Block Configuration:

┌────────────────────────────────────────────────────┐
│ INDICATOR: Highest(High, 20)                        │
│ INDICATOR: Lowest(Low, 20)                          │
│                                                     │
│ CONDITION: Close > Highest[1]    ────► S1 (Breakout)│
│ CONDITION: Low < Midpoint        ────► S2 (Pullback)│
│ CONDITION: High > Recent High    ────► S3 (Continue)│
│                                                     │
│ STATE MACHINE SETTINGS:                             │
│   Stage1Timeout = 0                                 │
│   Stage2Timeout = 15 bars                           │
│   Stage3Timeout = 10 bars                           │
│   Direction = Long                                   │
└────────────────────────────────────────────────────┘

Example 3: Volume Climax Reversal

The Pattern:

  1. Volume spike > 2x average (climax)
  2. Within 3 bars, price reverses (close > open after down move)
  3. Within 5 bars, volume returns to normal

Block Configuration:

┌────────────────────────────────────────────────────┐
│ INDICATOR: SMA(Volume, 20)                          │
│ MATH: Divide Volume by SMA(Volume)                  │
│                                                     │
│ CONDITION: VolRatio > 2.0        ────► S1 (Climax)  │
│ CONDITION: Close > Open          ────► S2 (Reversal)│
│ CONDITION: VolRatio < 1.5        ────► S3 (Normal)  │
│ CONDITION: VolRatio > 2.0        ────► Abort        │
│                                                     │
│ STATE MACHINE SETTINGS:                             │
│   Stage1Timeout = 0                                 │
│   Stage2Timeout = 3 bars                            │
│   Stage3Timeout = 5 bars                            │
│   ResetDelayBars = 5 (prevent rapid re-triggers)    │
└────────────────────────────────────────────────────┘

8. Troubleshooting

State Machine Won’t Advance

SymptomCauseSolution
Stuck on “Scanning”S1 condition never firesCheck S1 wiring, verify condition logic
Stuck on “Armed”S2 condition not firingCheck Stage2Timeout, verify S2 wiring
Timeout keeps resettingTimeout too shortIncrease timeout value

Signal Never Fires

SymptomCauseSolution
Reaches terminal stage but no signalDirection mismatchCheck SignalDirection setting
Final condition fires but stays at 0AutoReset issueVerify AutoResetAfterSignal

Abort Keeps Triggering

SymptomCauseSolution
State resets unexpectedlyAbort condition too sensitiveAdjust Abort condition thresholds
Abort firing during normal progressionDisable AbortEnabled temporarily

Block Shows Wrong State

SymptomCauseSolution
Display doesn’t updateShowStateOnBlockBody=falseEnable in properties
State number seems wrongCounting from 00=Scanning, 1=Stage1, etc.

9. Best Practices

DO:

  1. Start simple – Use 3 stages first, add complexity later
  2. Use meaningful names – “Armed”, “Pullback”, “Entry” instead of “Stage1”
  3. Set appropriate timeouts – Too short = miss signals, too long = stale setups
  4. Test each stage independently – Wire State output to Result block for debugging
  5. Use abort conditions – Protect against adverse market conditions

DON’T:

  1. Don’t chain State Machines – They’re designed to be self-contained
  2. Don’t use 6 stages unless necessary – More stages = more ways to fail
  3. Don’t set all timeouts to 0 – You’ll never get signals during choppy markets
  4. Don’t forget reset delay – Prevents machine-gun signals in volatile conditions

Timeout Guidelines

Market ConditionRecommended Timeout
Scalping (1-5 min)3-10 bars
Day Trading (15-60 min)5-20 bars
Swing Trading (Daily)3-10 bars
Position Trading (Weekly)2-5 bars

Quick Reference Card

State Numbers

NumberStateMeaning
0ScanningWaiting for first condition
1ArmedS1 fired, waiting for S2
2ConfirmedS2 fired, waiting for S3
3-6Stage 3-6Additional stages if configured

Signal Values

DirectionOutput
Long+1.0 (default, configurable)
Short-1.0 (default, configurable)
BothSign determined by final stage input

Port Summary

PortTypePurpose
S1-S6InputStage trigger conditions
AbortInputGlobal reset condition
SignalOutputEntry signal (1.0/-1.0)
StateOutputCurrent state number (0-6)

Appendix: Comparison with Traditional Approach

Traditional (8+ blocks):

RSI < 30 → SR Latch (Set)
         → SignalExtender (10 bars)
         → AND Gate ← LowerBB Touch
                    → SignalExtender (5 bars)
                    → AND Gate ← RSI CrossAbove 30
                              → Signal Output

Plus abort logic: RSI < 20 → SR Latch (Reset) wired to all components

State Machine (1 block):

RSI < 30      → S1
LowerBB Touch → S2
RSI CrossAbove 30 → S3
RSI < 20      → Abort
                → Signal Output

Timeouts and resets handled internally!

Happy Trading with Fusion Builder!

← All guides