In QuantRaider a strategy is a graph: nodes that read candle data, calculate, compare and finally place a trade entry. You will learn what nodes, sockets and connections are and how a graph is evaluated once for every candle.
Nodes, sockets and connections
A node is one small operation, such as reading prices, averaging them or comparing two numbers. Each node has sockets: input sockets on one side that receive values, and output sockets on the other that provide them. A connection is a line from an output socket to an input socket, and it carries the value the output produced for the current candle.
Sockets have a data type, for example a number, a boolean (true or false) or a list of numbers. A connection joins sockets of the same type. This is why a comparison such as GreaterThan, which outputs a boolean, can feed a logic node such as And, while an SMA, which outputs a number, feeds the numeric inputs of a comparison.
The families of nodes
- Data has no inputs. Its outputs are
Open,Close,High,Low,Time,Volume,Spread at highandSpread at lowfor the current candle. - Indicators such as
SMA,EMA,RSI,MACDandATRturn prices into new series. - Maths and comparisons:
Add,Subtract,Multiply,Divide,GreaterThan,LessThan,EqualToandIf. - Logic:
And,OrandNotcombine booleans. - Memory:
PreviousValuereturns the value from one candle earlier, andSlidingWindowreturns the last N values, whichMin,MaxandGetNthValuecan read. - Output:
Trade entryplaces trades, and theVisualizeLine,VisualizeArrowandVisualizeHistogramnodes draw on the chart.
One candle at a time
The whole graph is evaluated once per candle, from the oldest candle in the test to the newest. On each candle every node computes its outputs from the values that arrive at its inputs, and the Trade entry node looks at its Trigger. If the trigger is true on that candle, a trade is recorded with the entry, stop and target values the graph produced on that same candle.
Because the graph only ever sees the current candle plus whatever memory nodes give it, it cannot peek at future candles. Anything that refers to the past has to be built explicitly, which is what PreviousValue and SlidingWindow are for.
Worked example
Evaluating a simple graph on three candles
- The graph is
Data.CloseintoSMA20 (fast) andSMA50 (slow), and both into aGreaterThannode with the fast average onAand the slow one onB. - Candle 1: fast = 99.80 and slow = 100.00. Is 99.80 > 100.00? No, so
Resultis false. - Candle 2: fast = 100.30 and slow = 100.10. Is 100.30 > 100.10? Yes, so
Resultis true. - Candle 3: fast = 100.50 and slow = 100.10. Is 100.50 > 100.10? Yes, so
Resultis true.
The output over the three candles is false, true, true: the graph produces one boolean per candle, and the later nodes only see that candle's value.
A note on this example
Notice that on candle 3 the output is still true even though nothing new happened. A plain comparison describes a state, not an event. Whether you want a state or an event is the central design question when you turn a rule into a graph, and the next lesson shows how to turn the state into a single crossing event.
Key takeaways
- A strategy is a graph of nodes whose sockets are joined by typed connections.
- The graph is evaluated once per candle, and each node only sees values for the current candle plus what memory nodes provide.
- A comparison describes a state that can stay true for many candles, which is different from an event that happens once.
PreviousValueandSlidingWindoware how a graph looks back at earlier candles.