ดึงประวัติการเทรดจาก MetaTrader 5 มาวาดเป็นกล่องบนกราฟแท่งเทียน แล้วสรุปเป็นรายงานวินัยการเทรด ออกมาเป็นหน้าเว็บไฟล์เดียวที่เปิดได้เลยโดยไม่ต้องมีเซิร์ฟเวอร์
Pulls trade history from MetaTrader 5, draws each trade as a box on a candlestick chart, and produces a trading-discipline report as a single web page that opens directly, no server needed.
ขั้นที่มีคนเป็นผู้ตัดสินใจหรือใช้งานSteps where a person decides or uses it

AI เขียนโค้ดให้ แต่โจทย์ เกณฑ์ และสิ่งที่ยอมไม่ได้ ผมเป็นคนกำหนด
The AI writes the code; the problem, the criteria and the non-negotiables are mine.
รายงานมีหน้าเช็ควินัยที่ติดธงเมื่อขนาดไม้เกินที่ตั้งไว้ และหน้า "กำไรที่ทิ้งไว้บนโต๊ะ" ที่เทียบว่าราคาเคยวิ่งไปถึงไหนกับจุดที่ปิดจริง
There's a discipline page that flags positions above the set size limit, and a "profit left on the table" page comparing how far price went with where the trade was closed.
เปอร์เซ็นต์คิดจากยอดฝากรวม แทนทุนตั้งต้นที่ตั้งไว้เอง เพราะการฝากเพิ่มระหว่างทางทำให้ตัวเลขแบบเดิมหลอกตา
Percentages are based on total deposits rather than a self-declared starting balance, because topping up along the way makes the old figure misleading.
เป็นภาพ ณ ตอนกดเปิด ทำให้ระบบเรียบง่ายและไม่มีอะไรต้องรันค้างไว้
It's a snapshot taken when opened, which keeps the system simple with nothing running in the background.
โค้ดทั้งหมดเขียนโดย Claude Code ตามที่ผมสั่ง ผมอ่านแล้วอธิบายได้ว่าแต่ละท่อนทำอะไร และทำไมต้องเขียนแบบนี้ (ข้อมูลลับอย่างรหัสผ่านและที่อยู่เครื่องถูกตัดออก)
All code was written by Claude Code under my direction. I can explain what each part does and why it's written that way. (Secrets such as keys and machine paths are removed; code comments are in Thai.)
หลังสลับบัญชี ประวัติการเทรดจะซิงก์ตามมาช้ากว่าเล็กน้อย ถ้าดึงทันทีจะได้ข้อมูลไม่ครบ โค้ดนี้จะรอจนไม้ที่เปิดอยู่ทุกไม้มีประวัติตอนเปิดครบก่อน แล้วค่อยหาส่วนต่างเวลาของเซิร์ฟเวอร์จากราคาล่าสุด
After switching accounts the trade history syncs a little late; pulling immediately gives incomplete data. This waits until every open position has its opening deal, then works out the server's time offset from the latest price.
# หลัง login ประวัติ deal ซิงก์ตามมาทีหลัง -> รอจนไม้ที่เปิดอยู่มี deal ตอนเปิดครบ
open_ids = {p.identifier for p in m.positions_get() or []}
for _ in range(30):
all_deals = m.history_deals_get(H0, H1) or ()
if open_ids <= {d.position_id for d in all_deals if d.entry == 0}:
break
time.sleep(0.5)
# หา offset เวลาเซิร์ฟเวอร์ (tick.time เป็นเวลาเซิร์ฟเวอร์)
srv_off_h = round((m.symbol_info_tick(SYM).time - time.time()) / 3600)
shift = int((TZ_OUT - srv_off_h) * 3600)เวลาในรายงานเพี้ยนไปหลายชั่วโมง
Report times off by several hours
โปรแกรมเทรดส่งเวลาของเซิร์ฟเวอร์มา เลยต้องคำนวณส่วนต่างจากราคาล่าสุดแล้วแปลงเป็นเวลาไทย
The platform reports server time, so the offset is computed from the latest price and converted to Thai time
ไม้ล่าสุดหายจากรายงาน
Latest trade missing from the report
รอให้ประวัติซิงก์ครบก่อน (โค้ดด้านบน)
Wait for history to finish syncing (code above)
หน้าแสดงค้างเป็นข้อมูลเก่า
Page showing stale data
เพราะเป็นภาพ ณ ตอนเปิด ต้องกดสร้างใหม่ ระบบจะบอกเวลาของข้อมูลไว้ท้ายหน้า
It's a snapshot, so it must be rebuilt; the data timestamp is shown at the bottom