From 70b8a1a56e27e3b88bc85e6ef92f9c95471a3be2 Mon Sep 17 00:00:00 2001 From: Bell Date: Tue, 21 Oct 2025 11:24:51 +0700 Subject: [PATCH] Fix bug emaFilter --- Experts/BellPriceActionWithEma50EA.mq5 | Bin 26372 -> 26506 bytes Experts/draft.txt | 13 ++++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Experts/BellPriceActionWithEma50EA.mq5 b/Experts/BellPriceActionWithEma50EA.mq5 index 8a29e0544aa086b07e67f24494a8f428895cddc7..6f67e77fed7e46d079231018dc0d41159ab0740b 100644 GIT binary patch delta 309 zcmZoU$JlkAal-_5M#IVd>}w}aU^m#D!%<=on8Z-Zkj7xjV89T~5X+#$puhkTF#?J} z#H<;38MuJrAc$aP0(EIHI5Xrk6fjgWIDt(`V@PEvn*1Zvb?Y~ WP@HYDl@*sTx}Sman;EVC>i__MG&(K- delta 58 zcmV-A0LA}`&jEza0kDtO2gyt~%T-1PuTR0D|Wf#{d8T diff --git a/Experts/draft.txt b/Experts/draft.txt index b2771ea..ab9ed29 100644 --- a/Experts/draft.txt +++ b/Experts/draft.txt @@ -16,8 +16,8 @@ CTrade trade; // ================== INPUTS ========================================= -input ENUM_TIMEFRAMES TrendTF = PERIOD_M5; // khung thời gian dùng để lọc xu hướng -input ENUM_TIMEFRAMES EntryTF = PERIOD_M1; // khung thời gian để tìm điểm vào +input ENUM_TIMEFRAMES TrendTF = PERIOD_M15; // khung thời gian dùng để lọc xu hướng +input ENUM_TIMEFRAMES EntryTF = PERIOD_M5; // khung thời gian để tìm điểm vào input int EMA_Fast = 50; // EMA nhanh input int EMA_Slow = 200; // EMA chậm input double RiskPercent = 1.0; // rủi ro % equity cho mỗi lệnh @@ -186,8 +186,12 @@ double CalculateLotByRisk(double riskPercent, double stopLossPoints) { // -1 -> chỉ cho SELL // 0 -> không rõ xu hướng int EMAFilter() { - double ema50 = iMA(_Symbol, TrendTF, EMA_Fast, 0, MODE_EMA, PRICE_CLOSE); - double ema200 = iMA(_Symbol, TrendTF, EMA_Slow, 0, MODE_EMA, PRICE_CLOSE); + double buf50[], buf200[]; + + if(CopyBuffer(handleEMA50, 0, 1, 1, buf50) <= 0) return 0; + if(CopyBuffer(handleEMA200, 0, 1, 1, buf200) <= 0) return 0; + double ema50 = buf50[0]; + double ema200 = buf200[0]; if(ema50 == 0 || ema200 == 0) return 0; @@ -352,4 +356,3 @@ void OnDeinit(const int reason) if(handleEMA50 != INVALID_HANDLE) IndicatorRelease(handleEMA50); if(handleEMA200 != INVALID_HANDLE) IndicatorRelease(handleEMA200); } -