I want to get the maximum value

Posted By: Chuate

I want to get the maximum value - 01/07/19 15:45

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();
	}
	
	
	
	
	
}

Posted By: Brax

Re: I want to get the maximum value - 01/07/19 19:28

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

Re: I want to get the maximum value - 01/08/19 03:49

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