| //+------------------------------------------------------------------+
|
| //| TF_TestEA.mq5 - developer check: does the Strategy Tester see a |
|
| //| Tick Forge custom symbol? Counts ticks / bars, records the first |
|
| //| and last tick, writes one line to Common\Files\tf_test_result.txt.|
|
| //| Copyright (c) 2026 Joshua Dunnink. MIT License. |
|
| //+------------------------------------------------------------------+
|
| #property version "1.00"
|
| #property strict
|
|
|
| long g_n = 0;
|
| datetime g_t0 = 0, g_t1 = 0;
|
| double g_b0 = 0, g_b1 = 0, g_min = 1e18, g_max = 0, g_spr = 0;
|
|
|
| int OnInit() { return INIT_SUCCEEDED; }
|
|
|
| void OnTick()
|
| {
|
| MqlTick tk;
|
| if(!SymbolInfoTick(_Symbol, tk)) return;
|
| if(g_n == 0) { g_t0 = tk.time; g_b0 = tk.bid; }
|
| g_t1 = tk.time; g_b1 = tk.bid; g_n++;
|
| if(tk.bid < g_min) g_min = tk.bid;
|
| if(tk.bid > g_max) g_max = tk.bid;
|
| g_spr += tk.ask - tk.bid;
|
| }
|
|
|
| void OnDeinit(const int reason)
|
| {
|
| int h = FileOpen("tf_test_result.txt", FILE_WRITE | FILE_TXT | FILE_ANSI | FILE_COMMON);
|
| if(h == INVALID_HANDLE) return;
|
| FileWrite(h, StringFormat("symbol=%s ticks=%I64d first=%s bid=%.2f last=%s bid=%.2f min=%.2f max=%.2f avg_spread=%.3f digits=%d",
|
| _Symbol, g_n, TimeToString(g_t0, TIME_DATE | TIME_SECONDS), g_b0, TimeToString(g_t1, TIME_DATE | TIME_SECONDS), g_b1,
|
| g_min, g_max, (g_n > 0 ? g_spr / g_n : 0.0), (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS)));
|
| FileClose(h);
|
| }
|