Trades only 8 am – 3 pm
24 replies
Uwe6000
6 years ago #232923
Hello, I would like to go long only at certain times eg 8am – 3 pm. Optional 5-9 clock.
It does not work in the backtest. The orders are opened only in the time from 8 am to about 10 am.
What could it be? Here my example:
Best regards
Uwe6000
6 years ago #233303
hello, thank you for the file, I’ll test it! Now I also see how to get the brackets in the rules;)
Uwe6000
5 years ago #233382
Hello, I would like to close an open position in the time from 16:55 to 16:57. The problem is that the Pos from 16:55 to 16:59 is currently always closed. Starting at 16:58, the position should not be closed and in the example “minute [0} <= 57” has been added. After 17 o’clock everything is okay and the position is not closed. Nevertheless, the code does not work. Does anyone have an idea what’s wrong with that?
Conmariin
5 years ago #233387
Hi,
maybe try to insert another Hour[0] >= 16 before the Minute[0] <= 57.
Conmariin 🙂
Automatisches Handeln mit Expert Advisor
https://www.rabenesche.de
tomas262
5 years ago #233396
Uwe6000
5 years ago #233397
yes, that’s exactly why I thought I used “= 16” and “= 30” instead of “> =”, but it did not work with “=” …. funny
Uwe6000
5 years ago #233447
Hello, in my example, a long position should be opened only in the period from 8:05 to 15:05 and from 16:05 to 22:30 clock. In addition, long positions 15.20 (not yet integrated in the example) and 22:50 will be closed. There seems to be a mistake in logic as all long positions close immediately after 4:05 pm. Where is the mistake ? thanks for ideas
tomas262
5 years ago #233465
Hello,
just to make things completely clear
- you open a trade between 8:05 to 15:05 and close immediately at 15:20
- then you open a trade between 16:05 to 22:30 and close at 22:50
Is there correct?
Uwe6000
5 years ago #233477
Hello tomas, Yes ! Positions may only be possible from 8:05 to 15:05 or from 16:05 to 22:30. Long positions are closed exactly at 15:20 and 22:50. Unfortunately, the long positions are closed immediately after 16:05(my picture). So the trading time are set from 8:05 to 15:05 and from 16:05 to 22:30. Close position 16:05 and 22.30.
Uwe6000
5 years ago #233490
Hello, I found the problem. The times must be specified from “> =” to “<=”. like this:
Hour[0] >= 8
Minute[0] >= 5
Hour[0] <= 15
(Minute[0] <= 5