ApopheniaPays

Demonstration of how history length affects all EMA values

ApopheniaPays Cập nhật   
I saw some discussion of this so I whipped up an example to prove the that effect of history length on EMA values is pronounced, even for bars much further than the EMA length from the first candle of the chart.

This chart has two 89-bar EMAs of the close: a green one and a red one. However, for the red one, the first 89 bars of the graph are considered to have a close of "0", which is exactly whatTradingView's EMA calculation uses for bars before the start of the graph.

This is because unlike other moving averages, which reference the price of previous bars, the EMA references the EMA of previous bars. Therefore, bars closer to the beginning of the chart, where TradingView can't calculate an EMA because there is no previous EMA and therefore uses 0, will return substantially different values for the EMA() function that the same cart would with more history.

The further a bar is back in history, the less influence it has. However, every single historical bar has some influence on the EMA of every later bar.

To allow you to see this for yourself, this script contains the following inputs which you can change to see the effect:
-EMA period (default 89)
-Number of bars to ignore for EMA2 (default 89)
-decimal precision to show differences in. By making this a large number you can see that, although the effects diminish, history length affects all EMA values for the char.
-label spacing (increase this if you have a long history and run into TV's 50-label limit)
Phát hành các Ghi chú:
-Corrected error where ignored bars at beginning were still based on EMA length rather than input value
-Added bar labels to indicate integer multiples of EMA length

apop@apopheniapays.com
Twitter/TradingView: ApopheniaPays
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?