That's ChatGPT code right ? (or build using some similar tool).
Hi Alain, it is.
TBH I found it to be tremendously useful. Not for outright coding, since so far as I can tell it can't do that very well and generates a lot of errors by mixing languages and sometimes it makes things up. Nonetheless when used in pieces like function by function, it is good at:
1) explaining functions and logic.
2) providing code and logic suggestions, helping suggest efficiencies.
3) debugging, to a certain extent, by offering suggestions on why things may not work.
I've found that all of that together has increased my understanding of the language considerably over the past couple of weeks, in a much more accessible fashion than simply reading the documentation here. While I can read code, it's not my "bread and butter" so I need a crutch basically to help me along.
That being said, it helped me through a lot of bugs but does not seem to be able to help me at this (I hope) last issue. At the end of the day experienced human coders are still required :)
Any thoughts on what the issue could be?
In parallel, I'm curious to know what made you think it might be an gpt generated code?
Have a great evening,
Cornelius
Why ChatGPT?
It is looking for what you can find too!
But if you find it here (e.g.: https://www.mql5.com/en/search#!keyword=ma%20cross), it will probably run, while ChatGPT will most likely never run.
Bear in mind there's virtually nothing that hasn't already been programmed for MT4/MT5 and is ready for you - copy & paste the fastest way to program :)
Hi Alain, it is.
TBH I found it to be tremendously useful. Not for outright coding, since so far as I can tell it can't do that very well and generates a lot of errors by mixing languages and sometimes it makes things up. Nonetheless when used in pieces like function by function, it is good at:
1) explaining functions and logic.
2) providing code and logic suggestions, helping suggest efficiencies.
3) debugging, to a certain extent, by offering suggestions on why things may not work.
I've found that all of that together has increased my understanding of the language considerably over the past couple of weeks, in a much more accessible fashion than simply reading the documentation here. While I can read code, it's not my "bread and butter" so I need a crutch basically to help me along.
That being said, it helped me through a lot of bugs but does not seem to be able to help me at this (I hope) last issue. At the end of the day experienced human coders are still required :)
Any thoughts on what the issue could be?
In parallel, I'm curious to know what made you think it might be an gpt generated code?
Have a great evening,
Cornelius
It's actually useless from my point of view. Of course, as a professional coder, it's hard for me to put myself in your shoes, but I am trying to understand, so thank you for the explanation.
This code will never work and to make it working you would have to learn the language or rely on someone else to fix it for you. The main issue is : it's a mix of MQL4 and MQL5 which will not run either on MT4 or MT5.
In parallel, I'm curious to know what made you think it might be an gpt generated code?
It's obvious. It's like listening someone talking a foreign language, if this language is natural for you, you will immediately know it's not a native people using its mother language, but you will also recognize the accent used and where the person is coming from.
It's actually useless from my point of view. Of course, as a professional coder, it's hard for me to put myself in your shoes, but I am trying to understand, so thank you for the explanation.
This code will never work and to make it working you would have to learn the language or rely on someone else to fix it for you. The main issue is : it's a mix of MQL4 and MQL5 which will not run either on MT4 or MT5.
It's obvious. It's like listening someone talking a foreign language, if this language is natural for you, you will immediately know it's not a native people using its mother language, but you will also recognize the accent used and where the person is coming from.
Hi Alain, thanks for taking the time I appreciate being able to discuss it.
" It's actually useless from my point of view. " --> made me laugh ;)
" It's obvious. It's like listening someone talking a foreign language, ... recognize the accent used and where the person is coming from. " --> very interesting and as someone who speaks a couple, I fully understand thanks for that example.
" The main issue is : it's a mix of MQL4 and MQL5 which will not run either on MT4 or MT5 " --> insightful thank you. There were absolutely some cases where it was suggesting things that were MQL4, however these were only obvious to me when the compiler returned an error and I investigated the specific case. You're saying that there are still some MQL4 functions in the above code? That's really interesting since it seems to compile as an MT5 code.
Additionally, all of the individual elements appear to be correct up to the order send, the price values, SL, TP etc.
For the purpose of discussion (and food for thought) I also created a custom indicator using the same process. It is a lot simpler, perhaps, and maybe it was the luck of the "gpt draw", however it is functioning correctly on a live chart so it seems that this Frankenstein method of code generation can still bear fruit.
As the non native speaker in foreign lands, my goal is simply to be understood and get what I need (dos cervezas por favor). On the other hand, I can appreciate that other people's attempts to speak the language can be painful to watch -> thanks for being patient :)
Hi Alain, thanks for taking the time I appreciate being able to discuss it.
" It's actually useless from my point of view. " --> made me laugh ;)
" It's obvious. It's like listening someone talking a foreign language, ... recognize the accent used and where the person is coming from. " --> very interesting and as someone who speaks a couple, I fully understand thanks for that example.
" The main issue is : it's a mix of MQL4 and MQL5 which will not run either on MT4 or MT5 " --> insightful thank you. There were absolutely some cases where it was suggesting things that were MQL4, however these were only obvious to me when the compiler returned an error and I investigated the specific case. You're saying that there are still some MQL4 functions in the above code? That's really interesting since it seems to compile as an MT5 code.
Additionally, all of the individual elements appear to be correct up to the order send, the price values, SL, TP etc.
For the purpose of discussion (and food for thought) I also created a custom indicator using the same process. It is a lot simpler, perhaps, and maybe it was the luck of the "gpt draw", however it is functioning correctly on a live chart so it seems that this Frankenstein method of code generation can still bear fruit.
As the non native speaker in foreign lands, my goal is simply to be understood and get what I need (dos cervezas por favor). On the other hand, I can appreciate that other people's attempts to speak the language can be painful to watch -> thanks for being patient :)
Ok as you seem in a different process compared to most others ChatGPT guys, I will help :
The main issues are with indicators and getting their values.
1. This will be unreliable : because the handle to iMA should not be set in the same function as the CopyBuffer(). The indicator handles should be initialized in OnInit() event handler, that gives time to the indicator to be started and calculated. Also an handle should only be initialized ONCE, not each time a function is called.
bool GetMovingAverages(double &fastMA[], double &slowMA[]) { int handleFastMA = iMA(Symbol(), 0, fastSMA, 0, MODE_SMA, PRICE_CLOSE); int handleSlowMA = iMA(Symbol(), 0, slowSMA, 0, MODE_SMA, PRICE_CLOSE); if(CopyBuffer(handleFastMA, 0, 1, 3, fastMA) <= 0) { Print("Failed to copy fastMA. Error code: ", GetLastError()); return false; } if(CopyBuffer(handleSlowMA, 0, 1, 3, slowMA) <= 0) { Print("Failed to copy slowMA. Error code: ", GetLastError()); return false; } return true; }
2. This is the MQL4 way to get an indicator value, it should be changed to the MQL5 way with an handle and using CopyBuffer().
bool CheckBullishDivergence() { double priceHighPrev = iHigh(Symbol(), 0, 1); double rsiHighPrev = iRSI(Symbol(), 0, rsiPeriod, 1); return (priceHighPrev < iHigh(Symbol(), 0, 0) && rsiHighPrev > iRSI(Symbol(), 0, rsiPeriod, 0)); }
If you need more information about how to get values from indicator in MQL5 please check the documentation and search on the forum, it's has been discussed zillions times.
There are other issues, but let's start with these ones.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Not a coder by trade, I typically work with freelancers. However with a bit of free time this summer I decided to try and work on a basic MT5 MA cross system on my own.
I've gotten more or less to the "end" in that it compiles and seems to run. However, it cannot complete any trades. I consistently get the "OrderSend failed with error(4756)", but so far as I can tell everything appears to be correct.
I have attached the code here below. Please note that there are some calls to some divergence functions (strategy mode 3), but these can be ignored.
The code has a number of print statements for debugging, and I have also attached a screenshot of a failed trade showing them:
a) "0" comments are from before the MqlTradeRequest structure definition
b) "1" comments are from after the MqlTradeRequest structure definition and normalization of data, to ensure consistency before the order send function.
In the image, we can see:
1) the candle where the trade was sent
2) the ask price at the time
3) the SL (50 points) and the TP (100 points)
4) the volume
Note that the OP_BUY and OP_SELL are 0 and 1 respectively for the operation types.
I have also tested this on two different terminals using two different brokers during normal trading hours. The pair used was EURUSD, so nothing exotic.
Thoughts on what might be blocking me here? Happy for any pointers!