correct use of if with series ?

Posted By: faustf

correct use of if with series ? - 01/07/21 13:53

hi guys i read a manual https://manual.zorro-project.com/series.htm , in particular this case
// correct use of conditional series
vars X = series(), Y = series();
if(priceClose() > Threshold) {
X[0] = priceClose(); // ok!
Y[0] = SMA(X,100);
...
}

i create the script like this

vars PriceHL = series(priceHigh() - priceLow());
var CellM = SMA(PriceHL, 48) + StdDev(PriceHL, 48);
if (PriceHL() > CellM)
{
printf("\nResult1 = %.f", CellM);
}

but return this error

@PriceHL_00311():syntax error
<if (PriceHL() > CellM)>

i search in manual for this error , but not find

https://zorro-project.com/manual/en/errors.htm

some one can help me ? thankz
Posted By: strimp099

Re: correct use of if with series ? - 02/18/21 12:55

You’re calling PriceHL as a function which it’s not. It’s a series. I also think CellM is not correctly defined. You need to wrap in series.

Code

If(PriceHL>CellM)

Posted By: ZorroTradeAA

Re: correct use of if with series ? - 03/12/21 19:40

Hi,

strimp099 is right. Prices is a series. I assume you want to compare the recent price with CellM.
How about that:
Code
if(PriceHL[0]>CellM )
...
© 2024 lite-C Forums