|
Re: get rid of empty bars when market is closed (between days)
[Re: jcl]
#464779
03/11/17 15:09
03/11/17 15:09
|
Joined: Jul 2016
Posts: 27
konorti
OP
Newbie
|
OP
Newbie
Joined: Jul 2016
Posts: 27
|
Thanks! I found out the next code. I will see what happens on live but with backtesting it is not trading (though there are no night bars as well for history data): if (hour(0)==21 || hour(0)==22 ||hour(0)==23 ||hour(0)==0 ||hour(0)==1 ||hour(0)==2 ||hour(0)==3 ||hour(0)==4 ||hour(0)==5 ||hour(0)==6) {TimeFrame=0;} if (hour(0)==7 && minute(0)==1) {TimeFrame=-40;} //on M15, market is closed between 9:00PM-6:59AM if (hour(0)==7 && minute(0)==2) {TimeFrame=1;} There are 3 ways to get overnight bars:
- Setting Weekend at 0 - Trading another asset at the same time that is traded overnight. - The asset still gets some price quotes overnight. This sometimes happens with CFDs.
You can use the TimeFrame mechanism for skipping overnight bars so that they don't affect indicators. Set TimeFrame to 0 when the market closes, count the skipped bars, set TimeFrame to the negative number of skipped bars when the market opens again, and to 1 while the market is open.
Last edited by konorti; 03/11/17 15:09.
|
|
|
Re: get rid of empty bars when market is closed (between days)
[Re: jcl]
#464857
03/15/17 15:03
03/15/17 15:03
|
Joined: Jul 2016
Posts: 27
konorti
OP
Newbie
|
OP
Newbie
Joined: Jul 2016
Posts: 27
|
Unfortunatelly it doesnt work. Any idea why these bars appear or whdt is the problem with my code? There are 3 ways to get overnight bars:
- Setting Weekend at 0 - Trading another asset at the same time that is traded overnight. - The asset still gets some price quotes overnight. This sometimes happens with CFDs.
You can use the TimeFrame mechanism for skipping overnight bars so that they don't affect indicators. Set TimeFrame to 0 when the market closes, count the skipped bars, set TimeFrame to the negative number of skipped bars when the market opens again, and to 1 while the market is open.
Last edited by konorti; 03/15/17 17:35.
|
|
|
|