EST. 2026 — Notes from real server work SYSADMIN · SECURITY · AI · DIRECTADMIN Issue 01
THE SYSADMIN ALMANAC
Home / Linux / Connected, but Every Symbol Reports symbol not visible
Linux

Connected, but Every Symbol Reports symbol not visible

by Ton-Or ·21 Nov 2026·10 min read
Connected, but Every Symbol Reports symbol not visible

One error message covering three causes was a trap I set for myself. After fixing the first cause, I believed I understood the symptom completely. When it returned with a second cause, I went back to fixing the same place even though nothing was wrong there.

1-minute summary

Symptom / problem
A Python script connects to MT5 but every symbol is reported as not visible.
Who should read
People pulling prices from MT5 with Python who hit this error.
Fix in short
One symptom has three unrelated causes. The symbol is not in Market Watch, the session died after a terminal restart, or the name differs between brokers, so check them one at a time.
Jump to steps

My data collection daemon, which connects to a MetaTrader 5 terminal through the Python package, was printing the same line for every symbol on every cycle: symbol not visible, even though the preceding line said it had connected to the terminal successfully. I had seen and fixed this symptom once before, so I immediately opened the terminal to check Market Watch. Every symbol was there, and data was flowing normally, but the daemon still insisted it could not see them.

I eventually found that the same message came from three unrelated causes, and the fix for each did nothing at all for the other two. Broker names, server names, and symbol names in this article have all been replaced with broker A, broker B, and symbol A. This system stores data for historical analysis.

One Message, Three Causes

The symbol not visible message did not come from the terminal. It came from my own code, which printed it whenever a request for symbol information returned None. The problem is that functions in this API return None for almost every failure without raising an exception. My code therefore collapsed every case into one message.

symbol not visible for all1 Not in Market Watchsymbol_select = True2 Dead sessionterminal_info() None3 Broker name mismatchsymbol_select = Falseselect before infoNot info then selectshutdown + reconnectThen remeasure offsetTry candidate listselect passes, tick not NoneBefore each write: fresh account_info() must match archive; mismatch = stop
One symptom splits into three causes. The monospace lines in the top boxes show the check results that distinguish them. The bottom row shows the fixes and the final check shared by all cases.

These three causes produce different check results if I ask the right questions. This is the table I use to distinguish them.

Question 1 Not in Market Watch 2 Dead session 3 Name mismatch
terminal_info() Returns an object None Returns an object
account_info() Returns an object None or account number 0 Returns an object
symbol_select(name, True) True False False
Request a tick after select Returns data None None
Symbols affected Those never opened before All at once Only those with different names

First Cause: Missing from Market Watch and Calls in the Wrong Order

The terminal does not send data for every symbol the broker offers. It sends data only for symbols in Market Watch. For a symbol outside that list, I cannot request ticks or bars. I first have to add it with symbol_select(name, True).

My first version of the code accounted for this, but put the calls in the wrong order.

# ลำดับผิด: ถามข้อมูลก่อน แล้วค่อยเพิ่มเข้า Market Watch เมื่อพบว่ามองไม่เห็น
info = mt5.symbol_info(name)
if info is None:
    print(f"{name}: symbol not visible")      # หลัง terminal เพิ่งเปิด มักจบตรงนี้
    return None
if not info.visible:
    mt5.symbol_select(name, True)
return name

Just after the terminal starts, symbol_info() can return None for a symbol that has not yet been selected. The code therefore exited the function before reaching the line that added it. This is why the daemon starting around the same time as the terminal encountered the symptom.

The fix is to reverse the order: always select first, then request information.

def resolve(name):
    # symbol_select คืน True ถ้ามองเห็นอยู่แล้วหรือเพิ่มสำเร็จ คืน False ถ้าไม่มีชื่อนี้
    if not mt5.symbol_select(name, True):
        return None
    return name if mt5.symbol_info(name) is not None else None

Calling symbol_select() for a symbol already in the list does no harm, so I call it before fetching data on every cycle, not just at program startup. Someone at the screen can remove a symbol from Market Watch at any time.

The return value from select is an answer, not decoration

Several places in my code called symbol_select() and discarded its return value, which meant throwing away the most useful information. A return value of False from this call can mean two things: this broker has no symbol with that name, or the session no longer works. Both are reasons to stop, not continue.

Second Cause: A Dead Session After a Terminal Restart

After I fixed the call order, the daemon worked for a long time, until one day the same symptom returned. This time it affected every symbol at once and persisted on every cycle. Out of habit, I checked Market Watch first, which was a waste of time because every symbol was there.

The cause was that the terminal had been closed and reopened while the daemon was still running. The interprocess communication channel held by the daemon pointed to the old terminal, which no longer existed. The new terminal was running normally alongside it, but every call from the daemon returned None or False. When symbol_select() returned False, my code interpreted it as invisible and skipped to the next symbol. It kept looping like this, with no exception to catch.

The check that distinguishes this case from the others is terminal_info(). If it returns None, nothing is answering through the session anymore. I have to call shutdown() and then initialize() again, and remeasure values from the previous session, such as the server clock offset. I covered the details of reconnecting without launching another terminal in initialize(path=) Is Not an Attach Operation.

What I want to emphasize here is the message. If my code had given this case its own message from the start, I would not have wasted time looking at Market Watch. The check I should have had from the beginning asks questions in sequence and returns distinct causes.

def why_invisible(name):
    """แยกสาเหตุของ 'มองไม่เห็น' ออกเป็นข้อความที่ต่างกัน"""
    if mt5.terminal_info() is None:
        return "SESSION_DEAD"        # ทุกสัญลักษณ์จะพังพร้อมกัน ต้องต่อใหม่
    if mt5.account_info() is None:
        return "NO_ACCOUNT"          # terminal เปิดอยู่แต่ยังไม่ได้ล็อกอิน
    if not mt5.symbol_select(name, True):
        return "NO_SUCH_NAME"        # โบรกนี้ไม่มีชื่อนี้ ไปเดินลิสต์ candidate
    if mt5.symbol_info_tick(name) is None:
        return "NO_TICK_YET"         # มีชื่อ แต่ยังไม่มีข้อมูลวิ่งเข้ามา
    return "OK"
A symptom affecting every symbol at once is not a symbol problem

If the entire set of symbols becomes invisible in the same cycle, it is very unlikely that all of them disappeared from Market Watch at once. What broke is what they all share: the session. My daemon now calls terminal_info() before starting each cycle. If there is no answer, it reconnects first, instead of letting every symbol fail in turn and then reporting that the cycle had no data.

Third Cause: One Name in My Head, Different Names at Each Broker

The third case appeared when I connected the same daemon to broker B's terminal. Most symbols worked, but some were invisible, even though opening the terminal clearly showed instruments of the same type. The difference was that broker B named them differently from broker A. Some brokers append letters, some append a dot followed by a word, and some use an entirely different set of names.

I fixed this by separating names into two layers. The first is the canonical name I use throughout the archive and the code. The second is a list of possible names on the terminal side, ordered by which I want to try first.

SYMBOLS = {
    # ชื่อกลาง: รายชื่อที่อาจเจอในโบรกต่าง ๆ เรียงตามลำดับที่จะลอง
    "SYM_A": {"candidates": ["SYM_A", "SYM_Am", "SYM_A.x"]},
    "SYM_B": {"candidates": ["SYM_B", "SYM_Bm", "ALT_B"]},
}

def resolve_symbol(canonical):
    cfg = SYMBOLS.get(canonical)
    if cfg is None:
        return None
    for name in cfg["candidates"]:
        # ต้องผ่านสองด่าน: เพิ่มเข้า Market Watch ได้ และมี tick จริง
        if mt5.symbol_select(name, True) and mt5.symbol_info_tick(name) is not None:
            return name
    return None

for canonical in SYMBOLS:
    real = resolve_symbol(canonical)
    print(f"{canonical} -> {real or 'NONE (ปิดงานที่ใช้ตัวนี้)'}")

The second condition, that the tick must not be None, handles cases where the broker really does have that name but no data is flowing. Such a symbol can pass symbol_select() but cannot be used. If I accept the first name that passes select without checking the tick, the daemon will latch onto a name with no data and never try the next one.

The line that prints the result at startup matters more than it might seem. When no match is found, I make it explicitly print NONE and identify which tasks were disabled as a result, instead of silently passing the canonical name along as the terminal name.

Canonical name

Used in the archive and code

Set once and does not change with the broker. It is the folder name in the data archive, the key in the state file, and the name referenced by downstream analysis. If I change brokers, data for the same symbol still lives under the same name.

Terminal name

Resolved on every connection

Found by trying the candidate list at startup and after every session reconnection. Used only for API calls, never written to the archive, and never retained across reconnections, because the terminal may have switched to a login at another broker.

The Final Check: The Connected Broker Must Match the Destination Archive

Once a single daemon could connect to multiple brokers, a new risk emerged that was worse than invisible symbols: seeing everything, fetching everything, and writing it to the wrong broker's archive. I keep separate archives for each broker because their data differs, as do their server clock time zones. Broker A and broker B use different time zones for their clocks.

Once, my program launcher lost the environment variables specifying the archive location and time zone. The program did not crash. It used the defaults, which pointed to broker B's archive, even though the connected terminal belonged to broker A. The collector was just one work cycle, or 5 minutes, away from writing ticks from the wrong broker with the wrong time zone into that archive.

The check I added uses a mapping between the connected server, the permitted archive, and the required time zone. If those three do not line up, the collector does not start.

{
  "venues": [
    {"server_contains": "BROKER-A", "store": "DATA-A", "server_tz": "TZ-A"},
    {"server_contains": "BROKER-B", "store": "DATA-B", "server_tz": "TZ-B"}
  ],
  "on_unknown_server": "refuse",
  "on_mismatch": "stop"
}
import time

def venue_ok(store_dir, server_tz, venues):
    """อ่านบัญชีสดจาก terminal ทุกครั้ง แล้วเทียบกับคลังและเขตเวลาที่ตั้งไว้"""
    ai = mt5.account_info()                    # อ่านสด ห้ามใช้ค่าที่ลูปอื่นจำไว้
    if ai is None:
        return "skip"                          # อ่านไม่ได้ = รอบนี้ไม่เขียน
    server = (ai.server or "").upper()
    for v in venues:
        if v["server_contains"] in server:
            ok = v["store"] in str(store_dir).upper() and v["server_tz"] == str(server_tz)
            return "ok" if ok else "stop"      # ต่อผิดคู่ = หยุดตัวเก็บข้อมูล
    return "stop"                              # เซิร์ฟเวอร์ที่ไม่รู้จัก = หยุด ไม่เดา

while True:
    verdict = venue_ok(STORE_DIR, SRV_TZ, VENUES)
    if verdict == "stop":
        print("[ERR] เซิร์ฟเวอร์ที่ต่ออยู่ไม่ตรงกับคลัง ตัวเก็บข้อมูลหยุด")
        break
    if verdict == "skip":
        print("[WARN] อ่านบัญชีสดไม่ได้ ข้ามรอบนี้")
        time.sleep(60)
        continue
    run_cycle()
    time.sleep(300)

I had to revise this check twice. On the first pass, I checked only once when the collector started. That was not enough, because the terminal could switch to a login at another broker while it was running. The collector's archive location and time zone were set at startup and did not follow the change. After the switch, it would fetch the new broker's ticks and write them to the old broker's archive using the old broker's clock.

On the second pass, I moved the check to every cycle, but read the server name from a value cached by the program's main loop, which refreshed it about every 20 seconds. A work cycle starting within those 20 seconds after a switch would see the old value and pass the check. The current version therefore reads account_info() fresh from the terminal on every cycle. If that read fails, it does not write during that cycle.

  1. At startup, do not trust the archive location and time zone provided, whether they come from environment variables or defaults. Treat them as unverified until they have been checked against the terminal.
  2. Check the connected server's name against the mapping. Reject servers that are not in the table.
  3. Compare the configured time zone with that broker's time zone in the table. The right archive with the wrong clock still means corrupted data.
  4. Before every write cycle, read account_info() fresh and check again. Never use a value cached by another part of the program.
  5. If the read fails, skip the cycle. If the connection does not match, stop the entire collector and wait for someone to investigate.
Data in the wrong archive is harder to fix than missing data

When symbols are invisible, the archive merely has gaps that I can fill by fetching historical data. But ticks from one broker merged into another broker's daily file become mixed with the legitimate data in that same file. If the time zone is wrong too, they land in the wrong hours. Removing them later requires knowing where each row came from, which the archive does not record. A check that simply stops the collector is therefore worth more than one that tries to keep it running at any cost.

The Diagnostic Order Next Time This Happens

Start with what is sharedterminal_info()None = reconnect->account_info()Matches archive?->symbol_selectFalse = try another name->symbol_info_tickNone = no data yet->Fetch data

This order moves from what every symbol shares to what is specific to each one: session first, account next, then each symbol's name and data. That is the reverse of what the error line invites me to do. Because the error line names a symbol, the reader starts investigating that symbol and gradually works outward. By the time the investigation reaches the session, a lot of time has already been wasted.

To find out what symbol names the connected broker uses, I can ask the terminal directly and use the results to populate the candidate list.

# ไล่ดูชื่อจริงทั้งหมดที่มีคำที่ต้องการอยู่ในชื่อ ก่อนจะเดาเติมท้ายเอง
for s in mt5.symbols_get(group="*SYM_A*") or ():
    print(s.name, "visible" if s.visible else "hidden")

The Numbers Behind This Work

1 messagecovering three causes
3 causeswith identical symptoms on every line
5 statesdistinguished by the new check
2 checksper candidate: select and tick
20 secwhile the cached value remains stale
5 minaway from writing to the wrong archive
60 secpause when a fresh account read fails
2 passesto make the archive check robust

In summary, when symbol not visible appears after a successful terminal connection, first ask whether it affects one symbol or all of them. If all are affected at once, check the session first; there is no need to open Market Watch. If it affects some symbols after changing brokers, look at their names. If it happens only just after the terminal starts, look at the order of select and info. What mattered most to me after this work was not making the symbols visible, but giving different causes different error messages and making the collector stop when it was unsure whose archive it was writing to. Anyone using a single broker and a single terminal can skip the archive checks if that suits their workload. My server-to-archive mapping still matches words in server names, which is crude. If I replace it with a more robust method, I will come back and update this article.

Hit something like this? Stuck somewhere?

Come trade notes on the LinuxThai board

→ Continue on the board

Comments 0

No comments yet — be the first