A stack overflow builds up over time, and can be caused by multiple functions, so it is not possible to narrow it down to a single incident.
It can usually be caused by uncontrolled function recursion (e.g. a function calling itself infinitely).
A stack overflow builds up over time, and can be caused by multiple functions, so it is not possible to narrow it down to a single incident.
It can usually be caused by uncontrolled function recursion (e.g. a function calling itself infinitely).
Thanks a lot buddy.
Actually I figured it out as I was calling the function within the same function. It was recent change and I just guessed it could be cause. However if it has been some time and few changes have been done, I am worried I could be able to trace it. Wish MQL5 could point it.
Here is the error code for the other user's benefit on the forum.
CENUM_HA_BAR CiHAshi::GetHABarType(int pIndex) { if(HAOHLC[k].close < HAOHLC[k].open) { if(HAOHLC[k].open == HAOHLC[k].high) // BULLISH WHEN OPEN AND LOW EQUAL return(BEARISH); else if(HAOHLC[k].open != HAOHLC[k].high && BodySizeRTA <= 0.05) // BEAR DOJI WITH 5% BODY SIZE return(BEAR_DOJI); else if(HAOHLC[k].open != HAOHLC[k].high && BodySizeRTA > 0.05 && BodySizeRTA <= 0.20) // BEAR SPINNING TOP WITH 20% BODY SIZE return(BEAR_STOP); else if(HAOHLC[k].open != HAOHLC[k].high && BodySizeRTA > 0.20 && UpperWickRTA <= 0.05) // !BEARISH, !BEAR_DOJI, !BEAR_STOP return(BEARISH); // DEEMED BEARISH else if(HAOHLC[k].open != HAOHLC[k].high && BodySizeRTA > 0.20) // BEARISH WEAK WITH BODY SIZE 20% OF AMPLITUDE return(BEAR_WEAK); } if(GetHABarType(1) == BEAR_WEAK) { ... do something }
Thanks a lot buddy.
Actually I figured it out as I was calling the function within the same function. It was recent change and I just guessed it could be cause. However if it has been some time and few changes have been done, I am worried I could be able to trace it. Wish MQL5 could point it.
Here is the error code for the other user's benefit on the forum.
This code does not make much sense.
1. The function starts with an if statement which if true, returns to caller.
2. When the if from #1 is false, i.e. when the bar is a green (up) bar, the function then calls itself with a 1 bar index (do you intend to check the previous bar, or is it calling the first bar from left? in both cases, you can end up in infinite calling) - which in case it is also a green bar, it ends up calling itself endlessly. What is your intention here?
1. The function starts with an if statement which if true, returns to caller.
2. When the if from #1 is false, i.e. when the bar is a green (up) bar, the function then calls itself with a 1 bar index (do you intend to check the previous bar, or is it calling the first bar from left? in both cases, you can end up in infinite calling) - which in case it is also a green bar, it ends up calling itself endlessly. What is your intention here?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear All
I have recently started getting Stack overflow error but there is nothing to tell which code is causing this. How can I find the source is this problem. I have understood that this is caused by recursive loop. But unable to trace which loop is causing it.
debugger also did not help much to find it.
Until yesterday the code was working fine, and I have not made any changes to functions with loop.
2022.12.02 12:29:10.704 US30,Daily: history cache allocated for 455 bars and contains 453 bars from 2021.01.04 00:00 to 2022.09.30 00:00
2022.12.02 12:29:10.704 US30,Daily: 1 bar from 2022.10.03 00:00 added
2022.12.02 12:29:10.704 US30,Daily: history begins from 2021.01.04 00:00
2022.12.02 12:29:17.516 2022.10.03 02:48:00 Stack overflow