On compiling : //+------------------------------------------------------------------+ //…
- User
On compiling : //+------------------------------------------------------------------+ //| MT5-Scalper-EA-FINAL.mq5 | //| Safe-stop, spread-filtered, 100-USD cent scalper | //+------------------------------------------------------------------+ #property copyright "2025" #property version "2.10" #property description "Scalps 0.01 lot with 20-pip TP/SL and spread filter" #property description "Designed for nano-cent account (1 000 US cents ≈ $10)"
#include <Trade\Trade.mqh>
//---- INPUTS input int FastMA = 5; // Fast EMA period input int SlowMA = 15; // Slow EMA period input int Slippage = 3; // Allowed slippage (points) input int TP_Pips = 20; // Take-profit (pips) input int SL_Pips = 20; // Stop-loss (pips) input int MaxSpread_Pips= 2; // Max allowed spread (pips) input int MagicNumber = 123456;
//---- GLOBALS CTrade trade; datetime last_bar = 0; //+------------------------------------------------------------------+ int OnInit() { trade.SetExpertMagicNumber(MagicNumber); trade.SetDeviationInPoints(Slippage);
Print("EA started on ", AccountInfoString(ACCOUNT_CURRENCY), " balance ", AccountInfoDouble(ACCOUNT_BALANCE)); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ void OnTick() { MqlRates rt[]; if(CopyRates(_Symbol,_Period,0,3,rt) < 3) return;
// run once per bar if(rt[1].time == last_bar) return; last_bar = rt[1].time;
// --- spread filter --- double spread = SymbolInfoDouble(_Symbol,SYMBOL_ASK) - SymbolInfoDouble(_Symbol,SYMBOL_BID); if(spread > MaxSpread_Pips * _Point) return;
// --- broker minimum stop distance --- int stopLevelPips = (int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL); double minDistPts = stopLevelPips * _Point;
// --- TP / SL in points --- double tpPts = MathMax(TP_Pips * _Point, minDistPts); double slPts = MathMax(SL_Pips * _Point, minDistPts);
// --- MA values (FIXED 6-parameter signature) --- //double emaFast = iMA(_Symbol,_Period,FastMA,0,MODE_EMA,PRICE_CLOSE,1); //double emaSlow = iMA(_Symbol,_Period,SlowMA,0,MODE_EMA,PRICE_CLOSE,1);
// --- correct 7-parameter iMA calls --- double emaFast = iMA(_Symbol, _Period, FastMA, 0, MODE_EMA, PRICE_CLOSE, 1); double emaSlow = iMA(_Symbol, _Period, SlowMA, 0, MODE_EMA, PRICE_CLOSE, 1);
double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
bool buy = emaFast > emaSlow; bool sell = emaFast < emaSlow;
// --- position management --- if(PositionsTotal()==0) { if(buy) trade.Buy(0.01,NULL,Ask,Ask-slPts,Ask+tpPts); else if(sell) trade.Sell(0.01,NULL,Bid,Bid+slPts,Bid-tpPts); } } //+------------------------------------------------------------------+
i get : 'MT5-Scalper-EA.mq5' 0 Trade.mqh Object.mqh StdLibErr.mqh OrderInfo.mqh HistoryOrderInfo.mqh PositionInfo.mqh DealInfo.mqh 'iMA' - wrong parameters count MT5-Scalper-EA.mq5 147 21 built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int) MT5-Scalper-EA.mq5 147 21 'iMA' - wrong parameters count MT5-Scalper-EA.mq5 148 21 built-in: int iMA(const string,ENUM_TIMEFRAMES,int,int,ENUM_MA_METHOD,int) MT5-Scalper-EA.mq5 148 21 2 errors, 0 warnings 2 0
- Assistant
- User
kindly provide the full updated code
- Assistant
- User
what does this mean:
2025.07.17 01:05:44.291 MetaTester 5 started on 127.0.0.1:3000 2025.07.17 01:05:44.301 cloud network mode is off 2025.07.17 01:05:44.301 initialization finished 2025.07.17 01:05:44.498 login (build 5120) 2025.07.17 01:05:45.309 26040 bytes of account info loaded 2025.07.17 01:05:45.309 1478 bytes of tester parameters loaded 2025.07.17 01:05:45.309 3780 bytes of input parameters loaded 2025.07.17 01:05:45.313 2612 bytes of symbols list loaded (334 symbols) 2025.07.17 01:05:45.313 expert file added: Experts\MT5-Scalper-EA.ex5. 25734 bytes loaded 2025.07.17 01:05:45.534 1529 Mb available, 18 blocks set for ticks generating 2025.07.17 01:05:45.534 calculate profit in pips, initial deposit 100, leverage 1:100 2025.07.17 01:05:45.542 successfully initialized 2025.07.17 01:05:45.542 30 Kb of total initialization data received 2025.07.17 01:05:45.543 Intel Core i5-8350U @ 1.70GHz, 7653 MB 2025.07.17 01:05:45.577 EURUSD: symbol to be synchronized 2025.07.17 01:05:45.579 EURUSD: symbol synchronized, 3720 bytes of symbol info received 2025.07.17 01:05:45.579 EURUSD: history synchronization started 2025.07.17 01:05:45.586 EURUSD: load 27 bytes of history data to synchronize in 0:00:00.005 2025.07.17 01:05:45.586 EURUSD: history synchronized from 2024.01.02 to 2025.07.16 2025.07.17 01:05:45.836 EURUSD,M1: history cache allocated for 570495 bars and contains 569466 bars from 2024.01.02 00:04 to 2025.07.14 23:59 2025.07.17 01:05:45.836 EURUSD,M1: history begins from 2024.01.02 00:04 2025.07.17 01:05:45.842 EURUSD,M1 (HFMarketsKE-Demo2): every tick generating 2025.07.17 01:05:45.842 testing with execution delay 138 milliseconds 2025.07.17 01:05:45.842 EURUSD,M1: testing of Experts\MT5-Scalper-EA.ex5 from 2025.07.15 00:00 to 2025.07.16 00:00 started with inputs: 2025.07.17 01:05:45.842 FastMA=5 2025.07.17 01:05:45.842 SlowMA=15 2025.07.17 01:05:45.842 Slippage=3 2025.07.17 01:05:45.842 TP_Pips=20 2025.07.17 01:05:45.842 SL_Pips=20 2025.07.17 01:05:45.842 MaxSpread_Pips=2 2025.07.17 01:05:45.842 MagicNumber=123456
- Assistant
- User
so it placed no trades ie :
2025.07.17 01:05:46.089 final balance 100.00 pips
- Assistant
Yes, exactly.
The message:
2025.07.17 01:05:46.089 final balance 100.00 pipsmeans the backtest finished with no change in balance or profit — it neither made profits nor losses.
If no trades were placed, possible reasons include:
-
Entry conditions never met during the test period:
-
- User
Add print/debug statements inside OnTick() to confirm code reaches trading logic,
- Assistant
- User
- Assistant
- User
kindly provide the full updated code
- Assistant
- User
id like all the wording and figures to be in points no pips
- Assistant
- User
how can i limit the EA to 5 trades per day
- Assistant
- User
kindly provide the full updated code
- Assistant
- User
edit the EA so that it makes 1 or more buy or sell trade as specfied at a particular specified time ie 12:30 AM
- Assistant
- User
since it making one trade at a specified time there should be not strategy to take trades so remove the ; input int FastMA = 5; // Fast EMA period input int SlowMA = 15; // Slow EMA period
LOGIC
- Assistant
- User
how can i remove these print outs as the trade is only made at a specifc time:
2025.07.17 02:15:17.396 2025.07.15 23:57:47 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:48 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:49 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:50 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:51 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:52 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:53 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:54 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:55 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:56 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:57 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.396 2025.07.15 23:57:59 Spread too high (26.0 points), skipping opening trades. 2025.07.17 02:15:17.397 2025.07.15 23:59:30 Spread too high (38.0 points), skipping opening trades.
- Assistant
- User
kindly provide the full updated code
- Assistant
- User
how can i edit the EA to include a trailing stop an will it conflict with the stoploss
- Assistant
- User
kindly provide the full updated code
- Assistant
- User
error on compiling:
Trade.mqh Object.mqh StdLibErr.mqh OrderInfo.mqh HistoryOrderInfo.mqh PositionInfo.mqh DealInfo.mqh 'PositionSelectByIndex' - undeclared identifier MT5-Scalper-EA-1-TRADE-PER-DAY.mq5 220 11 'i' - some operator expected MT5-Scalper-EA-1-TRADE-PER-DAY.mq5 220 33 possible loss of data due to type conversion from 'long' to 'double' MT5-Scalper-EA-1-TRADE-PER-DAY.mq5 233 24 implicit conversion from 'number' to 'string' MT5-Scalper-EA-1-TRADE-PER-DAY.mq5 247 45 implicit conversion from 'number' to 'string' MT5-Scalper-EA-1-TRADE-PER-DAY.mq5 263 45 2 errors, 3 warnings 2 3
- Assistant
- User
kindly provide the full updated code
- Assistant