valiant-hero

Centered Moving Average

valiant-hero تم تحديثه   
The Centered moving averages tries to resolve the problem that simple moving average are still not able to handle significant trends when forecasting.
When computing a running moving average in a centered way, placing the average in the middle time period makes sense.
If we average an even number of terms, we need to smooth the smoothed values.

Try to describe it with an example:
The following table shows the results using a centered moving average of 4.

nterim Steps
Period Value SMA Centered
1 9
1.5
2 8
2.5 9.5
3 9 9.5
3.5 9.5
4 12 10.0
4.5 10.5
5 9 10.750
5.5 11.0
6 12
6.5
7 11

This is the final table:
Period Value Centered MA
1 9
2 8
3 9 9.5
4 12 10.0
5 9 10.75
6 12
7 11

With this script we are able to process and display the centered moving average as described above.
In addition to this, however, the script is also able to estimate the potential projection of future data based on the available data by replicating where necessary the data of the last bar until the number of data necessary for the calculation of the required centered moving average is reached.

If for example I have 20 daily closings and I look for the moving average centered at 10, I receive the first data on the fifth day and the last data on the fourteenth day, so I have 5 days left uncovered, to remedy this I have to give the last value to the uncovered data the closing price of the last day.
The deviations work like the bollinger bands but must refer to the centered moving average.
ملاحظات الأخبار:
after some tests I found problems in calculating the projection of the centered mean, so I proceeded to rewrite the implementation by introducing the bands based on the required standard deviation
نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟