SiamCafe.net Blog
Technology

MQL5 Forum — คู่มือเทรด Forex ฉบับสมบูรณ์ 2026

mql5 forum
MQL5 Forum — คู่มือเทรด Forex ฉบับสมบูรณ์ 2026 | SiamCafe Blog
2025-08-25· อ. บอม — SiamCafe.net· 1,465 คำ

MQL5 Forum คืออะไร

MQL5 Forum เป็นชุมชนออนไลน์ที่ใหญ่ที่สุดสำหรับ Forex traders และ developers ที่ใช้ MetaTrader 5 (MT5) platform MQL5 (MetaQuotes Language 5) เป็นภาษาโปรแกรมที่ใช้เขียน Expert Advisors (EA), Indicators และ Scripts สำหรับเทรดอัตโนมัติบน MT5 Forum นี้เป็นแหล่งเรียนรู้ แลกเปลี่ยนความรู้ ซื้อขาย trading tools และรับงาน freelance programming บทความนี้เป็นคู่มือฉบับสมบูรณ์สำหรับการใช้งาน MQL5 Forum และการพัฒนา EA สำหรับ Forex trading

MQL5 Platform Overview

# mql5_overview.py — MQL5 platform overview
import json

class MQL5Platform:
    COMPONENTS = {
        "mt5": {
            "name": "MetaTrader 5 (MT5)",
            "description": "Trading platform สำหรับ Forex, Stocks, Futures, CFDs",
            "features": ["Multi-asset trading", "Algorithmic trading", "Copy trading", "Market depth"],
        },
        "mql5_language": {
            "name": "MQL5 Language",
            "description": "ภาษา C-like สำหรับเขียน trading programs บน MT5",
            "types": ["Expert Advisors (EA) — เทรดอัตโนมัติ", "Custom Indicators — indicators เฉพาะ", "Scripts — ทำงานครั้งเดียว", "Services — background tasks"],
        },
        "mql5_forum": {
            "name": "MQL5.com Forum",
            "description": "ชุมชน traders/developers — กว่า 3 ล้านสมาชิก",
            "sections": ["General Discussion", "Trading Systems", "Expert Advisors", "Indicators", "Freelance", "Market"],
        },
        "mql5_market": {
            "name": "MQL5 Market",
            "description": "ร้านค้า EA, Indicators, Utilities — ซื้อขาย trading tools",
            "products": "10,000+ products, ราคา $10-$5,000+",
        },
        "signals": {
            "name": "Trading Signals",
            "description": "Copy trading — subscribe สัญญาณจาก traders คนอื่น",
            "features": "ตรวจสอบ track record, drawdown, profit factor ได้",
        },
    }

    def show_components(self):
        print("=== MQL5 Platform ===\n")
        for key, comp in self.COMPONENTS.items():
            print(f"[{comp['name']}]")
            print(f"  {comp['description']}")
            print()

platform = MQL5Platform()
platform.show_components()

MQL5 Programming Basics

# mql5_programming.py — MQL5 programming basics
import json

class MQL5Programming:
    EA_TEMPLATE = """
// simple_ea.mq5 — Simple Expert Advisor template
#property copyright "Your Name"
#property version   "1.00"

// Input parameters
input double LotSize = 0.01;
input int    TakeProfit = 100;  // pips
input int    StopLoss = 50;     // pips
input int    MAPeriod = 20;     // Moving Average period

// Global variables
int maHandle;
double maBuffer[];

// OnInit — เรียกเมื่อ EA เริ่มทำงาน
int OnInit() {
    maHandle = iMA(_Symbol, PERIOD_H1, MAPeriod, 0, MODE_EMA, PRICE_CLOSE);
    if (maHandle == INVALID_HANDLE) {
        Print("Error creating MA indicator");
        return INIT_FAILED;
    }
    ArraySetAsSeries(maBuffer, true);
    return INIT_SUCCEEDED;
}

// OnDeinit — เรียกเมื่อ EA หยุดทำงาน
void OnDeinit(const int reason) {
    IndicatorRelease(maHandle);
}

// OnTick — เรียกทุกครั้งที่ราคาเปลี่ยน (main logic)
void OnTick() {
    // Copy MA values
    if (CopyBuffer(maHandle, 0, 0, 3, maBuffer) < 3) return;
    
    double currentPrice = SymbolInfoDouble(_Symbol, SYMBOL_BID);
    double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
    
    // Check if no open positions
    if (PositionsTotal() == 0) {
        // Buy signal: price crosses above MA
        if (currentPrice > maBuffer[0] && maBuffer[1] < maBuffer[0]) {
            double sl = currentPrice - StopLoss * point;
            double tp = currentPrice + TakeProfit * point;
            
            MqlTradeRequest request = {};
            MqlTradeResult result = {};
            request.action = TRADE_ACTION_DEAL;
            request.symbol = _Symbol;
            request.volume = LotSize;
            request.type = ORDER_TYPE_BUY;
            request.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
            request.sl = sl;
            request.tp = tp;
            request.comment = "Simple EA Buy";
            
            if (!OrderSend(request, result))
                Print("OrderSend error: ", GetLastError());
        }
    }
}
"""

    INDICATOR_TEMPLATE = """
// custom_indicator.mq5 — Custom Indicator example
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrBlue
#property indicator_color2 clrRed

input int Period1 = 10;
input int Period2 = 20;

double FastMA[], SlowMA[];

int OnInit() {
    SetIndexBuffer(0, FastMA, INDICATOR_DATA);
    SetIndexBuffer(1, SlowMA, INDICATOR_DATA);
    PlotIndexSetString(0, PLOT_LABEL, "Fast MA");
    PlotIndexSetString(1, PLOT_LABEL, "Slow MA");
    return INIT_SUCCEEDED;
}

int OnCalculate(const int rates_total, const int prev_calculated,
                const datetime &time[], const double &open[],
                const double &high[], const double &low[],
                const double &close[], const long &tick_volume[],
                const long &volume[], const int &spread[]) {
    int start = MathMax(prev_calculated - 1, Period2);
    for (int i = start; i < rates_total; i++) {
        FastMA[i] = iMAOnArray(close, Period1, i);
        SlowMA[i] = iMAOnArray(close, Period2, i);
    }
    return rates_total;
}
"""

    def show_ea(self):
        print("=== EA Template ===")
        print(self.EA_TEMPLATE[:600])

    def show_indicator(self):
        print(f"\n=== Custom Indicator ===")
        print(self.INDICATOR_TEMPLATE[:500])

    def key_functions(self):
        print(f"\n=== Key MQL5 Functions ===")
        funcs = [
            {"name": "OrderSend()", "use": "ส่งคำสั่งซื้อขาย"},
            {"name": "PositionsTotal()", "use": "นับจำนวน positions ที่เปิดอยู่"},
            {"name": "iMA()", "use": "สร้าง Moving Average indicator"},
            {"name": "iRSI()", "use": "สร้าง RSI indicator"},
            {"name": "CopyBuffer()", "use": "คัดลอกค่า indicator ไปใส่ array"},
            {"name": "SymbolInfoDouble()", "use": "ดึงข้อมูลราคา symbol"},
            {"name": "AccountInfoDouble()", "use": "ดึงข้อมูลบัญชี (balance, equity)"},
        ]
        for f in funcs:
            print(f"  [{f['name']}] {f['use']}")

mql5 = MQL5Programming()
mql5.show_ea()
mql5.key_functions()

Backtesting & Optimization

# backtesting.py — EA backtesting and optimization
import json
import random

class Backtesting:
    STRATEGY_TESTER = {
        "name": "MT5 Strategy Tester",
        "modes": {
            "every_tick": "จำลองทุก tick — ช้าแต่แม่นยำ",
            "ohlc_1min": "ใช้ OHLC 1 นาที — เร็วกว่า, แม่นยำพอสมควร",
            "open_price": "ใช้ราคาเปิดเท่านั้น — เร็วมาก, เหมาะ daily strategies",
        },
        "features": ["Walk-forward optimization", "Monte Carlo simulation", "Multi-currency testing", "Genetic algorithm optimization"],
    }

    def show_tester(self):
        print("=== Strategy Tester ===\n")
        print(f"[{self.STRATEGY_TESTER['name']}]")
        for mode, desc in self.STRATEGY_TESTER["modes"].items():
            print(f"  {mode}: {desc}")

    def backtest_results(self):
        print(f"\n=== Backtest Results (Simple MA EA) ===")
        metrics = {
            "Period": "2023-01-01 to 2024-12-31",
            "Symbol": "EURUSD H1",
            "Initial deposit": "$10,000",
            "Net profit": f"",
            "Total trades": random.randint(100, 300),
            "Win rate": f"{random.randint(45, 65)}%",
            "Profit factor": f"{random.uniform(1.2, 2.5):.2f}",
            "Max drawdown": f" ({random.randint(5, 20)}%)",
            "Sharpe ratio": f"{random.uniform(0.8, 2.0):.2f}",
            "Recovery factor": f"{random.uniform(1.5, 5.0):.2f}",
        }
        for m, v in metrics.items():
            print(f"  {m}: {v}")

    def optimization_tips(self):
        print(f"\n=== Optimization Tips ===")
        tips = [
            "ใช้ Walk-forward optimization (in-sample + out-of-sample)",
            "อย่า over-optimize — ถ้า parameters มากกว่า 5 ตัว = เสี่ยง curve fitting",
            "ทดสอบหลาย pairs และหลาย timeframes",
            "ดู Monte Carlo simulation สำหรับ worst-case scenarios",
            "ใช้ out-of-sample period อย่างน้อย 30% ของ data",
        ]
        for tip in tips:
            print(f"  • {tip}")

bt = Backtesting()
bt.show_tester()
bt.backtest_results()
bt.optimization_tips()

Python + MQL5 Integration

# python_mql5.py — Python integration with MT5
import json
import random

class PythonMQL5:
    CODE = """
# mt5_python.py — Python MetaTrader 5 integration
import MetaTrader5 as mt5
import pandas as pd
from datetime import datetime

# Initialize MT5
if not mt5.initialize():
    print(f"MT5 initialize failed: {mt5.last_error()}")
    quit()

print(f"MT5 version: {mt5.version()}")

# Login
login = mt5.login(12345678, password="your-password", server="BrokerName-Demo")
print(f"Logged in: {login}")

# Account info
info = mt5.account_info()
print(f"Balance:  | Equity: ")

# Get OHLCV data
rates = mt5.copy_rates_from_pos("EURUSD", mt5.TIMEFRAME_H1, 0, 1000)
df = pd.DataFrame(rates)
df['time'] = pd.to_datetime(df['time'], unit='s')
print(df.tail())

# Send order
def send_order(symbol, order_type, lot, sl_pips=50, tp_pips=100):
    point = mt5.symbol_info(symbol).point
    price = mt5.symbol_info_tick(symbol).ask if order_type == mt5.ORDER_TYPE_BUY else mt5.symbol_info_tick(symbol).bid
    
    request = {
        "action": mt5.TRADE_ACTION_DEAL,
        "symbol": symbol,
        "volume": lot,
        "type": order_type,
        "price": price,
        "sl": price - sl_pips * point if order_type == mt5.ORDER_TYPE_BUY else price + sl_pips * point,
        "tp": price + tp_pips * point if order_type == mt5.ORDER_TYPE_BUY else price - tp_pips * point,
        "comment": "Python EA",
        "type_filling": mt5.ORDER_FILLING_IOC,
    }
    result = mt5.order_send(request)
    print(f"Order: {result.comment} | Retcode: {result.retcode}")
    return result

# Simple strategy
def simple_ma_strategy(symbol="EURUSD", fast=10, slow=20):
    rates = mt5.copy_rates_from_pos(symbol, mt5.TIMEFRAME_H1, 0, slow + 5)
    df = pd.DataFrame(rates)
    df['fast_ma'] = df['close'].rolling(fast).mean()
    df['slow_ma'] = df['close'].rolling(slow).mean()
    
    if df['fast_ma'].iloc[-1] > df['slow_ma'].iloc[-1] and \\
       df['fast_ma'].iloc[-2] <= df['slow_ma'].iloc[-2]:
        send_order(symbol, mt5.ORDER_TYPE_BUY, 0.01)
    elif df['fast_ma'].iloc[-1] < df['slow_ma'].iloc[-1] and \\
         df['fast_ma'].iloc[-2] >= df['slow_ma'].iloc[-2]:
        send_order(symbol, mt5.ORDER_TYPE_SELL, 0.01)

simple_ma_strategy()
mt5.shutdown()
"""

    def show_code(self):
        print("=== Python + MT5 ===")
        print(self.CODE[:600])

    def libraries(self):
        print(f"\n=== Python Libraries for Trading ===")
        libs = [
            {"name": "MetaTrader5", "use": "MT5 API — ส่งคำสั่ง, ดึงข้อมูล", "install": "pip install MetaTrader5"},
            {"name": "pandas_ta", "use": "Technical indicators", "install": "pip install pandas_ta"},
            {"name": "backtrader", "use": "Backtesting framework", "install": "pip install backtrader"},
            {"name": "vectorbt", "use": "Fast vectorized backtesting", "install": "pip install vectorbt"},
        ]
        for lib in libs:
            print(f"  [{lib['name']}] {lib['use']}")

py = PythonMQL5()
py.show_code()
py.libraries()

Forum Tips & Freelance

# forum_tips.py — MQL5 Forum tips and freelance
import json

class ForumTips:
    SECTIONS = {
        "general": {"name": "General Discussion", "tip": "แนะนำตัว ถามคำถามทั่วไป ศึกษาจาก threads เก่า"},
        "trading": {"name": "Trading Systems", "tip": "แชร์ strategy, ขอ feedback, backtest results"},
        "codebase": {"name": "Code Base", "tip": "แชร์ code ฟรี สร้าง reputation ใน community"},
        "freelance": {"name": "Freelance", "tip": "รับงานเขียน EA/Indicator ราคา $50-$5,000+"},
        "market": {"name": "Market", "tip": "ขาย EA/Indicator ของตัวเอง passive income"},
    }

    FREELANCE = {
        "how_to_start": [
            "สร้าง MQL5.com account + verify ตัวตน",
            "แชร์ code ฟรีใน Code Base สร้าง portfolio",
            "เริ่มรับงาน Freelance เล็กๆ ($50-200)",
            "สะสม reviews ดีๆ → ได้งานใหญ่ขึ้น",
            "ขายผลงานใน Market สร้าง passive income",
        ],
        "pricing": {
            "simple_ea": "$100-500 (EA ง่ายๆ)",
            "complex_ea": "$500-2,000 (EA ซับซ้อน + optimization)",
            "indicator": "$50-300",
            "conversion": "$100-500 (แปลง MQL4 → MQL5)",
        },
    }

    def show_sections(self):
        print("=== Forum Sections ===\n")
        for key, section in self.SECTIONS.items():
            print(f"  [{section['name']}] {section['tip']}")

    def show_freelance(self):
        print(f"\n=== Freelance Guide ===")
        for step in self.FREELANCE["how_to_start"]:
            print(f"  • {step}")
        print(f"\n  Pricing:")
        for job, price in self.FREELANCE["pricing"].items():
            print(f"    {job}: {price}")

tips = ForumTips()
tips.show_sections()
tips.show_freelance()

FAQ - คำถามที่พบบ่อย

Q: MQL5 กับ MQL4 ต่างกันอย่างไร?

A: MQL5: OOP support, multi-threading, hedging + netting, faster execution, more order types MQL4: ง่ายกว่า, legacy code เยอะ, hedging only, ยังใช้กันมาก แนะนำ: เรียน MQL5 — เป็นอนาคต และ backward compatible กับ MT4 ได้บางส่วน

Q: EA เทรดอัตโนมัติเชื่อถือได้ไหม?

A: ขึ้นอยู่กับ EA — ไม่ใช่ทุกตัวจะทำกำไร ก่อนใช้: backtest อย่างน้อย 2-3 ปี, forward test บน demo 3+ เดือน ระวัง: curve-fitted EA (ดีเฉพาะ backtest), Martingale EA (เสี่ยงล้างพอร์ต) ดูตัวเลข: profit factor > 1.5, max drawdown < 20%, win rate + RR ratio สมเหตุสมผล

Q: เรียน MQL5 จากไหน?

A: Official: mql5.com/en/docs (documentation ครบสมบูรณ์) Tutorials: mql5.com/en/articles (บทความ 5,000+) Forum: mql5.com/en/forum (ถามตอบ) YouTube: หลาย channels สอน MQL5 หนังสือ: MQL5 Programming for Traders (Andrew Young) เริ่มจาก: เรียน C/C++ basics → MQL5 documentation → ลองเขียน simple EA

Q: ขาย EA ใน MQL5 Market ได้เงินเท่าไหร่?

A: ราคา EA: $30-$5,000+ (ขึ้นกับ complexity และ track record) MQL5 Market หัก 20% commission Developer ที่ประสบความสำเร็จ: $1,000-$50,000+/เดือน ต้องมี: verified backtest, good reviews, marketing, support ลูกค้า ความเป็นจริง: ส่วนใหญ่ทำได้ $100-1,000/เดือน — ต้องอดทนสร้าง reputation

📖 บทความที่เกี่ยวข้อง

arimbi mql5อ่านบทความ → copy trade mql5อ่านบทความ → mql5 metatrader 5อ่านบทความ → mql5 ctrade exampleอ่านบทความ → mql5 indicatorอ่านบทความ →

📚 ดูบทความทั้งหมด →