PINE LIBRARY

lib_momentum

Library "lib_momentum"
This library calculates the momentum, derived from a sample range of prior candles. Depending on set MomentumType it either deduces the momentum from the price, volume, or a product of both. If price/product are selected, you can choose from SampleType if only candle body, full range from high to low or a combination of both (body counts full, wicks half for each direction) should be used. Optional: You can choose to normalize the results, dividing each value by its average (normalization_ma_length, normalization_ma). This will allow comparison between different instruments. For the normalization Moving Average you can choose any currently supported in my lib_no_delay.

get_momentum(momentum_type, sample_type, sample_length, normalization_ma_length, normalization_ma)
  Parameters:
    momentum_type (series MomentumType): select one of MomentumType.[Price, Volume, Product] to sample the price, volume or a product of both
    sample_type (series SampleType): select one of SampleType.[Body, Range, Body_Range] to sample the body, total range from high to low or a combination of both (body count full, wicks half for each direction)
    sample_length (simple int): how many candles should be sampled (including the current)
    normalization_ma_length (simple int): if you want to normalize results (momentum / momentum average) this sets the period for the average. (default = 0 => no normalization)
    normalization_ma (simple MovingAverage enum from robbatt/lib_no_delay/9): is the type of moving average to normalize / compare with
  Returns: returns the current momentum [total, up, down] where the total line is not just (up - down) but also sampled over the sample_length and can therefore be used as trend indicator. If up/down fail to reach total's level it's a sign of decreasing momentum, if up/down exceed total the trend it's a sign of increasing momentum.
MATHstatisticstechindicator

Pine脚本库

本着真正的TradingView精神,作者将此Pine代码发布为开源脚本库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私下或在其它开源出版物中使用此脚本库,但在出版物中重复使用此代码受网站规则约束。

免责声明