[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 749
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
Gentlemen programmers. Could you please help me.
From the input variables.
extern bool UseHourTrade = True;
extern int FromHourTrade = 0;
extern int ToHourTrade = 23;
int start(){
if (UseHourTrade){
if (!(Hour()>=FromHourTrade && Hour()<=ToHourTrade)) {
Comment("Time for trade has not arrived yet!");
return(0);
}
}
I want to add second time period when trade should be done with other variables UseHourTrade2, FromHourTrade2, ToHourTrade2.
Please help. please tell me what should be added to start function. I have tried so many things that do not work.
I want to thank you in advance. I cannot help.
Something like that, I guess.
SZY The code insertion button "SRC" is awkward to use, it's not easy to read.
The conundrum is this.
The indicator at the very end of the code creates an object, which serves as a flag for another indicator.
After creating the object, I need to "sleep" the indicator for 5 seconds, then delete the object and sleep it for 60 seconds, after which it will go to the last retry and start over from the beginning with a new tick.
Trying to do this
It hangs until it seems to run out of time.
Any tips on how to do this?
The logic is this - both indicators know the name of the object and one additional object
the first one creates the object and does nothing while it's there - at the very beginning of the start we write the exit condition (return;)
the second one reads the object, does its business and sets an additional object
the first one, without seeing the main object, leaves doing nothing and immediately finds the second (additional object), reads the time of object creation (it is entered there by the second component in the description when creating), counts down the required pause (60 seconds) and deletes all objects - you may continue working ....
It does not work in indicators. I do not understand the reason of doing it this way. Apparently, a constantly working indicator must be hypnotizing :)
The reason is that the indicator works in the interface flow, you cannot put it to sleep, because if you could "slow it down", at that moment you could not press any button in the terminal, for example "New order", or close an order, etc.
One more subtlety in this topic concerns the tester. In the real terminal, there are several threads, one interface thread is created separately for Expert Advisors (that is why it can be slowed down without consequences) and in the tester, it is the same for all, and all for one :)
That is why the Sleep() function works in such a specific way in test mode. If you put the tester's flow to sleep, then everything will stop working, including Expert Advisors, indicators, and tick generation, of course. Therefore, if I have understood your idea correctly, it can be tested only on a demo. If you want to slow down the interface flow, you may use the following function:
counts down the desired pause (60 sec)
Read carefully, I have explained everything, and it is not necessary to use a graph object at all, you can do with globals....
The reason is that the indicator works in the interface stream, it cannot be put to sleep...
There you go... it's brightened up now, thank you.
Man, what rocks. Can't put it in one indicator, can't put it to sleep... I'll try to do it with global variables.
Read carefully, I have explained everything, and it is not necessary to use a graph object at all, you can do with globals....
... I'll try to make it work with global variables.
I think Rustam hinted about it correctly, because thread freezing is the last thing you should do, it's an extreme measure, and not only in MQL, but in all programming languages.