Version 2.11 2025.09.22
🆕 New Features

Added configurable wait time before order processing resets

The EA now waits a user-defined time after all positions are closed before resetting processedOrders.

Prevents immediate re-entry and allows better control over signal timing.
Version 2.10 2025.09.22
//+------------------------------------------------------------------+
//| Version 2.10 |
//| Author: Santi Maliprom |
//| Developed from version 2.2 |
//+------------------------------------------------------------------+
//| Description: |
//| This Expert Advisor (EA) trades XAUUSD and BTCUSDm using |
//| a combination of EMA200 trend detection and swing high/low |
//| signals. |
//| |
//| Features: |
//| 1. Automatic Buy/Sell signals based on EMA200 trend and |
//| swing high/low patterns. |
//| 2. StopLoss per symbol (XAUUSD/BTCUSDm) with adjustable |
//| TakeProfit ratio. |
//| 3. Lot size automatically adjusted to broker minimum, maximum, |
//| and step values. |
//| 4. Hedging-safe: closes opposite positions if hedging is not |
//| allowed on the account. |
//| 5. MaxOrders enforced: if the number of positions exceeds MaxOrders, |
//| the oldest positions are closed first. |
//| 6. Automatic SL/TP modification for existing positions. |
//| |
//| Development notes: |
//| - Version 2.10: fully rewritten and optimized from version 2.2. |
//| Main improvements: |
//| * Optimized oldest position closure logic using struct array. |
//| * Clean, English-only code with clear naming conventions. |
// * Improved lot and stop adjustment functions. |
//| * Better signal generation and position management. |
//+------------------------------------------------------------------+
Version 2.9 2025.09.22
สิ่งที่ปรับปรุง

เพิ่มฟังก์ชัน สำหรับ ตรวจสอบ SL/TP ตาม StopLevel ของโบรกเกอร์ → ลดปัญหา Invalid Stops

รองรับ Hedging โดยปิด opposite positions หากโบรกเกอร์ไม่อนุญาต hedging

ฟีเจอร์ รอ WaitHours หลังปิด order พร้อม แจ้งเตือนผ่าน Alert/Print

รองรับ XAUUSD/D1, BTCUSDm โดยไม่เกิด error modify order
Version 2.8 2025.09.22
XAUUSD + BTCUSDm Hedging-Safe v2.08
EA สำหรับเทรดทองและ BTC แบบ Hedging-Safe พร้อม Auto-Close

คำอธิบาย (Description)

ภาษาไทย:
EA นี้ออกแบบสำหรับเทรด XAUUSD และ BTCUSDm โดยใช้แนวทาง Swing + EMA200 เพื่อหาสัญญาณซื้อขาย

เปิดออร์เดอร์ Buy/Sell อัตโนมัติเมื่อมีสัญญาณ

Auto-Close on Reverse Signal: ปิดออร์เดอร์ตรงข้ามทันทีเมื่อเกิดสัญญาณใหม่

รองรับ หลายสัญญาณต่อแท่งเดียว

ปรับ SL/TP ตามจุด StopLevel ของ Broker และอัตราส่วน TP/SL

รองรับ Hedging / Non-Hedging Broker

จำกัดจำนวนออร์เดอร์สูงสุดตามตัวแปร Ord

รองรับ Lot size ปรับอัตโนมัติตาม Broker

คุณสมบัติสำคัญ:

ตรวจจับ Swing High/Low เพื่อหาจุดกลับตัว

EMA200 สำหรับ Trend Filter

ป้องกันเปิดซ้ำใน Tick เดียว

ปิดออร์เดอร์อัตโนมัติเมื่อเกิดสัญญาณตรงข้าม

รองรับ XAUUSD และ BTCUSDm

ภาษาอังกฤษ:
This EA is designed for trading XAUUSD and BTCUSDm using Swing + EMA200 strategy to generate buy/sell signals.

Automatically opens Buy/Sell orders when a signal appears.

Auto-Close on Reverse Signal: closes opposite positions immediately when a new signal occurs.

Supports multiple signals in the same bar.

Adjusts SL/TP based on Broker StopLevel and TP/SL ratio.

Works with Hedging and Non-Hedging accounts.

Limits maximum open positions with Ord variable.

Lot size auto-adjusts according to Broker.

Key Features:

Detect Swing High/Low for reversal points.

EMA200 as trend filter.

Prevents duplicate orders in the same tick.

Auto-close opposite orders on reverse signal.

Supports XAUUSD and BTCUSDm symbols.

Usage Instructions (คู่มือการใช้งาน):

ใส่ EA บน XAUUSD หรือ BTCUSDm chart เท่านั้น

ตั้งค่า LotSize, SL_XAU, SL_BTC, TP_Ratio, Ord, SwingLookback ตามต้องการ

EA จะเปิด/ปิดออร์เดอร์อัตโนมัติ และ Log รายละเอียดใน Terminal

Attach the EA to XAUUSD or BTCUSDm chart only.

Set LotSize, SL_XAU, SL_BTC, TP_Ratio, Ord, SwingLookback as desired.

The EA will manage positions automatically and log all actions in the Terminal.
Version 2.4 2025.09.22
XAUUSD + BTCUSDm Hedging-Safe v2.04
EA สำหรับเทรดทองและ BTC แบบ Hedging-Safe พร้อม Auto-Close

คำอธิบาย (Description)

ภาษาไทย:
EA นี้ออกแบบสำหรับเทรด XAUUSD และ BTCUSDm โดยใช้แนวทาง Swing + EMA200 เพื่อหาสัญญาณซื้อขาย

เปิดออร์เดอร์ Buy/Sell อัตโนมัติเมื่อมีสัญญาณ

Auto-Close on Reverse Signal: ปิดออร์เดอร์ตรงข้ามทันทีเมื่อเกิดสัญญาณใหม่

รองรับ หลายสัญญาณต่อแท่งเดียว

ปรับ SL/TP ตามจุด StopLevel ของ Broker และอัตราส่วน TP/SL

รองรับ Hedging / Non-Hedging Broker

จำกัดจำนวนออร์เดอร์สูงสุดตามตัวแปร Ord

รองรับ Lot size ปรับอัตโนมัติตาม Broker

คุณสมบัติสำคัญ:

ตรวจจับ Swing High/Low เพื่อหาจุดกลับตัว

EMA200 สำหรับ Trend Filter

ป้องกันเปิดซ้ำใน Tick เดียว

ปิดออร์เดอร์อัตโนมัติเมื่อเกิดสัญญาณตรงข้าม

รองรับ XAUUSD และ BTCUSDm

ภาษาอังกฤษ:
This EA is designed for trading XAUUSD and BTCUSDm using Swing + EMA200 strategy to generate buy/sell signals.

Automatically opens Buy/Sell orders when a signal appears.

Auto-Close on Reverse Signal: closes opposite positions immediately when a new signal occurs.

Supports multiple signals in the same bar.

Adjusts SL/TP based on Broker StopLevel and TP/SL ratio.

Works with Hedging and Non-Hedging accounts.

Limits maximum open positions with Ord variable.

Lot size auto-adjusts according to Broker.

Key Features:

Detect Swing High/Low for reversal points.

EMA200 as trend filter.

Prevents duplicate orders in the same tick.

Auto-close opposite orders on reverse signal.

Supports XAUUSD and BTCUSDm symbols.

Usage Instructions (คู่มือการใช้งาน):

ใส่ EA บน XAUUSD หรือ BTCUSDm chart เท่านั้น

ตั้งค่า LotSize, SL_XAU, SL_BTC, TP_Ratio, Ord, SwingLookback ตามต้องการ

EA จะเปิด/ปิดออร์เดอร์อัตโนมัติ และ Log รายละเอียดใน Terminal

Attach the EA to XAUUSD or BTCUSDm chart only.

Set LotSize, SL_XAU, SL_BTC, TP_Ratio, Ord, SwingLookback as desired.

The EA will manage positions automatically and log all actions in the Terminal.