Help with calculation

Posted By: Qw3rty

Help with calculation - 06/17/19 09:10

Hi,

I am new to Zorro and C. I have been going through the manual and forums to get an idea of how the program and functions work.

How do I divide the close price of an asset by an indicator value?

function run()
{

vars c_euro= asset("EUR/USD");
var shortma = 20; //think I should use var not vars on this line
vars euro_ema= series(EMA(c_euro,shortma));

vars euro = (c_euro / euro_ema); // Not working
}

Do I need to use a loop or pointer (now is where I get lost)?

Any help would be awesome.

Qw3rty
Posted By: Grat

Re: Help with calculation - 06/17/19 11:45

This is a totally wrong

a) first set the asset - select the symbol

asset("EUR/USD");

b) prepare price set

vars c_euro= series(price());
Posted By: AndrewAMD

Re: Help with calculation - 06/17/19 11:59

Way off. You need to learn the difference between vars, var, and int.

Also, read the manual and verify what each function returns, and why.

For example, asset() does **not** return a vars.

Code
function run()
{
	asset("EUR/USD");
	vars c_euro= series(price());
	int shortma = 20;
	vars euro_ema= series(EMA(c_euro,shortma));
	vars euro = series(c_euro[0]/ euro_ema[0]);
}
Posted By: Qw3rty

Re: Help with calculation - 06/18/19 08:01

Thank you both for the replies. That makes sense.

I have gone through the manual as needed but not thorough enough I guess.
© 2024 lite-C Forums