"""Developer helper: run TF_TestEA in the Strategy Tester on a Tick Forge custom symbol (testing install only). usage: tf_tester_check.py SYMBOL FROM TO MODEL MODEL: 0 every tick, 1 1-min OHLC, 4 real ticks Writes the one-line result from Common\\Files\\tf_test_result.txt. """ import os, shutil, subprocess, sys, time from pathlib import Path D = Path(os.environ.get("TF_DATA", r"C:\Users\gebruiker\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075")) EXE = os.environ.get("TF_EXE", r"C:\Program Files\MetaTrader 5\terminal64.exe") EDIT = os.environ.get("TF_EDITOR", r"C:\Program Files\MetaTrader 5\metaeditor64.exe") HERE = Path(__file__).resolve().parent COMMON = Path(os.environ["APPDATA"]) / "MetaQuotes" / "Terminal" / "Common" / "Files" / "tf_test_result.txt" sym, fr, to, model = sys.argv[1:5] dst = D / "MQL5" / "Experts" / "Tick_Forge" dst.mkdir(parents=True, exist_ok=True) shutil.copy2(HERE / "TF_TestEA.mq5", dst / "TF_TestEA.mq5") subprocess.run([EDIT, "/compile:%s" % (dst / "TF_TestEA.mq5"), "/log:%s" % (dst / "t.log")], capture_output=True) if not (dst / "TF_TestEA.ex5").exists(): sys.exit("compile failed") ini = Path(os.environ["TEMP"]) / "tf_tester.ini" ini.write_bytes(b"\xff\xfe" + ( "[Tester]\nExpert=Tick_Forge\\TF_TestEA\nSymbol=%s\nPeriod=M1\nModel=%s\nFromDate=%s\nToDate=%s\nForwardMode=0\n" "Deposit=10000\nCurrency=USD\nLeverage=100\nOptimization=0\nVisual=0\nReport=tf_tester_report\nReplaceReport=1\n" "ShutdownTerminal=1\nExecutionMode=0\n" % (sym, model, fr, to)).replace("\n", "\r\n").encode("utf-16-le")) if COMMON.exists(): COMMON.unlink() subprocess.Popen([EXE, "/config:%s" % ini]) t0 = time.time() while time.time() - t0 < 900 and not COMMON.exists(): time.sleep(4) time.sleep(3) print(COMMON.read_text(errors="replace").strip() if COMMON.exists() else "NO RESULT (tester did not finish)") subprocess.run(["powershell", "-NoProfile", "-Command", "Get-Process terminal64 -EA SilentlyContinue | Where-Object {$_.Path -eq '%s'} | Stop-Process -Force" % EXE])