Indicator and TimeFrame

Posted By: Grat

Indicator and TimeFrame - 01/17/18 23:09

Hi,

I have this simple script ( only for testing )
this problem is described in manual:
TimeFrame does not affect a few indicators that do not use a Data series, but directly the current asset price series. This is mentioned in the description of the indicator.

Code:
void run()
{
	assetList("AssetsCur.csv");
	set(LOGFILE|PLOTNOW);
	set(TICKS);

	NumYears = 1;
	StartDate = 20170101;
	
	PlotScale = 8;
	PlotWidth = 1200;
	PlotHeight1 = 450;
	PlotHeight2 = 120;
	PlotDate = 20170601; 
	PlotBars = 200;

	BarPeriod = 5;
	TimeFrame = 12;	
		
	var *Price = series(price());		
	vars Trend1 = series(LowPass(Price,80));
	plot ("Price",Price,MAIN|LINE,ORANGE);
	plot("LP",Trend1,MAIN|LINE,BLUE);
	
}



after run I get this screen:






















but after remove the
Code:
TimeFrame=12;

- run only with BarPeriod is the indicator smoothed.




After change BarPeriod=60; / 5*12 / I get also different values in the indicators:




Sumary:
BarPeriod*TimeFrame / TimeFrame > 1 / not get the same value from indicator





Attached File

Description: smooth
Attached File

Description: BarPeriod60
Attached File
Posted By: jcl

Re: Indicator and TimeFrame - 01/18/18 11:23

That's right. But what was the question?
Posted By: Grat

Re: Indicator and TimeFrame - 01/18/18 13:14

no question, only explain for the other people, how work TimeFrame.
Posted By: Grat

Re: Indicator and TimeFrame - 01/18/18 17:33

so, I have question:

how to get the same price in the exact time? For 2.1.2017 00:00:00 - price don't have same value

BarPeriod=60
TimeFrame=1
Date: 02.01.17 00:00:00 Price: 1.05265 Trend: 1.05179

BarPeriod=5
TimeFrame =12
Date: 02.01.17 00:00:00 Price: 1.05301 Trend: 1.05455

BarPeriod=5
TimeFrame =1
Date: 02.01.17 00:00:00 Price: 1.05261 Trend: 1.05348

BarPeriod=1
TimeFrame =1
Date: 02.01.17 00:00:00 Price: 1.05259 Trend: 1.05289

BarPeriod=1
TimeFrame =0
Date: 02.01.17 00:00:00 Price: 1.05290 Trend: 1.05290

Code:
printf("nDate: %s Price: %.5f Trend: %.5f",datetime(),Price[0],Trend1[0]);

Posted By: jcl

Re: Indicator and TimeFrame - 01/19/18 07:48

price() is the mean price of the bar, so it depends on bar length. priceClose() is the price at the exact time.
Posted By: easyX

Re: Indicator and TimeFrame - 03/19/18 14:52

How can i get the H1 CCI while using 1 or 5 min BarPeriod?

What is the "current asset price series" in case i have BarPeriod = 5 is it always using M5 data then?

Does a change of TimeFrame (12) give me my H1 data?
Posted By: BobbyT

Re: Indicator and TimeFrame - 03/24/18 20:15

Hi easyX,

I'm also trying to work through some timeframe/indicator related issues and have a current thread about it.

The way I understand BarpPeriod/TimeFrame and price/indicator data is this....

BarPeriod will generate the following price series for BarPeriod: priceOpen(), priceHigh(), priceLow() and priceClose()

So in your example, the above functions will be autofilled every pass of run() which technically you could say it is filled every 5 minutes.

If you call TimeFrame(12) then yes, you will be looking at H1 data. Any call to the above functions, while TimeFrame = 12, will give you H1 data for that feature.
Of course you can always set up a TimeFrame specific series with
Code:
vars C = series(priceClose());

to make accessing non current bar elements easier.

I may have this completely wrong given I'm having problems of my own with this kind of thing.

Cheers
Posted By: Petra

Re: Indicator and TimeFrame - 03/25/18 11:56

Thats right, with 5 min barperiod, the TimeFrame of 1 hour is 60/5 = 12. And for catching the hour boundaries its TimeFrame = frameSync(12).
Posted By: aventador

Re: Indicator and TimeFrame - 11/17/19 12:39

I have question.

How to make weekly timeframe with BarPeriod = 60 ?

The reason to use Barperiod 60 is to trade market in timeframe 1 hour.

For example :-

If weekClose[0] > weekClose[1] then weeksignal = 1 else weeksignal = 0

in timeframe 1 hour if SMA10 > SMA30 and weeksignal = 1 then enterlong
else if SMA10 < SMA30 and weeksignal = 0 then entershort
Posted By: jcl

Re: Indicator and TimeFrame - 11/18/19 12:44

For a weekly time frame from 1h bars, you can use the synchronization mechanism described under "TimeFrame". But for that week signal you need no extra time frame. Just store the close at the end of Friday and compare with the previous stored close.
Posted By: aventador

Re: Indicator and TimeFrame - 11/19/19 02:27

Originally Posted by jcl
For a weekly time frame from 1h bars, you can use the synchronization mechanism described under "TimeFrame". But for that week signal you need no extra time frame. Just store the close at the end of Friday and compare with the previous stored close.


Thanks JCL. The idea store Fri' end is brilliant. Never thought of that.
© 2020 lite-C Forums