Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 945 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
price...() returns last bar close regardless of TimeFrame #478821
12/26/19 14:09
12/26/19 14:09
Joined: Dec 2019
Posts: 53
ozgur Offline OP
Junior Member
ozgur  Offline OP
Junior Member

Joined: Dec 2019
Posts: 53
Hi,

I am reading through the Manual and the "price" page says

Quote

Returns the open, close, maximum and minimum price of the bar period or time frame with the selected asset. priceClose(0) returns the current price.


Then I made this very simple script below.

Code
function run()
{
	BarPeriod = 60;
	TimeFrame = 4;
	
	vars cls_series = series(priceClose(0));
	var cls_val = priceClose(0);
	
	printf("\nFrom series: %f vs Other: %f", cls_series[0], cls_val);
}


As you can see the screenshot below, priceClose() returns the last bar (1 hour TF) value instead of the last Timeframe (4 hour TF) value unless it is defined as series(). I was expecting values from both series and single variable same. Am I missing something?

Thanks a lot

Note: I also tried other price functions such as price(), priceOpen() as well, experiencing the same behaviour.

Output:
[Linked Image]


Last edited by ozgur; 12/26/19 14:10.
Re: price...() returns last bar close regardless of TimeFrame [Re: ozgur] #478826
12/27/19 17:18
12/27/19 17:18
Joined: May 2018
Posts: 134
S
SBGuy Offline
Member
SBGuy  Offline
Member
S

Joined: May 2018
Posts: 134
I believe priceClose(0) is the price right now!

series() is only added at a TimeFrame of 4*60 (4 hours).

That's why the printfs are different.

At every 4 hours those 2 numbers will be the same in your printf, which appears to be the case.

Re: price...() returns last bar close regardless of TimeFrame [Re: ozgur] #478827
12/27/19 21:51
12/27/19 21:51
Joined: Dec 2019
Posts: 53
ozgur Offline OP
Junior Member
ozgur  Offline OP
Junior Member

Joined: Dec 2019
Posts: 53
Yeah, I think the manual is a bit vague though. I just wanted to check if I am doing something wrong.

Thanks.

Re: price...() returns last bar close regardless of TimeFrame [Re: ozgur] #478828
12/27/19 22:11
12/27/19 22:11
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
Can you try and see what will be the value of priceOpen(0)?
Is it equal to the priceClose() of the last complete 4-hour candle, or of the last 60-min bar?

Re: price...() returns last bar close regardless of TimeFrame [Re: Zheka] #478830
12/28/19 00:01
12/28/19 00:01
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Using this code:
Code
function run()
{
	StartDate = 20191101;
	EndDate = 20191227;
	BarPeriod = 60;
	TimeFrame = 4;
	assetList("AssetsFix");
	asset("EUR/USD");
	
	var p = price(0);
	var o = priceOpen(0);
	var h = priceHigh(0);
	var l = priceLow(0);
	var c = priceClose(0);
	
	vars P = series(p);
	vars O = series(o);
	vars H = series(h);
	vars L = series(l);
	vars C = series(c);
	
	if(Init)
		print(TO_CSV,"yyyy-mm-dd HH:MM,frame(0),p,P[0],o,O[0],h,H[0],l,L[0],c,C[0]\r\n");
	else
		print(TO_CSV,"%04d-%02d-%02d %2d:%2d,%d,%0.5f,%0.5f,%0.5f,%0.5f,%0.5f,%0.5f,%0.5f,%0.5f,%0.5f,%0.5f\r\n",
			year(0),month(0),day(0),hour(0),minute(0),
			frame(0),p,P[0],o,O[0],h,H[0],l,L[0],c,C[0]
			);
	
}
...produces the attached CSV. It appears that priceOpen et. al. ignores frame(0), which is fine so long as you are using a series.

Attached Files
ohlc.csv (68 downloads)
Re: price...() returns last bar close regardless of TimeFrame [Re: AndrewAMD] #478831
12/28/19 00:31
12/28/19 00:31
Joined: Dec 2019
Posts: 53
ozgur Offline OP
Junior Member
ozgur  Offline OP
Junior Member

Joined: Dec 2019
Posts: 53
Thanks Andrew.

What is the source of your EURUSD data? I see 10 - 20 pip gaps between current open vs previous close (non-series function) which is a bit concerning. This seems not to be an issue with data from series though, so may not be data related issue. Then the question is what value do price functions return when frame is 0? Could this be a bug?

Last edited by ozgur; 12/28/19 00:32.
Re: price...() returns last bar close regardless of TimeFrame [Re: ozgur] #478832
12/28/19 10:34
12/28/19 10:34
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Look closer. Every single entry is four-bar. laugh

Re: price...() returns last bar close regardless of TimeFrame [Re: ozgur] #478833
12/28/19 13:36
12/28/19 13:36
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
So, it is a 'rolling' 4-hour bar...I am not sure earlier versions had this behavior.

And this is not at all what the manual implies.

But now knowing how it works, this 'feature' might have some applications.



Last edited by Zheka; 12/28/19 13:38.
Re: price...() returns last bar close regardless of TimeFrame [Re: Zheka] #478836
12/29/19 01:34
12/29/19 01:34
Joined: Dec 2019
Posts: 53
ozgur Offline OP
Junior Member
ozgur  Offline OP
Junior Member

Joined: Dec 2019
Posts: 53
Yeah, it has to be that way for priceOpen() @ TimeFrame=4, otherwise it would return open price of current H4 incomplete candle.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1