AssetFrame issues

Posted By: Ger1

AssetFrame issues - 08/15/17 23:19

Hi,

I am trying to use both, AssetZone and AssetMarket at the same time, which does not seem to work.

What I want to achieve is to skip all bars outside of market hours and combine all bars within market hours to 1 bar.

As an example:
BarPeriod = 60;
StartMarket = 1000;
EndMarket = 1400;

I'd like to combine those 4 bars to 1 and ignore all price data points outside of those hours.

Using:
AssetMarket = UTC;
TimeFrame = AssetFrame;
vars Price = series(priceClose());

successfully skips all bars outside those hours.

Using:
AssetZone = UTC;
TimeFrame = AssetFrame;
vars Price = series(priceClose());

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.

Could anyone shed some light on this matter?
Posted By: jcl

Re: AssetFrame issues - 08/16/17 05:53

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.
Posted By: Ger1

Re: AssetFrame issues - 08/16/17 06:14

Okay. So is there way to achieve above?

As an example, is it possible to calculate the SMA of the last 5 day highs?

The issue is that I want to use only the high that occurred between StartMarket and EndMarket.

I first thought I could use dayHigh but this did not work.

I'd highly appreciate if you could shed some light on this as I got stuck.
Posted By: Ger1

Re: AssetFrame issues - 08/17/17 22:10

Could anyone shed some light on this?

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.
Posted By: Ger1

Re: AssetFrame issues - 08/18/17 08:18

attached fxcm cfd market hours, where I'd like to implement a strategy trading multiple assets on a daily timeframe

Attached picture FXCMCFDTradingHours-001.jpg
Posted By: jcl

Re: AssetFrame issues - 08/18/17 16:42

Originally Posted By: Ger1
is it possible to calculate the SMA of the last 5 day highs?

The issue is that I want to use only the high that occurred between StartMarket and EndMarket.

I first thought I could use dayHigh

I would think the same. dayHigh is exactly what you want - no need to skip bars or define time frames.
Posted By: Ger1

Re: AssetFrame issues - 08/19/17 01:08

Okay thanks.

I am able to replicate the daily price with the dayHigh function.

USE TIMEFRAME:
TimeFrame=frameSync(24);
vars PriceD1 = series(priceHigh());
TimeFrame=1;

USE DAYHIGH:
StartMarket = 0000;
EndMarket = 2359;
vars DayHigh = series(dayHigh(UTC,1));


However, I am unable to use the output from dayHigh as an input for indicator functions.

As an example I tried to set up the daily SMA:
vars smaD = series(SMA(PriceD1,3));
vars smaDayHigh = series(SMA(DayHigh,3));

Both give very different results.

I have attached the script I used and the resulting chart.

Could you please advise what is going wrong here and how to set it up correctly?

Eventually I'd like to set up various indicators on daily timeframes (but only getting price inputs during market hours) for various CFDs.

Thanks a lot.

Attached File
AssetFrame.c  (5 downloads)
Attached picture DAYHIGH.png
Posted By: jcl

Re: AssetFrame issues - 08/21/17 11:06

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.
© 2024 lite-C Forums