Auto Adjusting moving average, please assist

pacofflin

New Member
Joined
Jul 20, 2014
Messages
2
Hello everyone, I'm a day trader and would like to make a formula that adjusts a moving average with just one input change. I'm trying to get the average of the last X amount of days and change this based on the input of Days in test. I also want it to test only the number of days in test all the way down. Formula I have now only updates the currently selected number of days and 1 prior. Not sure what I've done wrong or how to fix it. I've been struggling with this for a few days now and would really appreciate some help. Thanks in advance.

=IF($I$2=G2;AVERAGE($E$2:E2);IF($I$2=G2-1;AVERAGE($E$2:E2);""))

[TABLE="width: 500"]
<tbody>[TR]
[TD]
1987.11.25134.75135134.4134.614
1987.11.26134.79134.8134.35134.432
1987.11.27134.55134.6133.4133.43
1987.11.30132.7133.2132132.44
1987.12.01132.4133.5132.1133.45133.7075
5
1987.12.02133.4134132.45132.6131.996
1987.12.03132.55133.2131.95132.957
1987.12.04133133.75131.95132.658
1987.12.07132.9133.15132.5133.19
1987.12.08133.1133.4132.65132.710
1987.12.09132.7132.7132.05132.2511
1987.12.10132.2132.35129.05129.2512
1987.12.11129.2129.25128.2128.3513
1987.12.14128.65128.65127.5128.114
1987.12.15128.1128.25126.85127.715
1988.01.04120.9123.35120.3123.2516
1988.01.05123.25128.45122.95128.3517
1988.01.06128.3131.9126.8129.4518
1988.01.07129.55130.75127.75130.419
1988.01.08130.35130.4128.25128.320
1988.01.11128.4128.9127.85128.5521
1988.01.12128.6128.6127.15127.4522
1988.01.13127.4127.6125.5127.3523
1988.01.14127.35127.35126.05126.124
1988.01.15126.1131.25126.1131.1525
1988.01.18131.1131.9129.5129.826
1988.01.19129.8129.95128.3128.627
1988.01.20128.55129.05127.15127.328
1988.01.21127.3127.9126.55127.329
1988.01.22127.3128.05127.05127.2530
1988.01.25127.5128.15127.4128.131
1988.01.26128.1128.3127.4127.732
1988.01.27127.6128.2126.95127.1533
1988.01.28127.1127.4126.9127.134
1988.01.29127.1128.1127.05128.135
1988.02.01128.35129.65128.3129.436
1988.02.02129.4129.4128.2128.337
1988.02.03128.25128.5127.75128.3538
1988.02.04128.3129.2127.912839
1988.02.05128129.5127.8129.4540
1988.02.08129.5129.65128.55128.941
1988.02.09128.9129.4128.8128.8542

<colgroup><col width="86"><col width="109"><col width="104"><col width="102"><col width="110"><col width="120"><col width="86"><col width="86"><col width="86"></colgroup> <tbody>
[TD="width: 86, bgcolor: #99FFFF"] Date [/TD]
[TD="width: 109, bgcolor: #99FFFF"] USD/JPY Open [/TD]
[TD="width: 104, bgcolor: #99FFFF"] USD/JPY High [/TD]
[TD="width: 102, bgcolor: #99FFFF"] USD/JPY Low [/TD]
[TD="width: 110, bgcolor: #99FFFF"] USD/JPY Close [/TD]
[TD="width: 120, bgcolor: #99FFFF"] Moving Average [/TD]
[TD="width: 86, bgcolor: #99FFFF"] Days [/TD]
[TD="width: 86"][/TD]
[TD="width: 86, bgcolor: #99FFFF"] Days in test [/TD]

</tbody>
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD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]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
What it should look like is this, just an example of the what the numbers should be if the formula was working correctly. It's currently taking a 4 day moving average of the [E] USD/JPY Close column.

1987.11.25134.75135134.4134.614
1987.11.26134.79134.8134.35134.432
1987.11.27134.55134.6133.4133.43
1987.11.30132.7133.2132132.44
1987.12.01132.4133.5132.1133.45133.70755
1987.12.02133.4134132.45132.6133.426
1987.12.03132.55133.2131.95132.95132.96257
1987.12.04133133.75131.95132.65132.858
1987.12.07132.9133.15132.5133.1132.91259
1987.12.08133.1133.4132.65132.7132.82510
1987.12.09132.7132.7132.05132.25132.8511
1987.12.10132.2132.35129.05129.25132.67512
1987.12.11129.2129.25128.2128.35131.82513
1987.12.14128.65128.65127.5128.1130.637514
1987.12.15128.1128.25126.85127.7129.487515
1988.01.04120.9123.35120.3123.25128.3516
1988.01.05123.25128.45122.95128.35126.8517
1988.01.06128.3131.9126.8129.45126.8518
1988.01.07129.55130.75127.75130.4127.187519
1988.01.08130.35130.4128.25128.3127.862520
1988.01.11128.4128.9127.85128.55129.12521
1988.01.12128.6128.6127.15127.45129.17522
1988.01.13127.4127.6125.5127.35128.67523
1988.01.14127.35127.35126.05126.1127.912524
1988.01.15126.1131.25126.1131.15127.362525
1988.01.18131.1131.9129.5129.8128.012526
1988.01.19129.8129.95128.3128.6128.627
1988.01.20128.55129.05127.15127.3128.912528
1988.01.21127.3127.9126.55127.3129.212529
1988.01.22127.3128.05127.05127.25128.2530
1988.01.25127.5128.15127.4128.1127.612531
1988.01.26128.1128.3127.4127.7127.487532
1988.01.27127.6128.2126.95127.15127.587533
1988.01.28127.1127.4126.9127.1127.5534
1988.01.29127.1128.1127.05128.1127.512535
1988.02.01128.35129.65128.3129.4127.512536
1988.02.02129.4129.4128.2128.3127.937537
1988.02.03128.25128.5127.75128.35128.22538
1988.02.04128.3129.2127.9128128.537539
1988.02.05128129.5127.8129.45128.512540
1988.02.08129.5129.65128.55128.9128.52541
1988.02.09128.9129.4128.8128.85128.67542

<colgroup><col width="86"><col width="109"><col width="104"><col width="102"><col width="110"><col width="120"><col width="86"><col width="86"><col width="86"></colgroup> <tbody>
[TD="width: 86, bgcolor: #99FFFF"] Date [/TD]
[TD="width: 109, bgcolor: #99FFFF"] USD/JPY Open [/TD]
[TD="width: 104, bgcolor: #99FFFF"] USD/JPY High [/TD]
[TD="width: 102, bgcolor: #99FFFF"] USD/JPY Low [/TD]
[TD="width: 110, bgcolor: #99FFFF"] USD/JPY Close [/TD]
[TD="width: 120, bgcolor: #99FFFF"] Moving Average [/TD]
[TD="width: 86, bgcolor: #99FFFF"] Days [/TD]
[TD="width: 86"][/TD]
[TD="width: 86, bgcolor: #99FFFF"] Days in test [/TD]

</tbody>
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top