커뮤니티
가변이동평균(Variable Moving Average ) 식좀 부탁드립니다.
2003-10-07 00:00:00
1559
글번호 816
안녕하세요.가변이동평균[Variable Moving Average (VMA)]을 사용자 함수로 만들려고 하는데 식좀 부탁드립니다.
The smoothed moving average를 구하는 것 같은데 이리저리 궁리해도 안되네요...
http://www.futuresource.com/industry/vma.asp에 나오네요..미리 감사 드립니다.
Computing the Variable Moving Average
The formulae to calculate a normal, exponential, and smoothed moving average are below.
The normal moving average is:
Mat = (P1 +... + Pn) / n
Mat is the simple moving average for the current period.
Pn is the price for the nth interval.
n is the length of the moving average.
FutureSource computes the average of the past n intervals using the price specified for that period. Remember, you specify the price. It can be the open, high, low, close, midpoint, or average price.
The exponential moving average is:
EMAt = EMAt-1 + (k * (Pt - EMAt-1))
EMAt is the exponential moving average for the current period.
EMAt-1 is the exponential moving average for the previous period.
Pt is the price for the current interval.
K is the exponential smoothing constant.
FutureSource does not use an assigned weight (smoothing constant) to compute the exponential moving average. Instead, it asks you to specify the length of the moving average. You can then determine the weight from the formula listed below.
If you specify a moving average length of 10, the smoothing constant is 0.18. Here is how to determine the smoothing constant.
k = 2 / (n + 1)
k is the smoothing constant.
n is the length of the moving average.
Now, substitute the values in the formula.
k = 2 / (10 + 1)
= 2 / 11
=.1818
Conversely, if you know the smoothing constant, you must derive the length of the moving average. In this example, use a smoothing constant of .125. You can solve the above equation for the value of n, which produces the following formula:
n = (2 / k) - 1
Now, substitute the above values in the equation.
n = (2 /.125) - 1
= 16 - 1
= 15
Please remember that FutureSource always asks for the length of moving average, not the smoothing constant. If you know the smoothing constant, use the above formula to determine the length of the moving average. If you know the length of the moving average and want to know the smoothing constant, use the formula to solve for the smoothing constant or k.
The smoothed moving average is:
Mat = ( (Mat-1 * (S-1)) + Pt ) / S
Mat is the moving average for the current period.
Mat-1 is the moving average for previous period.
Pt is the price for the current interval.
S is the period for smoothing.
Note: You may find variations of the above formula.
답변 1
예스스탁 예스스탁 답변
2003-10-08 00:00:00
안녕하세요? 예스스탁입니다....
문의하신 Smoothed Moving Average를 예스트레이더에서 구현하면 다음과 같습니다...
=====사용자함수=======================================================
SmoothedAverage(이름)
Input: Price(Numeric), Length(Numeric);
Var: Sum(0);
If Length > 0 Then
{
If dayindex() == 1 Then
{
Sum = accumN(Price, Length);
SmoothedAverage = Sum / Length;
}
Else
{
SmoothedAverage = (Sum[1] - SmoothedAverage[1] + Price) / Length;
Sum = accumN(Price, Length);
};
};
=======지표==============================================================
SmoothedAverage(이름)
input : Period(20);
plot1(smoothedaverage(C, Period));
감사합니다...
> 관양 님이 쓴 글입니다.
> 제목 : 가변이동평균(Variable Moving Average ) 식좀 부탁드립니다.
> 안녕하세요.가변이동평균[Variable Moving Average (VMA)]을 사용자 함수로 만들려고 하는데 식좀 부탁드립니다.
The smoothed moving average를 구하는 것 같은데 이리저리 궁리해도 안되네요...
http://www.futuresource.com/industry/vma.asp에 나오네요..미리 감사 드립니다.
Computing the Variable Moving Average
The formulae to calculate a normal, exponential, and smoothed moving average are below.
The normal moving average is:
Mat = (P1 +... + Pn) / n
Mat is the simple moving average for the current period.
Pn is the price for the nth interval.
n is the length of the moving average.
FutureSource computes the average of the past n intervals using the price specified for that period. Remember, you specify the price. It can be the open, high, low, close, midpoint, or average price.
The exponential moving average is:
EMAt = EMAt-1 + (k * (Pt - EMAt-1))
EMAt is the exponential moving average for the current period.
EMAt-1 is the exponential moving average for the previous period.
Pt is the price for the current interval.
K is the exponential smoothing constant.
FutureSource does not use an assigned weight (smoothing constant) to compute the exponential moving average. Instead, it asks you to specify the length of the moving average. You can then determine the weight from the formula listed below.
If you specify a moving average length of 10, the smoothing constant is 0.18. Here is how to determine the smoothing constant.
k = 2 / (n + 1)
k is the smoothing constant.
n is the length of the moving average.
Now, substitute the values in the formula.
k = 2 / (10 + 1)
= 2 / 11
=.1818
Conversely, if you know the smoothing constant, you must derive the length of the moving average. In this example, use a smoothing constant of .125. You can solve the above equation for the value of n, which produces the following formula:
n = (2 / k) - 1
Now, substitute the above values in the equation.
n = (2 /.125) - 1
= 16 - 1
= 15
Please remember that FutureSource always asks for the length of moving average, not the smoothing constant. If you know the smoothing constant, use the above formula to determine the length of the moving average. If you know the length of the moving average and want to know the smoothing constant, use the formula to solve for the smoothing constant or k.
The smoothed moving average is:
Mat = ( (Mat-1 * (S-1)) + Pt ) / S
Mat is the moving average for the current period.
Mat-1 is the moving average for previous period.
Pt is the price for the current interval.
S is the period for smoothing.
Note: You may find variations of the above formula.
다음글
이전글