Discussing the article: "Working with ONNX Models in MQL5 (Part 2): Drawing the Model Graph on an Interactive Chart Panel"
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Working with ONNX Models in MQL5 (Part 2): Drawing the Model Graph on an Interactive Chart Panel.
We turn the ONNX reader into an interactive graph viewer on a MetaTrader 5 chart. The parser is extended to carry tensor shapes and node attributes, and a canvas with anti-aliased drawing renders nodes and labeled connections. The layout arranges layers by depth, while zoom, pan, and clicks let you inspect operators and the tensors they read. This makes a model's structure and data flow visible directly in MQL5.
A list of layers has an order, and that is all it has. To draw the same layers as a graph, we need something a list never carries: position. Every node has to sit somewhere, and where it sits has to mean something, or the picture is decoration. The rule we use is depth: a node's row is one step past the deepest node feeding it. Whatever the graph takes in starts at depth zero; anything reading it sits at depth one, and so on down. When two layers both read the same value, neither is deeper than the other, so both land on the same row and are drawn side by side. That is not a choice we make for appearance. It falls out of the rule, and it is correct, because two layers reading the same value genuinely do run at the same stage. A chain becomes a column, a branch becomes two columns, and the shape of the picture ends up being the shape of the network. See the illustration below.
Determining how layers connect is the other half, and the file does not tell us directly. No layer names its neighbors. It records the names of the values a node reads and writes. We recover connections by matching outputs to inputs. A layer that writes a value and a layer that reads that same value are joined, and that shared name is the only evidence we get. It also means one value can feed several layers at once, and several values can arrive at a single layer, without either case needing to be handled specially. A branch and a rejoin fall out of the same matching rule.
Author: Allan Munene Mutiiria