Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1068
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
Good morning, everyone. Can you tell me how to take the opening of the day with an hour offset? That is, not take the first hour, but the second for the day?
It goes something like this.
But it would not hurt to put a check for a new day, otherwise all ticks from 1:00 to 2:00 will correspond to the condition.
Good afternoon, dear friends! Please advise me, where is the error in my reasoning, and, if there is no error, what corrections should be done to the code:When powering on the computer again after a power outage, all strings of code are loaded sequentially and after the closing curly bracket of OnTick() is read the user functions behind it, and, after reading the code of CloseAllBuy(), it is executed, although it has not been called from the OnTick(). So, when loading an EA, all open positions are closed. How to avoid this?
Try to use global variables. If you want the EA to start from the same state as when it was closed, all state flags should be stored in global variables. Their value does not change and will be stored for days like this....
I have an operator iOpen(NULL,PERIOD_D1,1) it shows the opening of the day, but how to make the opening of the second hour of this day....????
iOpen() is the price, but iTime() should be used as suggested above. And different western companies may open the day on Sunday evening, you have to keep an eye on that, too.
In general, study whatiBarShift is.
Good day, dear friends! Please advise me where there is an error in my reasoning and, if there is none, what corrections should be made to the code:When powering on the computer again after a power outage, all code lines are loaded sequentially and after the closing curly bracket of OnTick() the user functions located behind it are read, and after reading the code of CloseAllBuy() its execution occurs, even though it has not been called from the OnTick(). So, when loading an EA, all open positions are closed. How to avoid this?
And how did you check that CloseAllBuy() is not called from nowhere? Or maybe the closure is still prescribed somewhere else?
No one can tell without the code, except the author.