price() on different timeframes

Posted By: gamadeus

price() on different timeframes - 02/05/20 20:02

I was wondering why price() does not return precisely the same result when using different timeframes?

For example:

BarPeriod = 10;
TimeFrame = 6;
if(!minute())printf("\n%s %.7f",strdate("%d.%m %H:%M",0), price());

does sometimes, but not always, print out slightly different prices than on BarPeriod 60 TimeFrame 1.
Posted By: AndrewAMD

Re: price() on different timeframes - 02/05/20 20:40

Hint: replace !minute() with frame(0) and see what happens. Also, read the manual regarding TimeFrame and frame().
Posted By: gamadeus

Re: price() on different timeframes - 02/05/20 21:13

Thanks Im aware of these functions, in the script Im actually running this on I am using frameSync instead. Thats not the cause and I wanted to make this example script as simple as possible.
Posted By: AndrewAMD

Re: price() on different timeframes - 02/05/20 23:40

With TimeFrame = 6 and 10 minute bars, there is no guarantee that the last 6 bars represent the last 60 minutes. There can be many reasons for this, such as data gaps.

Consider also that the price function generates an average of the immediately available samples. In one case, you have one degree of separation from your T6 data, and in another case, you have two degrees of separation from your T6 data.
© 2024 lite-C Forums