| //+------------------------------------------------------------------+
|
| //| ONNX Model Viewer Part 4.mq5 |
|
| //| Copyright 2026, Allan Munene Mutiiria. |
|
| //| https://t.me/Forex_Algo_Trader |
|
| //+------------------------------------------------------------------+
|
| #property copyright "Copyright 2026, Allan Munene Mutiiria."
|
| #property link "https://t.me/Forex_Algo_Trader"
|
| #property version "1.00"
|
| #property strict
|
| #property description "Draw an ONNX model and run it on each new bar"
|
|
|
| #include "OMV Panel.mqh"
|
|
|
| //+------------------------------------------------------------------+
|
| //| Which body the panel opens on |
|
| //+------------------------------------------------------------------+
|
| enum ENUM_OMV_VIEW
|
| {
|
| OMV_VIEW_GRAPH, // Graph of the layers
|
| OMV_VIEW_NEURONS // Neurons and their connections
|
| };
|
|
|
| //+------------------------------------------------------------------+
|
| //| Inputs |
|
| //+------------------------------------------------------------------+
|
| input group "Model"
|
| input string ModelFile = "ONNX Model Viewer Part 4\\model.onnx"; // Model Path Inside The Shared Files Folder
|
| input string ScaleFile = "ONNX Model Viewer Part 4\\model_scale.txt"; // Scaling Path Inside The Shared Files Folder
|
| input string FeedSymbol = "XAUUSDm"; // Symbol The Model Was Trained On
|
| input ENUM_TIMEFRAMES FeedPeriod = PERIOD_M15; // Timeframe The Model Was Trained On
|
| input ENUM_OMV_VIEW StartView = OMV_VIEW_NEURONS; // View The Panel Opens On
|
|
|
| //+------------------------------------------------------------------+
|
| //| Global Variables |
|
| //+------------------------------------------------------------------+
|
| COmvPanel panel; // Owns the canvas, the parsed model and the event routing
|
|
|
| //+------------------------------------------------------------------+
|
| //| Expert initialization function |
|
| //+------------------------------------------------------------------+
|
| int OnInit()
|
| {
|
| //--- Build the panel and read the model into it
|
| if(!panel.Init(ChartID(), ModelFile, ScaleFile, FeedSymbol, FeedPeriod,
|
| StartView == OMV_VIEW_NEURONS))
|
| return(INIT_FAILED);
|
| return(INIT_SUCCEEDED);
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| Expert tick function |
|
| //+------------------------------------------------------------------+
|
| void OnTick()
|
| {
|
| //--- Let the panel notice a bar that has closed since the last look
|
| panel.OnBar();
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| Expert timer function |
|
| //+------------------------------------------------------------------+
|
| void OnTimer()
|
| {
|
| //--- Move the signal one step further through the rows
|
| panel.OnPulse();
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| Expert deinitialization function |
|
| //+------------------------------------------------------------------+
|
| void OnDeinit(const int reason)
|
| {
|
| //--- Release the canvas and restore the chart
|
| panel.Destroy();
|
| ChartRedraw();
|
| }
|
|
|
| //+------------------------------------------------------------------+
|
| //| ChartEvent function |
|
| //+------------------------------------------------------------------+
|
| void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
|
| {
|
| //--- Route hover, drag and click into the panel
|
| panel.OnEvent(id, lparam, dparam, sparam);
|
| }
|
| //+------------------------------------------------------------------+ |