Hi,
I'm a beginner and wrote an EA, saved, compile, and it came back with no errors, loaded on tester. the inputs are there, but it doesn't do any trading. Does anyone can helpe me?
There could be a lot of possibilities. Check your position size, or maybe you have incorect symbol, or stops or timeframe, or maybe your contition to entry not met so you didnt get signal ... You need to describe us some more about the problem or part of your code.
Hello everyone!
EA after compiled with no errors, saved, with all the imputs, is not trading on tester. Does someone can helpe me? Attached the code file.
oh! for so many reasons. Here are just the main 1...
in mql5 you have to use handles. Search the website for online documents to learn what these are and how to use them.
Hi,
I'm a beginner and wrote an EA, saved, compile, and it came back with no errors, loaded on tester. the inputs are there, but it doesn't do any trading. Does anyone can helpe me?
do not make multiple posts/threads about the same issue. Moderators will probably delete 1 of them. Hopefully they do not delete your other thread where I responded to your question.
Hello Michael,
Thank you very much for your help, I added the handles but it still not doing tradings. Do you have any other tip that would help out? Thanks in advance!
Hello Michael,
Thank you very much for your help, I added the handles but it still not doing tradings. Do you have any other tip that would help out? Thanks in advance!
post your code with the code button.
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ input double lotSize = 0.1; // Lot size input double takeProfitPips = 50; // Take Profit in pips input double stopLossPips = 30; // Stop Loss in pips input int maPeriodFast = 50; // Fast moving average period input int maPeriodSlow = 100; // Slow moving average period input double volumeMultiplier = 1.0; // Volume multiplier input double slippage = 3; // Slippage in pips int maFastHandle; int maSlowHandle; int OnInit() { // Create handles for moving averages maFastHandle = iMA(Symbol(), PERIOD_H1, maPeriodFast, 0, MODE_SMA, PRICE_CLOSE); maSlowHandle = iMA(Symbol(), PERIOD_H1, maPeriodSlow, 0, MODE_SMA, PRICE_CLOSE); if (maFastHandle == INVALID_HANDLE || maSlowHandle == INVALID_HANDLE) { Print("Error creating indicator handles"); return(INIT_FAILED); } return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { // Release indicator handles if (maFastHandle != INVALID_HANDLE) IndicatorRelease(maFastHandle); if (maSlowHandle != INVALID_HANDLE) IndicatorRelease(maSlowHandle); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { // Trading parameters double takeProfitPrice = 0.0; double stopLossPrice = 0.0; // Technical indicators double maFast[], maSlow[]; if (CopyBuffer(maFastHandle, 0, 0, 2, maFast) <= 0 || CopyBuffer(maSlowHandle, 0, 0, 2, maSlow) <= 0) { Print("Error copying indicator data"); return; } // Variables for crossover double maFastPrev = maFast[1]; double maSlowPrev = maSlow[1]; double maFastCurrent = maFast[0]; double maSlowCurrent = maSlow[0]; // Get current Ask and Bid prices double Ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK); double Bid = SymbolInfoDouble(Symbol(), SYMBOL_BID); // Adjust lot size based on volume multiplier double adjustedLotSize = lotSize * volumeMultiplier; // Ensure adjustedLotSize and slippage are within the range of ulong ulong volume = (ulong)MathMax(0, MathMin(adjustedLotSize, (double)ULONG_MAX)); ulong deviation = (ulong)MathMax(0, MathMin(slippage, (double)ULONG_MAX)); // Buy entry condition if (maFastCurrent > maSlowCurrent && maFastPrev <= maSlowPrev) { takeProfitPrice = NormalizeDouble(Ask + takeProfitPips * _Point, _Digits); stopLossPrice = NormalizeDouble(Ask - stopLossPips * _Point, _Digits); // OrderSend structure for MQL5 MqlTradeRequest request; MqlTradeResult result; request.action = TRADE_ACTION_DEAL; request.symbol = Symbol(); request.volume = volume; request.price = NormalizeDouble(Ask, _Digits); request.tp = takeProfitPrice; request.sl = stopLossPrice; request.deviation = deviation; request.type = ORDER_TYPE_BUY; if (!OrderSend(request, result)) { Print("Error opening buy order: ", GetLastError()); } else { Print("Buy order opened successfully"); } // Buy signal string buyArrowName = "BuyArrow" + TimeToString(TimeCurrent(), TIME_DATE | TIME_MINUTES); ObjectCreate(0, buyArrowName, OBJ_ARROW, 0, TimeCurrent(), Bid); ObjectSetInteger(0, buyArrowName, OBJPROP_ARROWCODE, 233); // Up arrow code ObjectSetInteger(0, buyArrowName, OBJPROP_COLOR, clrGreen); } // Sell entry condition if (maFastCurrent < maSlowCurrent && maFastPrev >= maSlowPrev) { takeProfitPrice = NormalizeDouble(Bid - takeProfitPips * _Point, _Digits); stopLossPrice = NormalizeDouble(Bid + stopLossPips * _Point, _Digits); // OrderSend structure for MQL5 MqlTradeRequest request; MqlTradeResult result; request.action = TRADE_ACTION_DEAL; request.symbol = Symbol(); request.volume = volume; request.price = NormalizeDouble(Bid, _Digits); request.tp = takeProfitPrice; request.sl = stopLossPrice; request.deviation = deviation; request.type = ORDER_TYPE_SELL; if (!OrderSend(request, result)) { Print("Error opening sell order: ", GetLastError()); } else { Print("Sell order opened successfully"); } // Sell signal string sellArrowName = "SellArrow" + TimeToString(TimeCurrent(), TIME_DATE | TIME_MINUTES); ObjectCreate(0, sellArrowName, OBJ_ARROW, 0, TimeCurrent(), Ask); ObjectSetInteger(0, sellArrowName, OBJPROP_ARROWCODE, 234); // Down arrow code ObjectSetInteger(0, sellArrowName, OBJPROP_COLOR, clrRed); } } //+------------------------------------------------------------------+ //| Tester function | //+------------------------------------------------------------------+ double OnTester() { // Function called during the test return 0.0; } //+------------------------------------------------------------------+ //| Tester initialization function | //+------------------------------------------------------------------+ void OnTesterInit() { // Test initialization } //+------------------------------------------------------------------+ //| Tester pass function | //+------------------------------------------------------------------+ void OnTesterPass() { // Function called on each test pass } //+------------------------------------------------------------------+ //| Tester deinitialization function | //+------------------------------------------------------------------+ void OnTesterDeinit() { // Test deinitialization } //+------------------------------------------------------------------+ //| Chart event function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { // Function called on chart events Print("Chart event: ", id); } //+------------------------------------------------------------------+ //| Book event function | //+------------------------------------------------------------------+ void OnBookEvent(const string &symbol) { // Function called on book events Print("Book event for symbol: ", symbol); } //+------------------------------------------------------------------+
If you add me like a friend I woud like to talk with you in private. Is that ok?
no, it is not ok. i hate using chat services, here, or facebook.
as i said, too many issues. Here are just a few...
1) open a buy at ask price; close at bid price. open sell trade at bid price, close at ask price.
2) double maFast[], maSlow[] move to global enviro.
3) the ulong lines change to double
4) no need for the functions below Ontick.
good luck, but am offline for weekend.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone!
EA after compiled with no errors, saved, with all the imputs, is not trading on tester. Does someone can helpe me? Attached the code file.