[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 656
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What may cause stack overflow? When you open a position with big take (take is calculated from volatility and multiplied by 100, the size is 41*100), then a stack overflow is written into the log and... ... just take it. No more positions are opened until this one closes, and this one, of course, will not close because of the huge TP... And the EA does not work correctly at all, because it should close all positions when the predefined total profit of the open positions is reached... But it doesn't happen, even though this one position has been in huge profits for a long time, about two thousand points... How do I fight it? One cannot be secured against the situation when all open positions will overflow the stack, and everything will go upside down...
the stack cannot overflow just with a number that is outside the type range - there will be another error
data passed into a function or a recursive call to a function without quitting can overflow the stack.
start() is also a function - maybe you have a lot of variables there.
the stack is a memory region where intermediate values (local variables) of a function are stored; you might be breaking the stack yourself if you're using dynamic arrays and haven't correctly checked the array scope, i.e., you're writing data not in an array, but in a memory region that comes right after the array
try to move some of the arrays to global variables - put them at the top of the board
ZS: at least it's the same in all programming languages - I think it's the same in mql
the stack cannot overflow just with a number that is outside the type range - there will be another error
data passed into a function or a recursive call to a function without quitting can overflow the stack.
start() is also a function - maybe you have a lot of variables there.
the stack is a memory region where intermediate values (local variables) of a function are stored; you might be breaking the stack yourself if you're using dynamic arrays and haven't correctly checked the array scope, i.e., you're writing data not in an array, but in a memory region that comes right after the array
try to move some of the arrays to global variables - put them at the top of the board
ZS: at least it's the same in all programming languages - I think it's the same in mql
Igor, you know that I have avoided using arrays so far... I only have a couple of arrays in my code - an array of orders before the tick and an array of orders after the tick. I have them defined in the global variable area. The funny thing is that I moved the code to open these positions elsewhere in the EA and the error disappeared. It looks like there was a recursive call to open orders, although I didn't really bother with it. I simply decided that it would not be appropriate to place the opening immediately after closing all the positions in the code to check if the total profit was reached and all the positions were closed... I made a mess of it... :)
I made a template for creating an EA - when an order is placed, the flag of such an order is immediately set and afterwards, before opening a new order of this type, I always check the flag - whether the order exists, but I am writing EAs with only one order
I have long ago made a template for creating an EA - when I place an order, I immediately set a sign (flag) that such an order exists, and then before opening a new order of this type I always check the flag - whether such an order exists, but I write EAs with only one order
Yes, I got "0", but what should I do? I can't do it both ways (I even tried equal periods), I tried both Print("NormalizeDouble(c1b_1..."), but I got zeros (only c1b[i] shows the value, all others including c1s[i] are zeros), may help me to bring one of them to a working condition or share a hint, if you notice any defects?
New:
Old:
Whole:
Yuri, in the future, if code is repeated at least twice, it should be allocated to a method, and you won't need heaps of arrays cluttering up the code.
Here's a method for you:
I think everything is clear with parameters, enter data and by varying ma_shift parameter get the shift you need. Note that this method can be used as a template, just change access methods for indicators i...(...) or iCustom(...). Now your block of trading decisions looks as it should be:
Accordingly there is no need now for "old" and "new" variants, trades are opened according to the given criteria (as far as I understood you have a three-bar pattern of tops/troughs smoothed iCC). There is a corrected variant in the file.
Hello.
Can you please give me the code to write the prices since the order was opened into the array.
How to make each new price to be added to the array.
Hello.
Can you please give me the code to write the prices since the order was opened into the array.
How to make each new price to be added to the array.
Please be more specific in your question
If you are interested in the current price at the time of placing the order, you can add a call to the code that will be responsible for storing the current price in the global array with changing the array index counter, which you can view later from any point in the code.
how to check the performance of an EA - I would just like to display the code execution time in milliseconds
how much better is the performance of MT5 vs MT4
how to check the performance of an EA - I would just like to display the code execution time in milliseconds
how much better is the performance of MT5 vs MT4
GetTickCount would help https://docs.mql4.com/ru/common/GetTickCount
GetTickCount will help https://docs.mql4.com/ru/common/GetTickCount
thanks yes it's what i was looking for, has anyone measured the speed of the same type of code for mt4 and mt5 ?