Connecting Nodes
Connections (edges) between nodes define how data flows through your strategy. Understanding how to create valid connections, recognize data type compatibility, and organize your graph is essential for building effective trading strategies.
What are Connections?
Connections are the lines that link nodes together, passing data from one node's output to another node's input. They represent the flow of information through your strategy, from data sources through logic operations to final trading signals.
Creating Connections
Follow these steps to connect nodes on the canvas:
Step-by-Step Connection Process
- Locate Output Port: Find the small circle on the right side of the source node. This is the output port.
- Click and Hold: Click on the output port and hold the mouse button down.
- Drag to Input Port: While holding, drag your cursor to the target node's input port (left side circle).
- Visual Feedback: As you hover over the input port, you'll see:
- Green highlight = Valid connection (compatible types)
- Red highlight = Invalid connection (incompatible types)
- Release to Connect: If green (valid), release the mouse button to create the connection.
- Connection Confirmed: A colored line appears connecting the two nodes.
Pro Tip: You can also start from an input port and drag to an output port. The system validates connections in both directions.
Understanding Data Type Compatibility
Connections are only valid when the output type matches the input type. MangoLabs uses color-coded connections to help you identify data types.
NUMERIC Connections (Cyan/Blue)
Carry numeric values (integers, decimals, arrays of numbers).
Valid Connections:
- Feature Node output → Comparison Node input
- Static Value output → Math Node input
- Math Node output → Position Size output
BOOLEAN Connections (White)
Carry true/false values representing conditions and logic.
Valid Connections:
- Comparison Node output → AND/OR Node input
- Logic Node output → Output Node (buy_signal, sell_signal)
- NOT Node output → Logic Node input
DATA Connections (Teal/Green)
Carry market data streams (OHLCV time series).
Valid Connections:
- Data Source Node output → Feature Node input (when applicable)
- Feature arrays → Custom indicator nodes
Valid vs Invalid Connections
Valid Connections
These connections are allowed and will work correctly:
- ✓NUMERIC → NUMERIC (Feature to Comparison)
- ✓BOOLEAN → BOOLEAN (Comparison to AND gate)
- ✓NUMERIC → Math operation inputs
- ✓BOOLEAN → buy_signal or sell_signal output
- ✓Multiple outputs from same node (fan-out)
Invalid Connections
These connections will be rejected by the canvas:
- ✗NUMERIC → BOOLEAN (type mismatch)
- ✗BOOLEAN → Math operation inputs
- ✗Output port → Output port (no input)
- ✗Input port → Input port (no output)
- ✗Circular dependencies (A → B → A)
Type Mismatch Prevention: The canvas won't let you create invalid connections. If you try to connect incompatible types, the connection will fail and you'll see a brief error notification.
Visual Feedback During Connection
The canvas provides real-time visual feedback as you create connections:
Hover State (Before Release)
- Green Pulse: Input port compatible - safe to connect
- Red Pulse: Input port incompatible - connection will fail
- Dashed Line: Preview of connection path while dragging
- Blue Highlight: Source output port highlighted during drag
Connected State (After Release)
- Cyan Line (3px): NUMERIC data flowing through connection
- White Line (3px): BOOLEAN data flowing through connection
- Teal Line (3px): DATA stream flowing through connection
- Animated Flow: Subtle animation shows data direction (left to right)
- Selected State: Purple highlight when connection is selected
Deleting and Modifying Connections
Deleting Connections
Three ways to remove a connection:
- Click and Delete: Click the connection line to select it (turns purple), then press Delete or Backspace key.
- Right-Click Menu: Right-click the connection line and select "Delete Edge" from the context menu.
- Reconnect: Drag a new connection from the same output port - the old connection is automatically replaced.
Reconnecting Nodes
To change where a connection points:
- Delete the existing connection (methods above)
- Create a new connection from the same output to a different input
- Or create a new connection from the output - the old one is replaced automatically
Connection Best Practices
Left-to-Right Data Flow
Organize nodes so data flows from left (data sources) to right (outputs). This conventional layout makes strategies easier to read and debug.
Minimize Connection Crossings
Rearrange nodes to reduce connection line crossings. This improves readability and makes it easier to trace data flow. Use the grid alignment to create clean vertical/horizontal layouts.
Group Related Logic
Keep related nodes close together. For example, group all entry logic nodes in one area, exit logic in another. Use Comment nodes to label these sections.
Validate Early and Often
Check the validation panel frequently as you build. Fix connection errors immediately rather than waiting until the end. This prevents cascading issues.
Avoiding Circular Dependencies
What is a Circular Dependency?
A circular dependency occurs when a node's output eventually feeds back into its own input through a chain of connections. This creates an infinite loop and is not allowed.
Example of Circular Dependency:
Node A → Node B → Node C → Node A (INVALID - circular!)The validation system will detect circular dependencies and prevent you from saving the strategy. Check the validation panel for "Circular dependency detected" errors.
How to Fix Circular Dependencies
- Identify the Loop: The validation panel will show which nodes are involved in the circular dependency.
- Break the Chain: Delete one connection in the loop to break the circular flow.
- Redesign Logic: Rethink your strategy structure. Often circular dependencies indicate a logic design issue.
- Use Intermediate Nodes: Sometimes adding a Static Value or Input node can break unwanted dependencies.
Fan-Out: Connecting One Output to Multiple Inputs
A single output can connect to multiple inputs. This is called "fan-out" and is perfectly valid.
Fan-Out Use Cases
- Reuse Feature Values: Connect a single RSI feature node to multiple comparison nodes (RSI < 30, RSI > 70).
- Share Calculations: Use one Math node result in multiple downstream operations without recalculating.
- Multiple Conditions: Send a boolean condition to both buy_signal and sell_signal logic paths.
Performance Note: Fan-out doesn't impact performance. Features and calculations are computed once, then the result is reused for all connected inputs.
Troubleshooting Connection Issues
Problem: Can't connect two nodes
Solution:
- Verify you're connecting output (right) to input (left)
- Check data type compatibility (NUMERIC to NUMERIC, BOOLEAN to BOOLEAN)
- Ensure the input port doesn't already have a connection (disconnect first)
- Check for validation errors in the nodes themselves
Problem: Connection disappears after release
Solution:
- This indicates a type mismatch - check the data types
- Look for a brief error notification explaining the issue
- Verify you released the mouse over the target port (not empty space)
Problem: Connection shows as error in validation panel
Solution:
- Check if source or target node has configuration errors
- Ensure both connected nodes are fully configured
- Look for circular dependency warnings
- Verify the connection path doesn't create invalid logic
Problem: Too many connection crossings (messy graph)
Solution:
- Rearrange nodes to minimize crossings (drag nodes to new positions)
- Use vertical or horizontal alignment for cleaner layouts
- Group related nodes together using Comment boxes
- Consider restructuring logic to reduce overall complexity
Advanced Connection Patterns
Pattern: Parallel Conditions (AND Logic)
Connect multiple comparison outputs to a single AND node to require all conditions to be true:
(RSI < 30) → AND Node
(Price > SMA) → AND Node
AND Node → buy_signalPattern: Alternative Exits (OR Logic)
Connect multiple exit conditions to an OR node to trigger on any condition:
(RSI > 70) → OR Node
(Stop Loss Hit) → OR Node
(Take Profit) → OR Node
OR Node → sell_signalPattern: Chained Calculations
Chain multiple math operations for complex calculations:
Account Balance → Multiply (× 0.1) → Divide (÷ Price) → position_sizePattern: Conditional Filtering
Use AND nodes to filter signals through multiple conditions:
Primary Signal → AND Node
NOT(Market Closed) → AND Node
NOT(High Volatility) → AND Node
AND Node → buy_signalWhat's Next?
Strategy Validation
Learn about validation rules, common errors, and how to ensure your strategy is ready for backtesting.
Node Types Reference
Comprehensive reference of all available node types, their inputs, outputs, and configuration options.
Build Your First Strategy
Apply what you've learned by building a complete RSI mean reversion strategy step-by-step.