Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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

2 Replies
sunny_talwar

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.