Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (sleakz, AndrewAMD), 684 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
get rid of empty bars when market is closed (between days) #464771
03/09/17 19:21
03/09/17 19:21
Joined: Jul 2016
Posts: 27
K
konorti Offline OP
Newbie
konorti  Offline OP
Newbie
K

Joined: Jul 2016
Posts: 27
I try my code on demo fxcm server. How can I get rid of these empty bars (not seen during backtest) when the market was closed? An indicator will use these bars for the calculation which is not good. Sorry for the small screenshot, it was taken on GER30 but it is similar to any indices that the market is closed for the night but FXCM generates a bar with same OHLC. The problem is that it affects the indicators.


Last edited by konorti; 03/10/17 11:12.
Re: get rid of empty bars when market is closed (between days) [Re: konorti] #464773
03/10/17 11:43
03/10/17 11:43
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
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.

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
K
konorti Offline OP
Newbie
konorti  Offline OP
Newbie
K

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;}

Originally Posted By: jcl
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
K
konorti Offline OP
Newbie
konorti  Offline OP
Newbie
K

Joined: Jul 2016
Posts: 27
Unfortunatelly it doesnt work. Any idea why these bars appear or whdt is the problem with my code?


Originally Posted By: jcl
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.
Re: get rid of empty bars when market is closed (between days) [Re: konorti] #465646
05/07/17 19:34
05/07/17 19:34
Joined: Jul 2016
Posts: 27
K
konorti Offline OP
Newbie
konorti  Offline OP
Newbie
K

Joined: Jul 2016
Posts: 27
I tried to skip these bars different ways but couldnt. Can somebody try on FXCM demo (only GER30 is traded) to somehow get rid of them? Any code would be fine, just not to see those empty bars while market is closed. Thanks!

Re: get rid of empty bars when market is closed (between days) [Re: konorti] #465678
05/09/17 12:18
05/09/17 12:18
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
I'll look into that.

- Update: The bars are probably ok. FXCM apparently sends GER30 price quotes all around the clock, so you still get bars and see them in the chart.

If you don't want those bars, use the TimeFrame mechanism as described. Of course you'll then still see the bars in the chart, but they won't affect the series and indicators.

Re: get rid of empty bars when market is closed (between days) [Re: jcl] #465791
05/12/17 13:35
05/12/17 13:35
Joined: Jul 2016
Posts: 27
K
konorti Offline OP
Newbie
konorti  Offline OP
Newbie
K

Joined: Jul 2016
Posts: 27
Thanks! Still i dont understand that when i download history from the server, these bars are not there. My live trades are different than what i have backtested. Timeframe mechanism didnt work for me. I tried the demo trading on mt4 than i had trading errors with limit orders not being enterred as they were too close to market price. For me would be advantage to trade with fxcm, but can try to fix this stop level issue with mt4 bridge (or maybe this was already fixed as i tried this with 1.51 version only)

Re: get rid of empty bars when market is closed (between days) [Re: konorti] #465848
05/15/17 07:43
05/15/17 07:43
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
I cannot answer the question why the prices outside market hours are removed from the price history, but when you ask FXCM they probably have an answer.

Why does the timeframe mechanism not work for you?

Re: get rid of empty bars when market is closed (between days) [Re: jcl] #465900
05/17/17 05:33
05/17/17 05:33
Joined: Jul 2016
Posts: 27
K
konorti Offline OP
Newbie
konorti  Offline OP
Newbie
K

Joined: Jul 2016
Posts: 27
The bars are still there with the code above. I tried to also remove each bar after it closed and had same high and low value. They are just there. Maybe the code has error, but after changing sg i have to wait for a night to test it laugh

Re: get rid of empty bars when market is closed (between days) [Re: konorti] #465902
05/17/17 08:24
05/17/17 08:24
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
Yes, that's what I said - the bars won't go away, so you need to set TimeFrame to 0 when you don't want them to affect your series.

Code:
static int SkippedBars = 0;
if(between(hour(),21,6)) {
  TimeFrame = 0;
  SkippedBars--; 
} else if(TimeFrame == 0)
  TimeFrame = SkippedBars;
  SkippedBars = 0;
} else {
  TimeFrame = 1;
}


Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1