Tucsky / aggr

Cryptocurrency trades aggregator
https://charts.aggr.trade/
GNU General Public License v3.0
855 stars 244 forks source link

Unable to create custom indicator script #231

Closed LagoonProject closed 2 years ago

LagoonProject commented 2 years ago

Hi, I'm trying to create a MFI indicator script on https://charts.aggr.trade/ from "ADD+" > "Create blank indicator" with the following code :

//mfi
prc = ($price.high + $price.low + $price.close)/3
volume = vbuy + vsell
raw = prc * volume
var change = prc - prc[1]

posDay = Math.max(change, 0)
negday = -Math.min(change, 0)

posPeriod = sum(posDay, length)
negPeriod = sum(negday, length)

mfRatio = (posPeriod / negPeriod)
mfIndex = 100 - (100 / (1 + mfRatio))

line(mfIndex)

However I get only "na" and "100.00" as results like shown in the attached image.

aggr_MFI_capture

I get the same result for RSI if I create a blank indicator and paste the code of the built-in RSI script from aggr, it will show the same kind of line with "na" and "100.00" instead of the rsi numbers.

What am I doing wrong? Can somebody help ?

Thanks

Tucsky commented 2 years ago

Maybe this would help ? https://github.com/Tucsky/aggr/issues/53#issuecomment-876778782

LagoonProject commented 2 years ago

Maybe this would help ? #53 (comment)

definitely helps. Thank you so much