successfully combines all 24 hourly bars to 1 daily bar.
But so far I couldn't figure out how to only emulate those bars within those pre-defined market hours. Using AssetZone and AssetMarket in the same script did not work.
I also tried to use dayClose(UTC,1) instead, which works in showing me the closing price of the market end. However, it seems that the day functions cannot be combined with TimeFrame.
Eventually I'd like to use other indicators on those emulated bars such as SMA or RSI and I could not get this working with the day functions either.
AssetZone and AssetMarket are mutually exclusive, since using them together would make no sense. Assetzone produces daily time frames, but skipping outside market hours makes only sense with intraday time frames.
I further tried following code based on the manual:
if(between(hour(),19,23) or between(hour(),0,5)) //outside market hours --> skip and ignore those bars { TimeFrame = 0; SkippedBars--; // count negative number of bars outside market hours } else if(hour()==6) { TimeFrame=SkippedBars; // end this timeFrame SkippedBars = 0; } else if(between(hour(),7,17)) //the hours I want to trade and use as an input for my indicators; { TimeFrame=0; BarsPerMarketDay--; } else if(hour()==18) //Market Closes --> combine all market hours bars to one and use as an input for SMA, RSI, etc. { TimeFrame=BarsPerMarketDay; BarsPerMarketDay = 0; } vars PriceD1 = series(priceClose()); //my problem is that it fills in also the price bar from the closed market hours that I do not want to have in here //vars smaD = series(SMA(PriceD1,3)); //create an SMA of my last three market days
plot("PriceD1",PriceD1,MAIN,RED); // seems to work, but not sure if outside market hour bar is ignored or just a 2nd daily bar
//plot("smaD",smaD,MAIN,BLUE); // DOES NOT WORK AS INTENDED
Can anyone explain what is going wrong here and how to solve it? It seems to me that the only way around this is to write several loops as there does not seem to be a way around this.
I was also wondering if anyone traded multiple FXCM cfds on daily bars, which does not seem to be an easy endeavour with Zorro as each cfd is traded during different market hours.
Print PriceD1[0] and DayHigh[0] in the log and compare them with the High prices of the last 24 hours. Then you can see where the difference comes from. I cannot say it from a look at your code, but that would be the logical next step.