คำสั่ง Pending Order คืออะไร
Pending Order เป็นคำสั่งซื้อขายล่วงหน้าใน Forex trading ที่ตั้งไว้ให้ทำงานอัตโนมัติเมื่อราคาถึงระดับที่กำหนด แทนที่จะเปิด order ทันทีที่ราคาปัจจุบัน (Market Order) trader สามารถตั้ง Pending Order เพื่อเข้า position ที่ราคาที่ต้องการในอนาคต
Pending Orders มี 4 ประเภทหลัก ได้แก่ Buy Limit ตั้งซื้อที่ราคาต่ำกว่าราคาปัจจุบัน, Sell Limit ตั้งขายที่ราคาสูงกว่าราคาปัจจุบัน, Buy Stop ตั้งซื้อที่ราคาสูงกว่าราคาปัจจุบัน และ Sell Stop ตั้งขายที่ราคาต่ำกว่าราคาปัจจุบัน ในบทความนี้จะเน้นเปรียบเทียบ Buy Limit กับ Buy Stop ซึ่งเป็นคำสั่งที่ trader ใหม่มักสับสนมากที่สุด
ข้อดีของ Pending Orders ได้แก่ ไม่ต้องนั่งเฝ้าหน้าจอรอราคาถึงจุดที่ต้องการ, ลด emotional trading เพราะวางแผนล่วงหน้า, ได้ราคาที่ต้องการแม่นยำกว่า Market Order, สามารถตั้ง Stop Loss และ Take Profit พร้อมกันได้ และ ทำงานอัตโนมัติแม้ปิดคอมพิวเตอร์ (order อยู่ที่ server ของ broker)
Buy Limit คืออะไร
Buy Limit เป็นคำสั่งซื้อที่ตั้งไว้ที่ราคาต่ำกว่าราคาปัจจุบัน ใช้เมื่อ trader คาดว่าราคาจะลงมาถึงจุดหนึ่งแล้วกลับตัวขึ้น เป็นกลยุทธ์ Buy the Dip หรือซื้อตอนราคาย่อ
ตัวอย่างเช่น EUR/USD ราคาปัจจุบัน 1.0900 trader วิเคราะห์แล้วเห็นว่า support อยู่ที่ 1.0850 คาดว่าราคาจะลงมาแตะ support แล้วเด้งขึ้น จึงตั้ง Buy Limit ที่ 1.0850 เมื่อราคาลงมาถึง 1.0850 order จะ trigger อัตโนมัติ
สถานการณ์ที่เหมาะใช้ Buy Limit ได้แก่ ซื้อที่แนว support ใน uptrend, ซื้อที่ Fibonacci retracement levels (38.2%, 50%, 61.8%), ซื้อที่ demand zone ใน supply and demand trading, ซื้อเมื่อราคา pullback ใน trend following strategy
Buy Stop คืออะไร
Buy Stop เป็นคำสั่งซื้อที่ตั้งไว้ที่ราคาสูงกว่าราคาปัจจุบัน ใช้เมื่อ trader คาดว่าราคาจะทะลุ resistance ขึ้นไปต่อ เป็นกลยุทธ์ Breakout Trading
ตัวอย่างเช่น EUR/USD ราคาปัจจุบัน 1.0900 trader วิเคราะห์แล้วเห็นว่า resistance อยู่ที่ 1.0950 คาดว่าถ้าราคาทะลุ 1.0950 ขึ้นไปได้จะวิ่งต่อ จึงตั้ง Buy Stop ที่ 1.0950 เมื่อราคาขึ้นถึง 1.0950 order จะ trigger อัตโนมัติ
สถานการณ์ที่เหมาะใช้ Buy Stop ได้แก่ Breakout trading เมื่อราคาทะลุ resistance, ซื้อเมื่อราคาทะลุ channel หรือ triangle pattern, News trading เมื่อคาดว่าข่าวจะทำให้ราคาวิ่งขึ้น, Momentum trading เมื่อราคากำลัง trend ขึ้นแรง
เปรียบเทียบ Buy Limit vs Buy Stop
เปรียบเทียบรายละเอียด
# === Buy Limit vs Buy Stop Comparison ===
# Buy Limit:
# - ราคาตั้ง: ต่ำกว่าราคาปัจจุบัน
# - Strategy: Buy the Dip / Reversal
# - คาดการณ์: ราคาจะลงมาแล้วกลับตัวขึ้น
# - Risk: ราคาอาจลงต่อไม่กลับตัว
# - Entry: ได้ราคาดี (ต่ำ)
# - Slippage: น้อย (ราคามาหา order)
# Buy Stop:
# - ราคาตั้ง: สูงกว่าราคาปัจจุบัน
# - Strategy: Breakout / Momentum
# - คาดการณ์: ราคาจะทะลุขึ้นไปต่อ
# - Risk: อาจเป็น false breakout
# - Entry: ราคาสูงกว่า (แต่มี momentum)
# - Slippage: อาจมาก (ตอน breakout volatility สูง)
# === ตัวอย่าง Scenarios ===
# Scenario 1: Uptrend Pullback
# ===================================
# EUR/USD uptrend, ราคาปัจจุบัน 1.0900
# Support: 1.0850 | Resistance: 1.0950
#
# Buy Limit Strategy:
# Entry: 1.0850 (รอราคาย่อมาที่ support)
# Stop Loss: 1.0800 (ใต้ support 50 pips)
# Take Profit: 1.0950 (ที่ resistance)
# Risk: 50 pips | Reward: 100 pips | RR = 1:2
#
# Buy Stop Strategy:
# Entry: 1.0955 (เหนือ resistance 5 pips)
# Stop Loss: 1.0900 (ใต้ breakout level)
# Take Profit: 1.1050 (target distance = resistance range)
# Risk: 55 pips | Reward: 95 pips | RR = 1:1.7
# Scenario 2: Range Trading
# ===================================
# USD/JPY sideways, range 149.00 - 150.00
#
# Buy Limit: ตั้งที่ 149.10 (ใกล้ bottom ของ range)
# SL: 148.80 | TP: 149.90 | RR = 1:2.7
#
# Buy Stop: ตั้งที่ 150.10 (breakout เหนือ range)
# SL: 149.70 | TP: 151.00 | RR = 1:2.3
# Scenario 3: News Event
# ===================================
# NFP release, GBP/USD ปัจจุบัน 1.2700
# คาดว่า NFP ดีจะทำให้ USD แข็ง
#
# Buy Stop ไม่เหมาะ (ต้อง Buy USD = Sell GBP/USD)
# Sell Stop: 1.2650 (breakout ลง)
# หรือถ้าคาดว่า NFP แย่:
# Buy Stop: 1.2750 (GBP/USD วิ่งขึ้น)
echo "Comparison complete"
ตัวอย่างการใช้งานจริงด้วย MQL4
เขียน Expert Advisor สำหรับ Pending Orders
// === MQL4 Pending Order Examples ===
// 1. Buy Limit Order
// ===================================
// int ticket = OrderSend(
// Symbol(), // Currency pair
// OP_BUYLIMIT, // Order type
// 0.1, // Lot size
// 1.0850, // Entry price (below current)
// 3, // Slippage
// 1.0800, // Stop Loss
// 1.0950, // Take Profit
// "Buy Limit at Support", // Comment
// 12345, // Magic number
// D'2025.01.20 23:59', // Expiration
// clrGreen // Arrow color
// );
// 2. Buy Stop Order
// ===================================
// int ticket = OrderSend(
// Symbol(),
// OP_BUYSTOP, // Order type
// 0.1,
// 1.0955, // Entry price (above current)
// 3,
// 1.0900, // Stop Loss
// 1.1050, // Take Profit
// "Buy Stop Breakout",
// 12345,
// D'2025.01.20 23:59',
// clrBlue
// );
// 3. Smart Pending Order EA
// ===================================
// Expert Advisor ที่เลือก Buy Limit หรือ Buy Stop อัตโนมัติ
// #property copyright "Trading Bot"
// #property version "1.00"
//
// input double LotSize = 0.01;
// input int StopLossPips = 50;
// input int TakeProfitPips = 100;
// input int PendingDistancePips = 50;
// input int ExpirationHours = 24;
// input int MagicNumber = 20250115;
//
// int OnInit() {
// return INIT_SUCCEEDED;
// }
//
// void OnTick() {
// if (OrdersTotal() > 0) return; // Only 1 order at a time
//
// double point = MarketInfo(Symbol(), MODE_POINT);
// double digits = MarketInfo(Symbol(), MODE_DIGITS);
// double pip = (digits == 3 || digits == 5) ? point * 10 : point;
//
// double currentPrice = Ask;
// double distance = PendingDistancePips * pip;
//
// // Determine trend using Moving Average
// double ma50 = iMA(Symbol(), PERIOD_H1, 50, 0, MODE_SMA, PRICE_CLOSE, 0);
// double ma200 = iMA(Symbol(), PERIOD_H1, 200, 0, MODE_SMA, PRICE_CLOSE, 0);
//
// datetime expiration = TimeCurrent() + ExpirationHours * 3600;
//
// if (currentPrice > ma50 && ma50 > ma200) {
// // Uptrend: Use Buy Limit (buy on pullback)
// double entryPrice = NormalizeDouble(currentPrice - distance, digits);
// double sl = NormalizeDouble(entryPrice - StopLossPips * pip, digits);
// double tp = NormalizeDouble(entryPrice + TakeProfitPips * pip, digits);
//
// int ticket = OrderSend(Symbol(), OP_BUYLIMIT, LotSize,
// entryPrice, 3, sl, tp, "BuyLimit Pullback",
// MagicNumber, expiration, clrGreen);
//
// if (ticket > 0)
// Print("Buy Limit placed at ", entryPrice);
// else
// Print("Error: ", GetLastError());
// }
// else if (currentPrice < ma50 && currentPrice > ma200) {
// // Consolidation: Use Buy Stop (breakout above MA50)
// double entryPrice = NormalizeDouble(ma50 + 5 * pip, digits);
// double sl = NormalizeDouble(entryPrice - StopLossPips * pip, digits);
// double tp = NormalizeDouble(entryPrice + TakeProfitPips * pip, digits);
//
// int ticket = OrderSend(Symbol(), OP_BUYSTOP, LotSize,
// entryPrice, 3, sl, tp, "BuyStop Breakout",
// MagicNumber, expiration, clrBlue);
//
// if (ticket > 0)
// Print("Buy Stop placed at ", entryPrice);
// }
// }
// 4. Position Size Calculator
// ===================================
// double CalculateLotSize(double riskPercent, double slPips) {
// double balance = AccountBalance();
// double riskAmount = balance * riskPercent / 100;
// double tickValue = MarketInfo(Symbol(), MODE_TICKVALUE);
// double tickSize = MarketInfo(Symbol(), MODE_TICKSIZE);
// double pipValue = tickValue * (0.0001 / tickSize);
//
// double lots = riskAmount / (slPips * pipValue);
// lots = NormalizeDouble(lots, 2);
//
// double minLot = MarketInfo(Symbol(), MODE_MINLOT);
// double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);
//
// if (lots < minLot) lots = minLot;
// if (lots > maxLot) lots = maxLot;
//
// return lots;
// }
Print("MQL4 examples defined");
Risk Management และ Position Sizing
จัดการความเสี่ยงสำหรับ Pending Orders
#!/usr/bin/env python3
# risk_calculator.py — Forex Risk Management Calculator
import json
import logging
from typing import Dict
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("risk")
class ForexRiskCalculator:
def __init__(self, balance, risk_pct=1.0):
self.balance = balance
self.risk_pct = risk_pct
def calculate_position_size(self, entry, stop_loss, pair="EURUSD"):
pip_value_per_lot = 10 # USD per pip per standard lot (for USD pairs)
sl_pips = abs(entry - stop_loss) * 10000 # Convert to pips
risk_amount = self.balance * (self.risk_pct / 100)
lot_size = risk_amount / (sl_pips * pip_value_per_lot)
lot_size = round(lot_size, 2)
return {
"pair": pair,
"balance": self.balance,
"risk_pct": self.risk_pct,
"risk_amount": round(risk_amount, 2),
"entry": entry,
"stop_loss": stop_loss,
"sl_pips": round(sl_pips, 1),
"lot_size": lot_size,
"lot_type": "standard" if lot_size >= 1 else "mini" if lot_size >= 0.1 else "micro",
}
def compare_buy_limit_vs_stop(self, current_price, support, resistance):
# Buy Limit at support
buy_limit = self.calculate_position_size(
entry=support,
stop_loss=support - 0.0050 # 50 pips below support
)
buy_limit["order_type"] = "Buy Limit"
buy_limit["take_profit"] = resistance
buy_limit["tp_pips"] = round((resistance - support) * 10000, 1)
buy_limit["risk_reward"] = round(buy_limit["tp_pips"] / buy_limit["sl_pips"], 2)
# Buy Stop above resistance
buy_stop_entry = resistance + 0.0005 # 5 pips above resistance
buy_stop = self.calculate_position_size(
entry=buy_stop_entry,
stop_loss=current_price # Stop at previous price level
)
buy_stop["order_type"] = "Buy Stop"
buy_stop["take_profit"] = buy_stop_entry + (resistance - support)
buy_stop["tp_pips"] = round((buy_stop["take_profit"] - buy_stop_entry) * 10000, 1)
buy_stop["risk_reward"] = round(buy_stop["tp_pips"] / buy_stop["sl_pips"], 2)
return {
"current_price": current_price,
"support": support,
"resistance": resistance,
"buy_limit": buy_limit,
"buy_stop": buy_stop,
"recommendation": "Buy Limit" if buy_limit["risk_reward"] > buy_stop["risk_reward"] else "Buy Stop",
}
def max_daily_loss(self, max_trades=3):
per_trade_risk = self.balance * (self.risk_pct / 100)
daily_max = per_trade_risk * max_trades
return {
"balance": self.balance,
"risk_per_trade_pct": self.risk_pct,
"risk_per_trade_usd": round(per_trade_risk, 2),
"max_trades_per_day": max_trades,
"max_daily_loss_usd": round(daily_max, 2),
"max_daily_loss_pct": round(self.risk_pct * max_trades, 1),
}
calc = ForexRiskCalculator(balance=10000, risk_pct=1.0)
# Compare Buy Limit vs Buy Stop
comparison = calc.compare_buy_limit_vs_stop(
current_price=1.0900,
support=1.0850,
resistance=1.0950
)
print(json.dumps(comparison, indent=2))
# Position sizing
print(json.dumps(calc.calculate_position_size(1.0850, 1.0800), indent=2))
print(json.dumps(calc.max_daily_loss(), indent=2))
FAQ คำถามที่พบบ่อย
Q: Buy Limit กับ Buy Stop อันไหนดีกว่า?
A: ไม่มีอันไหนดีกว่า ขึ้นกับ strategy และสถานการณ์ตลาด Buy Limit ดีสำหรับ trend following ที่รอ pullback ได้ราคาเข้าที่ดีกว่า risk/reward ratio สูงกว่า แต่ order อาจไม่ trigger ถ้าราคาไม่ลงมาถึง Buy Stop ดีสำหรับ breakout trading ได้ momentum ที่แรง order trigger เมื่อ market เคลื่อนไหว แต่อาจ false breakout ได้ แนะนำเริ่มจาก Buy Limit เพราะ risk/reward ดีกว่าสำหรับมือใหม่
Q: ควรตั้ง Expiration ของ Pending Order ไหม?
A: ควรตั้ง Expiration เสมอ เหตุผลหลัก สภาพตลาดเปลี่ยนแปลงตลอดเวลา analysis ที่ทำวันนี้อาจไม่ valid พรุ่งนี้ ถ้าไม่ตั้ง expiration order อาจ trigger ในสถานการณ์ที่ไม่เหมาะสม แนะนำ Day trading ตั้ง expiration ภายในวัน, Swing trading ตั้ง 1-3 วัน, Position trading ตั้ง 1 สัปดาห์ ตรวจสอบ pending orders ทุกวันและยกเลิกถ้าสถานการณ์เปลี่ยน
Q: Slippage ของ Buy Limit กับ Buy Stop ต่างกันไหม?
A: ต่างกัน Buy Limit มักมี slippage น้อยกว่าหรือได้ราคาดีกว่า (positive slippage) เพราะราคาเคลื่อนที่มาหา order เมื่อ trigger จะได้ราคาที่ตั้งไว้หรือดีกว่า Buy Stop มักมี slippage มากกว่า (negative slippage) โดยเฉพาะตอน breakout ที่ volatility สูง ราคาอาจกระโดดข้าม level ที่ตั้งไว้ทำให้ได้ราคาแย่กว่าที่ตั้ง สำหรับ Buy Stop ควรรวม slippage ไว้ใน risk calculation ด้วย
Q: Pending Order ปลอดภัยไหมถ้าปิดคอมพิวเตอร์?
A: ปลอดภัย Pending Orders ถูกเก็บไว้ที่ server ของ broker ไม่ใช่ที่คอมพิวเตอร์ของ trader เมื่อราคาถึง level ที่ตั้งไว้ broker จะ execute order อัตโนมัติ รวมถึง Stop Loss และ Take Profit ด้วย ข้อยกเว้นคือ gap (ราคากระโดดข้ามวัน) อาจทำให้ Stop Loss trigger ที่ราคาแย่กว่าที่ตั้งไว้ ส่วน Expert Advisors (EA) ต้องเปิด MT4 ไว้ตลอดหรือใช้ VPS
Q: ควรใช้ Pending Order กี่ตัวพร้อมกัน?
A: ขึ้นกับ balance และ risk management ไม่ควรมี risk มากกว่า 5% ของ balance ทั้งหมดในเวลาเดียวกัน ถ้า risk per trade 1% ก็มีได้ 5 pending orders พร้อมกัน แต่ระวังว่า pending orders ทั้งหมดอาจ trigger พร้อมกันในบาง scenarios (เช่น flash crash) ควร diversify pairs ไม่ตั้ง pending orders บน correlated pairs หลายตัว เช่น EUR/USD กับ GBP/USD พร้อมกัน
