Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
I want to get the maximum value #475767
01/07/19 15:45
01/07/19 15:45
Joined: Dec 2018
Posts: 22
VN
C
Chuate Offline OP
Newbie
Chuate  Offline OP
Newbie
C

Joined: Dec 2018
Posts: 22
VN
Hello, I want to get the maximum value but the result is so weird. Do you know what is problem ? I can use MaxVal function but I want to use my own function

recent_max_H:5835419512674041400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000

Code:
var test(var *Highs, int Period)
{
	int count;
	var recent_max_H = 0;
	for(count = 1; count < Period; count++)
	{
		if (Highs[count] > recent_max_H) recent_max_H = Highs[count];

	}
	
	printf("nrecent_max_H:%f", recent_max_H);
	return 1;
	

}

function run()
{
	set(PLOTNOW|PARAMETERS);
	StartDate = 20180705;
	EndDate = 20180705;
	BarPeriod = 60;
	LookBack = 3;
	
 

	// create series of highs, closes, lows
	vars Highs = series(priceHigh());
	int Period_Bar = 50;
	if (test(Highs, Period_Bar) == 1)
	{
		enterLong();
	}
	
	
	
	
	
}


Re: I want to get the maximum value [Re: Chuate] #475780
01/07/19 19:28
01/07/19 19:28
Joined: Aug 2017
Posts: 102
Spain
B
Brax Offline
Member
Brax  Offline
Member
B

Joined: Aug 2017
Posts: 102
Spain
For correctly printing float values you must do this:

printf("nrecent_max_H:%f", (var) recent_max_H);

If you set LookBack = 3 and you have BarPeriod = 60, then you are storing in Highs the last three hours of data, so if you try to call test with Period_Bar = 50 you may have problems.

Correct the printf, put LookBack = 50 and try again.

Re: I want to get the maximum value [Re: Brax] #475789
01/08/19 03:49
01/08/19 03:49
Joined: Dec 2018
Posts: 22
VN
C
Chuate Offline OP
Newbie
Chuate  Offline OP
Newbie
C

Joined: Dec 2018
Posts: 22
VN
Originally Posted By: brax
For correctly printing float values you must do this:

printf("nrecent_max_H:%f", (var) recent_max_H);

If you set LookBack = 3 and you have BarPeriod = 60, then you are storing in Highs the last three hours of data, so if you try to call test with Period_Bar = 50 you may have problems.

Correct the printf, put LookBack = 50 and try again.


Thank you for helping. After changing LookBack, it worked laugh


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1