Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Different moving averages in script

Hi

Can anyone give me a hand on how to create different moving averages in the script load?

I have some stock market data, daily values, and I want to create an average for the 5-10-20-50-100 and 200 days.

LOAD

          '$(_vNameOfStock)' as Ticker,

          '$(_vNameOfExchange)' as Exchange,

          Day(Date) As StartDate,

          Num(Month(Date)) As StartMonth,

          Year(Date) As StartYear,

          TradeDate,

          Open,

          High,

          Low,

          Close,

         Volume,

          [Adj Close]

                                                                 

    FROM $(URL_String) (txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Best regards

Espen

Labels (1)
2 Replies
sunny_talwar
MVP
MVP

I think you might need to use Peek() or Previous() ?

Also read here: Peek() vs Previous() – When to Use Each

Anonymous
Not applicable
Author

may be this?

Create a Bucket of your said days like, 0-5,5-10, 10-20 etc which cud be:

TradeDate-Date as Days

Buckets

Then Expression like: avg(Close) if not wrong or your business logic for average calculation.