JBroadway

TimeLockedMA

JBroadway Cập nhật   
Library "TimeLockedMA"
Library & function(s) which generates a moving average that stays locked to users desired time preference.

TODO - Add functionality for more moving average types. IE: smooth, weighted etc...

Example:
time_locked_ma(close, length=1, timeframe='days', type='ema')
Will generate a 1 day exponential moving average that will stay consistent across all chart intervals.

Error Handling
On small time frames with large moving averages (IE: 1min chart with a 50 week moving average), you'll get a study error that says "(function "sma") references too many candles in history".
To fix this, make sure you have timeframe="" as an indicator() header. Next, in the indicator settings, increase the timeframe from to a higher interval until the error goes away.
By default, it's set to "Chart". Bringing the interval up to 1hr will usually solve the issue.

Furthermore, adding timeframe_gaps=false to your indicator() header will give you an approximation of real-time values.

Misc Info
For time_lock_ma() setting type='na' will return the relative length value that adjusts dynamically to user's chart time interval.
This is good for plugging into other functions where a lookback or length is required. (IE: Bollinger Bands)

time_locked_ma(source, length, timeframe, type) Creates a moving average that is locked to a desired timeframe
  Parameters:
    source: float, Moving average source
    length: int, Moving average length
    timeframe: string, Desired timeframe. Use: "minutes", "hours", "days", "weeks", "months", "chart"
    type: string, string Moving average type. Use "SMA" (default) or "EMA". Value of "NA" will return relative lookback length.
  Returns: moving average that is locked to desired timeframe.

timeframe_convert(t, a, b) Converts timeframe to desired timeframe. From a --> b
  Parameters:
    t: int, Time interval
    a: string, Time period
    b: string, Time period to convert to
  Returns: Converted timeframe value

chart_time(timeframe_period, timeframe_multiplier) Separates timeframe.period function and returns chart interval and period
  Parameters:
    timeframe_period: string, timeframe.period
    timeframe_multiplier: int, timeframe.multiplier

Enjoy :)
Phát hành các Ghi chú:
v2 - Added wma, vwma, and hma

Thư viện Pine

Với tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác từ cộng đồng của chúng tôi có thể sử dụng lại nó. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này một cách riêng tư hoặc trong các ấn phẩm mã nguồn mở khác, 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 chung.

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 thư viện này?

Sao chép văn bản vào khay nhớ tạm và dán nó vào tập lệnh của bạn.