- fated82: I used ChatGPT
Stop using ChatGPT/Copilot.
Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)ChatGPT (the worst), “Bots Builder”, “EA builder”, “EA Builder Pro”, EATree, “Etasoft forex generator”, “Forex Strategy Builder”, ForexEAdvisor (aka. ForexEAdvisor STRATEGY BUILDER, and Online Forex Expert Advisor Generator), ForexRobotAcademy.com, forexsb, “FX EA Builder”, fxDreema, Forex Generator, FxPro, “LP-MOBI”, Molanis, “Octa-FX Meta Editor”, Strategy Builder FX, “Strategy Quant”, “Visual Trader Studio”, “MQL5 Wizard”, etc., are all the same. You will get something quick, but then you will spend a much longer time trying to get it right, than if you learned the language up front, and then just wrote it.
Since you haven't learned MQL4/5, therefor there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
We are willing to HELP you when you post your attempt (using Code button) and state the nature of your problem, but we are not going to debug your hundreds of lines of code. You are essentially going to be on your own.
ChatGPT - Even it says do not use it for coding. *
- Mixing MT4 and MT5 code together.
- Creating multiple OnCalculate/OnTick functions.
- OnCalculate returning a double.
- Filling buffers with zero in OnInit (they have no size yet). Setting buffer elements to zero but not setting Empty Value to correspond.
- Calling undefined functions.
- Calling MT4 functions in MT5 code.
- Sometimes, not using strict (MT4 code).
- Code that will not compile.
- Creating code outside of functions. *
- Creating incomplete code. *
- Initialization of Global variables with non-constants. *
- Assigning a MT5 handle to a double or missing the buffer and bar indexes in a MT4 call. *
- Useing MT4 Trade Functions without first selecting an order. *
- Uses NULL in OrderSend. *
bot builder Creating two OnInit() functions. * EA builder EATree Uses objects on chart to save values — not persistent storage (files or GV+Flush.) No recovery (crash/power failure.) ForexEAdvisor - Non-updateing global variables.
- Compilation errors.
- Not checking return codes.
- Not reporting errors.
FX EA Builder - Not checking return codes.
- Loosing open tickets on terminal restart. No recovery (crash/power failure.)
- Not adjusting stops for the spread. *
- Using OrdersTotal directly.
- Using the old event handlers.
-
double fastEMA = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, 0); double slowEMA = iMA(NULL, 0, 400, 0, MODE_EMA, PRICE_CLOSE, 0);
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. I have moved this thread. -
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5 / MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum (2012)
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles (2014)
Hi
Chat GPT is not the best for coding yet as was mentioned above.
But regarding the problem only – 131 is the error with wrong lot size – so here you have wrong value of lot. Here atr value was used wrong – ATR return decimal values- so you should rather divide by point (not multiple). But here you should also include the tick value and tick size to calculate lot properly and I would also recommend using some function to normalize lot value (by step and min/max allowed lot size – normalization to 2 decimal places is not enough. Try something like this:
double lotSize = normalizeLots(AccountBalance() * 0.001 / (2*atr * MarketInfo(Symbol(), MODE_TICKVALUE)/MarketInfo(Symbol(), MODE_TICKSIZE))); double NormalizeLots(double lots){ double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP); lots = MathRound(lots/ls) * ls; double minLot = MarketInfo(Symbol(), MODE_MINLOT); double maxLot = MarketInfo(Symbol(), MODE_MAXLOT); if (lots < minLot) lots = minLot; if(lots>maxLot) lots=maxLot; return(lots); }Best Regards
BUT I have a coding background. I understand design overview, logic flow, on-tick, subroutines, calls, handles, variables, condtitional and if/else statements.....
And ChatGPT can spew out some really nice looking code, sometimes it even compiles - but it is a talking machine, not a thinking one. It does not and cannot think ahead of you and go "I should make sure that my lot-size is the minimum allowable by the broker", for instance.
You "COULD" ask it what the error means instead of asking it to fix the error
then once you understand the error, you "Could" ask it if there is a function or call that solves that error....
ChatGPT is an awesome tool for understanding code syntax, but you still have to know how to code 'something' before taking something like this on, because it's still kinda 'stupid'.
ChatGPT is a good TRANSLATOR (think literal word-for-word) but a near useless "INTERPRETER" (think adapting what's said to be culturally appropriate)
what I mean is in America "what do you do for a job?" is a valid conversation point - in the Netherlands, translated literally SAYS the same thing, but asking that question is like a sarcastic way of saying "You're broke, useless and can't get a real job". An interpreter would rephrase the question to "what is the field you've chosen to work in at the moment?" This is a limitation of ChatGPT.
Without a solid understanding of how to code in the first place, you're going to have a rough time.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all, need some help here.
I used ChatGPT to create an EA for me. It looks good but there are error 131 when I tried testing it with strategy Tester.
Apprantely my OrderSend command is wrong. Can someone look through the codes and let me know what is missing?
I am not a coder so if you can enlighten me with th right codes that would be great.
Thanks in advance.