Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 846

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
I have GetLastError after functions and if an error occurs, won't it go to this block (as written) and commands won't be executed? I understand the chain, e.g. OrderSend() -> GetLastError -> error block Sleep(3000) RefreshRates() -> exit the block and if conditions remain OrderSend() is requested again. Or my reasoning and concepts are wrong. I understand you want to write the return value 1 or 0 in the block, but my functions are simple not related to boolean values like SignalBuy, if I understand correctly, the return values should be returned there.
I need some advice. According to the conditions, the position should be closed and after 121 seconds a new position should open. How can I do it with Sleep(121000)?
Good day!
I need some advice. According to the conditions, the position should be closed and after 121 seconds a new position should be opened. How can I do it with Sleep(121000)?
OnTimer() to the rescue
I just reinstalled Windows 7 and wanted to install Mt4, the problem is the files do not download, what should I do?
Thanks! I never used OnTimer(). This part of code is in void OnTick(). Will the OpenPosition() function be handled by OnTimer() then? If you can, please correct code how to insert OnTimer() there correctly...
The timer is started in OnInit()
To start the countdown, you need to find the closing time of the last position in the timer and count 121 sukunds from this time. To pass the flag allowing you to open a new position, use a global variable whose scope covers the entire program. You can make it initially contain a value higher than 121, for example 122 (you can change the wait time in settings).
In OnTick(), check this variable. If it is greater than 121 and there is no position, you open a position and, after checking if it was successfully opened, reset the variable to zero.
As soon as the position is closed, the timer sees the time of closing (it does this continuously once a second) and if from the current time to the closing time of the position passed less than 121-th second, the timer starts counting - every second the variable value is added by 1.
Approximately so. Where there may be a bug - if the position has not yet been closed, its closing time is zero. This can cause a problem with starting the countdown. You could reset the variable to -1, for example.
Yes, don't forget to destroy the timer in OnDeinit():
The timer is started in OnInit()
In order to start the countdown, you need to find the time in the timer when the last position was closed and count 121 seconds from that time. To pass the flag allowing you to open a new position, use a global variable that is scalable by the whole program. You can make it initially contain a value higher than 121, e.g. 122 (you can change the wait time in the settings).
In OnTick() You check this variable. If it is greater than 121 and there is no position - open a position - and, after checking if it was successfully opened, reset the variable to zero.
As soon as the position is closed, the timer sees the time of closing (it does this continuously once a second) and if from the current time to the closing time of the position passed less than 121-th second, the timer starts counting - every second the variable value is added by 1.
Approximately so. Where there may be a bug - if the position has not yet been closed, its closing time is equal to zero. This can cause a problem with starting the countdown. You could reset the variable to -1, for example.
Yes, don't forget to destroy the timer in OnDeinit():
Got it, thanks. I was hoping to do it in one line, but probably I'll have to work a bit longer.
I see, thank you. I was hoping to do it in one line, but I guess it's going to take more work.
как проще всего загрузить всю доступную историю графика?
Script.
it's not working.