[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 309
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
That's right: it's good manners to tidy up your own rubbish...
But in this context, how can you tell if the "rubbish" needs to be cleaned up now or vice versa: it's not rubbish - it's the necessary data for further calculations.
As I understand it, deinit() should be used to clean up the trash, but... it is executed not only when chart of a trade instrument is deleted, when Expert Advisor is removed from it, but also when TF is changed. In this case, all of the accumulated data for the TF will be lost and the Expert Advisor will restart working with a zero array when it returns to the previous timeframe. The same will happen if we change any of parameters of the Expert Advisor.
It turns out that in some situations "rubbish collection" is a complex logical process, not a simple change of the array size.
Well, it's not complicated. In the loop, initialize the array with values. Then we work with the resulting array. When the work is done, we make it zero in length. If in doubt, you may do it at the end of the code just before return(0).
Please suggest the code below to read the log file. Automatically reads the current log file by date and outputs it to the printer.
Where:
The file is being assembled from parts. But I don't need the whole file, just the last line. Help to correct, please.
Well, it is not difficult. In the loop, the array is initialized with values. Then we worked with the resulting array. When the work is over, we make it a zero-length array. If in doubt, you may do it at the end of the code just before return(0).
I was misunderstood.
In the context of the conversation (if I understood the premise of this conversation correctly), the loop is the EA itself. After all, every time a tick comes, the array either increases or stays the same depending on whether a new value needs to be written to it.
How can we know that the work is finished, and not just a person, for example, changes the timeframe? Even by accident... In this case, deinit() will be called and all data will be lost. The Expert Advisor will start to store (write in a dynamic array) them anew, based on the values obtained in the new timeframe(a new cycle).
I mean it.
I wasn't understood.
In the context of our discussion (if I understood the premise of this discussion correctly), the cycle is the work of the Expert Advisor itself. After all, every time a tick comes the array is either increased or remains unchanged, depending on whether a new value needs to be written to it.
How can you tell if a job is finished and not just a person changing timeframes, for example? Even by accident... In this case, deinit() will be called and all data will be lost. The Expert Advisor will start to accumulate them (write them into a dynamic array) anew, based on the values obtained in the new timeframe(a new cycle).
My point is this.
I have noticed one specific feature of the terminal. Since the order profit calculation does not consider the OrderSwap(), I want it to close the order at once.
It means we should use this formula to close the order with a profit:
(OrderProfit()+OrderSwap()+OrderCommission())>0
I've never worked with commission and commission is not used on demo, that's why I can't check it on account.
Are my calculations correct?
If you go into details, you can use this function. It will tell you the reason for deinitialisation.
Quite right... :)
Forgot about it. Now, with my habit of using "foolproof", we'll use it...
ObjectGetValueByShift() to help you
And how you're going to work with it - only you know...
Thank you, kind man!
Can I change the lot size of a pending order?
No, you can't.
everything you can change is explained here https://docs.mql4.com/ru/trading/OrderModify