Questions tagged [moving-average]

A calculation of the average value of the most recent (within some window) values in a time series, rather than the average of the entire series.

Moving average is a calculation of the average value of the most recent (within some window) values in a time series, rather than the average of the entire series.

1034 questions
-1
votes
1 answer

Moving average for multiple stock in python

I have been calculating the simple moving average of a stock using the code below: def SMA(data, period =30, column='Close'): return data[column].rolling(window=period).mean() df['SMA20']=SMA(df,20) df['SMA50']=SMA(df,50) How do I calculate…
-1
votes
3 answers

C# Boolean Window Most Common

I'm looking to create a moving window that stores boolean values and outputs the most common boolean value. I want to be able to add new values on the fly, for example: bool[] window = { false, false, true, true, true }; New 'false' value added,…
embedded.95
  • 63
  • 1
  • 8
-1
votes
1 answer

How do I create a 12 week moving average in Power BI that accounts for stores open less than 12 weeks?

I work for a retailer and made a rolling 12 week sales average the brute force way. More specifically, I made 12 measures to calculate the average for my 12 weeks individually. Then a 13th measure to average my 12 weeks. That said, if a store has…
m5edward
  • 25
  • 8
-1
votes
1 answer

Moving average in Arduino IDE with distance sensor

I was reviewing previous questions related to my topic, I found this: Moving average in C++ with arduino The problem I have is very similar, but I want to relize distance averages every 150 seconds from a vl6180x adafruit distance sensor. Average…
clclc
  • 3
  • 1
-1
votes
1 answer

MACD plot in python similar to tradingview figure

Here is an example of MACD plot using python. https://code.luasoftware.com/tutorials/algo-trading/python-mplfinance-plot-yfinance-candle-chart-moving-average-macd-and-volume/ I'd like the result (including colors and crossover points, etc.) to be…
user1424739
  • 11,937
  • 17
  • 63
  • 152
-1
votes
1 answer

Moving average in MYSQL without dates but grouped by another column

I have a table in MYSQL(version 5.7.33) which looks like shown…
-1
votes
1 answer

C# - Moving average

I'm fairly new to C# and can't seem to find anything working for me. I need to get data from the serial port which I can collect successfully. Every time I click the button the data gets displayed. This data needs to go in an array, over this array…
-1
votes
1 answer

Running average on SQL Data Stream

How do I modify the code below to add a running average of each group without: anything in the query that would force multiple passes (e.g., group by or partition by) potential overflow computing the running average A group of tuples are all…
torzihp
  • 9
  • 3
-1
votes
1 answer

MS Excel: Moving average last 12 months for each expenses (with the current date)

I would like to know what is the formula to know the average cost of the last 12 months for each expenses that I have with the current month and that keeps the last 12 months average as the months go by? To be more precise and for example: now we…
Max
  • 3
  • 3
-1
votes
1 answer

Three moving average cross over in trading view using pine script version @4

//@version=4 study(title="MA Cross", overlay=true, resolution="") fastMA = sma(close, 55) medMA= sma(close, 89) slowMA = sma(close,233) plot(fastMA, color = color.red) plot(medMA, color = color.green) plot(slowMA,color=…
-1
votes
1 answer

Calculating a 7 day average

I have this query. CREATE TABLE ip_logs ( `ip_address` VARCHAR(11), `start_date` VARCHAR(11), `end_date` VARCHAR(11), `time_stamp`, VARCHAR(20), `mappings`, INTEGER, `loc_id` INTEGER ); INSERT INTO ip_logs …
user3078335
  • 781
  • 4
  • 13
  • 24
-1
votes
2 answers

Simple program for running average in python yields index out of range

No imports allowed. I am writing a program for a simple moving average but keep getting an error. inp = 12345 lst = [int(x) for x in str(inp)] x = range (len(lst)) for n in x: An =((lst[n]+ lst[n+1])/2) print(An) n+=1 I keep…
-1
votes
1 answer

BitCoin Algo not iterating through historical data correctly

I'm creating a simple trading backtester on Bitcoin, yet I'm having trouble with the for loops in my code. The current code is based on 2 simple moving averages q and z (currently for learning purposes no real strategy). info is a dataframe holding…
GilbertN
  • 37
  • 5
-1
votes
2 answers

MySQL self-join optimization while calculating move averages

I have created a mysql query to calculate moving averages of data by using multiple self-joins as shown below. This is consuming lot of time and the data rows are in 100k per query. Any way to further optimize it to reduce time please? select…
-1
votes
1 answer

Pandas Moving Average

I am trying to plot the moving average for a rolling window of 30 days on a column of a Quandl dataset that I have added as a column of a pandas dataframe. The dataframe looks like: How do I firstly compute the moving average, and after that, how…
arnavlohe15
  • 332
  • 5
  • 16