├── .gitignore ├── README.md ├── bands_and_channels ├── acceleration_bands.pine ├── interquartile_range_bands.pine ├── kirshenbaum_bands.pine ├── mean_absolute_deviation_bands.pine ├── moving_average_channel.pine ├── stoller_average_range_channels.pine └── vortex_bands.pine ├── highlighters ├── bitmex_withdrawals_cutoff_time.pine ├── leap_years.pine ├── quarters.pine ├── range_candles.pine └── weekdays_gaps.pine ├── movings ├── adaptive_laguerre_filter.pine ├── adaptive_rsi_moving_average.pine ├── ahrens_moving_average.pine ├── alpha_decreasing_exponential_moving_average.pine ├── apirine_adaptive_exponential_moving_average.pine ├── apirine_adaptive_moving_average.pine ├── arnaud_legoux_moving_average.pine ├── bryant_adaptive_moving_average.pine ├── butterworth_filter.pine ├── corrected_moving_average.pine ├── distance_coefficient_filter.pine ├── distance_weighted_moving_average.pine ├── double_exponential_moving_average.pine ├── double_weighted_moving_average.pine ├── ehlers_deviation_scaled_moving_average.pine ├── ehlers_distance_coefficient_filter.pine ├── ehlers_leading_indicator.pine ├── ehlers_mesa_adaptive_moving_averages.pine ├── ehlers_modified_optimum_elliptic_filter.pine ├── ehlers_optimum_elliptic_filter.pine ├── ehlers_super_smoother_filter.pine ├── elastic_volume_weighted_moving_average.pine ├── exponential_moving_average.pine ├── farey_sequence_weighted_moving_average.pine ├── fibonacci_weighted_moving_average.pine ├── finite_impulse_response_filter.pine ├── fractal_adaptive_moving_average.pine ├── gaussian_filter.pine ├── hampel_filter.pine ├── henderson_weighted_moving_average.pine ├── holt_exponential_moving_average.pine ├── hull_moving_average.pine ├── infinite_impulse_response_filter.pine ├── inverse_distance_weighted_moving_average.pine ├── jurik_moving_average.pine ├── kaufman_adaptive_moving_average.pine ├── laguerre_filter.pine ├── least_squares_moving_average.pine ├── leo_moving_average.pine ├── linear_weighted_moving_average.pine ├── mcginley_dynamic.pine ├── mcnicholl_moving_average.pine ├── middle_high_low_moving_average.pine ├── moving_geometric_mean.pine ├── moving_harmonic_mean.pine ├── moving_median.pine ├── moving_quadratic_mean.pine ├── multiple_hull_moving_average.pine ├── parabolic_sar.pine ├── parabolic_weighted_moving_average.pine ├── pentuple_exponential_moving_average.pine ├── quadruple_exponential_moving_average.pine ├── quick_moving_average.pine ├── recursive_median_filter.pine ├── recursive_median_oscillator.pine ├── recursive_moving_trend_average.pine ├── regularized_exponential_moving_average.pine ├── self_weighted_moving_average.pine ├── sharp_modified_moving_average.pine ├── simple_moving_average.pine ├── sine_weighted_moving_average.pine ├── spencer_15_point_moving_average.pine ├── spencer_21_point_moving_average.pine ├── t3_moving_average.pine ├── triangular_moving_average.pine ├── trimean.pine ├── vidya_variable_index_dynamic_average.pine ├── weighted_moving_average.pine ├── wilder_modified_moving_average.pine └── zero_lag_exponential_moving_average.pine ├── oscillators ├── accelerator_oscillator.pine ├── accumulative_swing_index.pine ├── asymmetrical_rsi.pine ├── awesome_oscillator.pine ├── cci_commodity_channel_index.pine ├── center_of_gravity_oscillator.pine ├── chande_momentum_oscillator.pine ├── coppock_curve.pine ├── demarker.pine ├── derivative_oscillator.pine ├── didi_index.pine ├── disparity_index.pine ├── dorsey_inertia.pine ├── dynamic_momentum_index.pine ├── ehlers_cyber_cycle.pine ├── ehlers_decycler_oscillator.pine ├── ehlers_fisherized_deviation_scaled_oscillator.pine ├── ehlers_roofing_filter.pine ├── ehlers_smoothed_adaptive_momentum.pine ├── ehlers_stochastic.pine ├── ehlers_stochastic_cyber_cycle.pine ├── ehlers_super_passband_filter.pine ├── ehlers_triple_delay_line_detrender.pine ├── ergodic_oscillator.pine ├── forecast_oscillator.pine ├── gator_oscillator.pine ├── intraday_momentum_index.pine ├── jurik_rsx.pine ├── kairi_relative_index.pine ├── laguerre_rsi.pine ├── laguerre_rsi_self_adjusting_alpha_with_fractals_energy.pine ├── mass_index.pine ├── mfi_money_flow_index.pine ├── normalized_relative_vigor_index.pine ├── percentage_price_oscillator.pine ├── percentage_volume_oscillator.pine ├── phase_change_index.pine ├── pretty_good_oscillator.pine ├── price_momentum_oscillator.pine ├── pring_special_k.pine ├── rainbow_oscillator.pine ├── random_walk_index.pine ├── range_action_verification_index.pine ├── rapid_rsi.pine ├── recursive_median_oscillator.pine ├── regression_oscillator.pine ├── relative_momentum_index.pine ├── relative_spread_strength.pine ├── relative_volatility_index.pine ├── repulse.pine ├── rocket_rsi.pine ├── rsi_relative_strength_index.pine ├── rsx.pine ├── self_adjusting_rsi.pine ├── smoothed_rate_of_change.pine ├── stc_schaff_trend_cycle.pine ├── stiffness_indicator.pine ├── stochastic.pine ├── stochastic_connors_rsi.pine ├── stochastic_momentum_index.pine ├── tick_line_momentum_oscillator.pine ├── total_power_indicator.pine ├── trend_continuation_factor.pine ├── trend_detection_index.pine ├── trend_intensity_index.pine ├── trend_trigger_factor.pine ├── trendscore.pine ├── trix.pine ├── true_range_double.pine ├── tsi_true_strength_index.pine ├── v_macd.pine ├── vertical_horizontal_filter.pine └── vw_macd.pine ├── research ├── chart_type_identifier.pine ├── custom_median_vs_built_in_median.pine ├── dashed_line_style.pine ├── fancy_shapes.pine ├── heikin_ashi_chart_identifier.pine ├── kagi_chart_identifier.pine ├── litecoin_halving_utc_countdown.pine ├── mean_absolute_deviation.pine ├── momentum.pine ├── percentrank_bug.pine ├── point_and_figure_pnf_chart_identifier.pine ├── rate_of_change.pine ├── renko_chart_identifier.pine ├── script_with_expiration_time.pine ├── symbol_info_helper.pine └── utc_clock.pine ├── statistics ├── all_time_high_days.pine ├── all_time_high_percent_drop.pine ├── bitcoin_ath_hash_rate_level.pine ├── bullish_bearish_candle_series_distribution.pine ├── candles_history.pine ├── close_to_close_percent_change_distribution.pine ├── dividends_per_share_dps_yearly.pine ├── earnings_per_share_eps_yearly.pine ├── gaps_percent_size_distribution.pine ├── kendall_rank_correlation_coefficient.pine ├── kurtosis_indicator.pine ├── linear_regression_all_data.pine ├── roi_return_on_investment.pine ├── ticker_performance_by_us_president.pine ├── us_treasury_yields.pine ├── ytd_year_to_date_percent_return.pine └── z_score.pine ├── trailing_stops ├── chandelier_exit.pine ├── halftrend.pine ├── nrtr_nick_rypock_trailing_reverse.pine ├── parabolic_sar.pine └── supertrend.pine ├── utils ├── session_input_parser.pine └── unit_testing_framework.pine ├── volatility ├── damping_index.pine ├── gopalakrishnan_range_index.pine ├── mayer_multiple.pine ├── normalized_average_true_range.pine ├── ulcer_index.pine └── volatility_ratio.pine └── volume ├── accumulation_distribution_line.pine ├── klinger_volume_oscillator.pine ├── negative_volume_index.pine ├── net_volume.pine ├── on_balance_volume.pine ├── percent_volume.pine ├── positive_volume_index.pine ├── price_volume_trend.pine └── volume_accumulation.pine /.gitignore: -------------------------------------------------------------------------------- 1 | _dev/ 2 | 3 | *.log 4 | *.tgz 5 | .npm 6 | .node_repl_history 7 | .yarn-integrity 8 | .idea 9 | .vscode 10 | .DS_Store 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tradingview-pinescript-indicators 2 | 3 | A collection of various technical indicators implemented in the Pine Script language for the TradingView platform. 4 | -------------------------------------------------------------------------------- /bands_and_channels/acceleration_bands.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Acceleration Bands script may be freely distributed under the terms of the GPL-3.0 license. 4 | study(title="Acceleration Bands", shorttitle="AB", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=20) 7 | factor = input(title="Factor", type=float, defval=0.001, step=0.0001) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | mult = 4000 * factor * (high - low) / (high + low) 11 | 12 | upperBandSrc = high * (1 + mult) 13 | upperBand = sma(upperBandSrc, length) 14 | 15 | basis = sma(src, length) 16 | 17 | lowerBandSrc = low * (1 - mult) 18 | lowerBand = sma(lowerBandSrc, length) 19 | 20 | upperBandPlot = plot(upperBand, title="Upper", linewidth=1, color=#138484, transp=0) 21 | 22 | plot(basis, title="Basis", linewidth=1, color=#741b47, transp=0) 23 | 24 | lowerBandPlot = plot(lowerBand, title="Lower", linewidth=1, color=#138484, transp=0) 25 | 26 | fill(upperBandPlot, lowerBandPlot, title="Background", color=color(#ffd966, 84)) 27 | -------------------------------------------------------------------------------- /bands_and_channels/interquartile_range_bands.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Interquartile Range Bands script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Interquartile Range Bands", shorttitle="IQRB", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | mult = input(title="Multiplier", type=float, minval=0, step=0.1, defval=1.5) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | q1 = percentile_nearest_rank(src, length, 25) 11 | median= percentile_nearest_rank(src, length, 50) 12 | q3 = percentile_nearest_rank(src, length, 75) 13 | 14 | iqr = q3 - q1 15 | 16 | upperBand = q3 + mult * iqr 17 | lowerBand = q1 - mult * iqr 18 | 19 | upperBandPlot = plot(upperBand, title="Upper", color=#138484, transp=0) 20 | plot(median, title="Median", color=#741b47, transp=0) 21 | lowerBandPlot = plot(lowerBand, title="Lower", color=#138484, transp=0) 22 | fill(upperBandPlot, lowerBandPlot, title="Background", color=color(#ffd966, 84)) 23 | -------------------------------------------------------------------------------- /bands_and_channels/kirshenbaum_bands.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Kirshenbaum Bands script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Kirshenbaum Bands", shorttitle="KB", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=30) 7 | regressionLength = input(title="Regression Length", type=integer, defval=20) 8 | mult = input(title="Multiplier", type=float, step=0.1, defval=1.75) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | regression = linreg(src, regressionLength, 0) 12 | stderror = mult * sqrt(sma(pow(src - regression, 2), regressionLength)) 13 | 14 | basis = ema(src, length) 15 | upper = basis + stderror 16 | lower = basis - stderror 17 | 18 | plot(basis, title="Basis", color=#351c75, transp=0) 19 | upperBandPlot = plot(upper, title="Upper", color=#45818e, transp=0) 20 | lowerBandPlot = plot(lower, title="Lower", color=#45818e, transp=0) 21 | fill(upperBandPlot, lowerBandPlot, title="Background", color=color(#ffd966, 84)) 22 | -------------------------------------------------------------------------------- /bands_and_channels/mean_absolute_deviation_bands.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2020-present, Alex Orekhov (everget) 3 | // Mean Absolute Deviation Bands script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Mean Absolute Deviation Bands", shorttitle="MADB", overlay=true) 5 | 6 | length = input(title="Length", defval=20, minval=2) 7 | mult = input(title="Bands Multiplier", defval=2.0, type=input.float, step=0.1) 8 | src = input(title="Source", defval=close) 9 | 10 | basis = sma(src, length) 11 | dev = mult * dev(src, length) 12 | upper = basis + dev 13 | lower = basis - dev 14 | 15 | plot(basis, title="Basis", color=#351c75, transp=0) 16 | upperPlot = plot(upper, title="Upper", color=#45818e, transp=0) 17 | lowerPlot = plot(lower, title="Lower", color=#45818e, transp=0) 18 | fill(upperPlot, lowerPlot, title="MADB Background", color=color.new(#ffd966, 84)) 19 | -------------------------------------------------------------------------------- /bands_and_channels/moving_average_channel.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2017-present, Alex Orekhov (everget) 3 | // Moving Average Channel script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Moving Average Channel", shorttitle="MAC", overlay=true) 5 | 6 | upperSrc = input(title="Upper Source", type=input.source, defval=high) 7 | upperLength = input(title="Upper Length", type=input.integer, defval=20) 8 | upperOffset = input(title="Upper Offset", type=input.integer, defval=0) 9 | 10 | upper = sma(upperSrc, upperLength) 11 | upperPlot = plot(upper, title="Upper", color=#3c78d8, offset=upperOffset, transp=0) 12 | 13 | lowerSrc = input(title="Lower Source", type=input.source, defval=low) 14 | lowerLength = input(title="Lower Length", type=input.integer, defval=20) 15 | lowerOffset = input(title="Lower Offset", type=input.integer, defval=0) 16 | 17 | lower = sma(lowerSrc, lowerLength) 18 | lowerPlot = plot(lower, title="Lower", color=#f57c00, offset=lowerOffset, transp=0) 19 | 20 | fill(upperPlot, lowerPlot, title="Background", color=color.new(#ffd966, 90)) 21 | 22 | barColor = close > upper ? color.lime : close < lower ? color.red : color.gray 23 | barcolor(barColor, title="Bar Color") 24 | -------------------------------------------------------------------------------- /bands_and_channels/stoller_average_range_channels.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Stoller Average Range Channels (STARC) Bands script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Stoller Average Range Channels (STARC) Bands", shorttitle="STARC", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=6) 7 | maInput = input(title="MA", defval="SMA", options=["EMA", "SMA", "VWMA", "WMA"]) 8 | atrLength = input(title="ATR Length", type=integer, minval=1, defval=15) 9 | mult = input(title="Multiplier", type=float, step=0.1, defval=1.33) 10 | src = input(title="Source", type=source, defval=close) 11 | 12 | basis = iff(maInput == "EMA", ema(src, length), 13 | iff(maInput == "SMA", sma(src, length), 14 | iff(maInput == "VWMA", vwma(src, length), 15 | iff(maInput == "WMA", wma(src, length), 16 | na)))) 17 | 18 | upperBand = basis + atr(length) * mult 19 | lowerBand = basis - atr(length) * mult 20 | 21 | plot(upperBand, title="Upper", linewidth=2, color=blue, transp=0) 22 | plot(basis, title="Basis", linewidth=2, color=#6d1e7f, transp=0) 23 | plot(lowerBand, title="Lower", linewidth=2, color=red, transp=0) 24 | -------------------------------------------------------------------------------- /bands_and_channels/vortex_bands.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2020-present, Alex Orekhov (everget) 3 | // Vortex Bands script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Vortex Bands", shorttitle="VB", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=20) 7 | mult = input(title="Multiplier", type=input.float, step=0.1, defval=2) 8 | src = input(title="Source", type=input.source, defval=hlc3) 9 | barColoringType = input(title="Bar Coloring", defval="None", options=["None", "Upper > Lower", "Close Above/Below Basis", "Close Inside Cloud", "Wicks Inside Cloud"]) 10 | 11 | _ema(src, alpha) => 12 | out = src 13 | out := alpha * out + (1 - alpha) * nz(out[1], out) 14 | out 15 | 16 | _mnma(src, length) => 17 | alpha = 2 / (length + 1) 18 | ema1 = _ema(src, alpha) 19 | ema2 = _ema(ema1, alpha) 20 | out = ((2 - alpha) * ema1 - ema2) / (1 - alpha) 21 | out 22 | 23 | basis = _mnma(src, length) 24 | dev = mult * _mnma(src - basis, length) 25 | 26 | upper = basis + dev 27 | lower = basis - dev 28 | 29 | plot(basis, title="Basis", color=color.maroon, transp=0) 30 | upperBandPlot = plot(upper, title="Upper", linewidth=2, color=color.blue) 31 | lowerBandPlot = plot(lower, title="Lower", linewidth=2, color=color.orange) 32 | fill(upperBandPlot, lowerBandPlot, title="Background", color=color.new(#ffd966, 90)) 33 | 34 | barColor = 35 | barColoringType == "Upper > Lower" ? (upper > lower ? color.lime : color.red) : 36 | barColoringType == "Close Above/Below Basis" ? (close > basis ? color.lime : color.red) : 37 | barColoringType == "Close Inside Cloud" ? (min(upper, lower) < close and close < max(upper, lower) ? color.lime : color.red) : 38 | barColoringType == "Wicks Inside Cloud" ? (min(upper, lower) < low and high < max(upper, lower) ? color.lime : color.red) : 39 | na 40 | 41 | barcolor(barColor, title="Bar Color") 42 | -------------------------------------------------------------------------------- /highlighters/bitmex_withdrawals_cutoff_time.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // BitMEX Withdrawals Cutoff Time script may be freely distributed under the terms of GPL-3.0 license. 4 | study("BitMEX Withdrawals Cutoff Time", overlay=true) 5 | 6 | transparency = input(title="Transparency", minval=0, defval=70) 7 | 8 | cutoff = hour(time) == 13 9 | transparent = color(white, 100) 10 | 11 | bgcolor(cutoff ? #f57f17 : transparent, title="Cutoff Time", transp=transparency) -------------------------------------------------------------------------------- /highlighters/leap_years.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | study("Leap Years", overlay=true) 4 | 5 | transparency = input(title="Transparency", type=integer, defval=88, minval=0, maxval=100) 6 | showLabels = input(title="Show Labels ? ", type=bool, defval=true) 7 | 8 | transparent = color(white, 100) 9 | labelColor = #1e90ff 10 | bgColor = #ffa726 11 | 12 | isLeap = false 13 | 14 | if year % 4 != 0 // year is not divisible by 4 15 | // it is a common year 16 | isLeap := false 17 | else 18 | if year % 100 != 0 // year is not divisible by 100 19 | // it is a leap year 20 | isLeap := true 21 | else 22 | if year % 400 != 0 // year is not divisible by 400 23 | // it is a common year 24 | isLeap := false 25 | else 26 | // it is a leap year 27 | isLeap := true 28 | 29 | lyText = " Leap \nYear " 30 | lyStart = year != year[1] and isLeap 31 | plotshape(showLabels and lyStart, title=lyText, text=lyText, color=labelColor, textcolor=white, style=shape.labelup, location=location.belowbar, size=size.small, transp=0) 32 | bgcolor(title="Leap Year", color=isLeap ? bgColor : transparent, transp=transparency) 33 | -------------------------------------------------------------------------------- /highlighters/quarters.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | study("Quarters", overlay=true) 4 | 5 | transparency = input(title="Transparency", type=integer, defval=88, minval=0, maxval=100) 6 | showLabels = input(title="Show Labels ? ", type=bool, defval=true) 7 | 8 | transparent = color(white, 100) 9 | labelColor = #1e90ff 10 | 11 | m = month(time) 12 | 13 | q1Text = " Q1 " 14 | q1Start = m[1] == 12 and m == 1 15 | q1 = m == 1 or m == 2 or m == 3 16 | plotshape(showLabels and q1Start, title=q1Text, text=q1Text, color=labelColor, textcolor=white, style=shape.labelup, location=location.belowbar, size=size.small, transp=0) 17 | bgcolor(title="Q1", color=q1 ? #e6194b : transparent, transp=transparency) 18 | 19 | q2Text = " Q2 " 20 | q2Start = m[1] == 3 and m == 4 21 | q2 = m == 4 or m == 5 or m == 6 22 | plotshape(showLabels and q2Start, title=q2Text, text=q2Text, color=labelColor, textcolor=white, style=shape.labelup, location=location.belowbar, size=size.small, transp=0) 23 | bgcolor(title="Q2", color=q2 ? #3cb44b : transparent, transp=transparency) 24 | 25 | q3Text = " Q3 " 26 | q3Start = m[1] == 6 and m == 7 27 | q3 = m == 7 or m == 8 or m == 9 28 | plotshape(showLabels and q3Start, title=q3Text, text=q3Text, color=labelColor, textcolor=white, style=shape.labelup, location=location.belowbar, size=size.small, transp=0) 29 | bgcolor(title="Q3", color=q3 ? #ffe119 : transparent, transp=transparency) 30 | 31 | q4Text = " Q4 " 32 | q4Start = m[1] == 9 and m == 10 33 | q4 = m == 10 or m == 11 or m == 12 34 | plotshape(showLabels and q4Start, title=q4Text, text=q4Text, color=labelColor, textcolor=white, style=shape.labelup, location=location.belowbar, size=size.small, transp=0) 35 | bgcolor(title="Q4", color=q4 ? #f58231 : transparent, transp=transparency) 36 | -------------------------------------------------------------------------------- /highlighters/range_candles.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2020-present, Alex Orekhov (everget) 3 | // Range Candles script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Range Candles", overlay=true) 5 | 6 | var color bullColor = input(title="Bull Color", defval=#26a69a) 7 | var color bearColor = input(title="Bear Color", defval=#ef5350) 8 | candleColor = close >= open ? bullColor : bearColor 9 | 10 | plotcandle( 11 | open, 12 | high, 13 | low, 14 | close, 15 | title="", 16 | color=candleColor, 17 | bordercolor=candleColor, 18 | wickcolor=candleColor 19 | ) 20 | -------------------------------------------------------------------------------- /highlighters/weekdays_gaps.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Weekdays Gaps script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Weekdays Gaps", overlay=true) 5 | 6 | td = dayofweek(time) 7 | yd = dayofweek(time[1]) 8 | 9 | mo = dayofweek.monday 10 | tu = dayofweek.tuesday 11 | we = dayofweek.wednesday 12 | th = dayofweek.thursday 13 | fr = dayofweek.friday 14 | sa = dayofweek.saturday 15 | su = dayofweek.sunday 16 | 17 | gaps = td == mo and yd != su or 18 | td == tu and yd != mo or 19 | td == we and yd != tu or 20 | td == th and yd != we or 21 | td == fr and yd != th or 22 | td == sa and yd != fr or 23 | td == su and yd != sa 24 | 25 | gapColor = color.new(#ffcc80, 70) 26 | noneColor = color.new(color.white, 100) 27 | bgcolor(gaps ? gapColor : noneColor, title="Gap") 28 | -------------------------------------------------------------------------------- /movings/adaptive_laguerre_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Adaptive Laguerre Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Adaptive Laguerre Filter", shorttitle="ALF", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | medianLength = input(title="Median Length", type=input.integer, defval=5) 8 | src = input(title="Source", type=input.source, defval=close) 9 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 10 | awaitBarConfirmation = input(title="Await Bar Confirmation ?", type=input.bool, defval=true) 11 | 12 | _median(src, length) => 13 | percentile_nearest_rank(src, length, 50) 14 | 15 | alf = 0.0 16 | 17 | diff = abs(src - nz(alf[1], src)) 18 | 19 | HH = 0.0 20 | HH := diff 21 | 22 | LL = 0.0 23 | LL := diff 24 | 25 | for i = 0 to length - 1 26 | if nz(diff[i]) > HH 27 | HH := nz(diff[i]) 28 | HH 29 | 30 | if nz(diff[i]) < LL 31 | LL := nz(diff[i]) 32 | LL 33 | 34 | alpha = 0.0 35 | alpha := HH - LL != 0.0 ? _median((diff - LL) / (HH - LL), medianLength) : nz(alpha[1], 2 / (length + 1)) 36 | alpha2 = 1 - alpha 37 | 38 | L0 = 0.0 39 | L0 := alpha * src + alpha2 * nz(L0[1], src) 40 | 41 | L1 = 0.0 42 | L1 := nz(L0[1], src) + alpha2 * (nz(L1[1], src) - L0) 43 | 44 | L2 = 0.0 45 | L2 := nz(L1[1], src) + alpha2 * (nz(L2[1], src) - L1) 46 | 47 | L3 = 0.0 48 | L3 := nz(L2[1], src) + alpha2 * (nz(L3[1], src) - L2) 49 | 50 | alf := (L0 + 2 * L1 + 2 * L2 + L3) / 6 51 | 52 | await = awaitBarConfirmation ? barstate.isconfirmed : true 53 | 54 | alfColor = highlight ? (alf > alf[1] and await ? color.green : color.red) : #6d1e7f 55 | plot(alf, title="ALF", linewidth=2, color=alfColor, transp=0) 56 | 57 | alertCond = alfColor != alfColor[1] and await 58 | alertcondition(alertCond, title="Color Change", message="ALF has changed its color!") 59 | -------------------------------------------------------------------------------- /movings/adaptive_rsi_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Adaptive RSI Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Adaptive RSI Moving Average", shorttitle="ARSIMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | alpha = 2 * abs(rsi(src, length) / 100 - 0.5) 11 | 12 | arsima = 0.0 13 | arsima := alpha * src + (1 - alpha) * nz(arsima[1]) 14 | 15 | arsimaColor = highlight ? arsima > arsima[1] ? color.green : color.red : #6d1e7f 16 | plot(arsima, title="ARSIMA", linewidth=2, color=arsimaColor, transp=0) 17 | -------------------------------------------------------------------------------- /movings/ahrens_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ahrens Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ahrens Moving Average", shorttitle="AHMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=9) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | ahma = 0.0 11 | ahma1 = nz(ahma[1]) 12 | ahma := ahma1 + (src - (ahma1 + nz(ahma[length])) / 2) / length 13 | 14 | ahmaColor = highlight ? ahma > ahma[1] ? color.green : color.red : #6d1e7f 15 | plot(ahma, title="AHMA", linewidth=2, color=ahmaColor, transp=0) 16 | -------------------------------------------------------------------------------- /movings/alpha_decreasing_exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Alpha-Decreasing Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Alpha-Decreasing Exponential Moving Average", shorttitle="ADEMA", overlay=true) 5 | 6 | alpha = 2 / (int(bar_index) + 1) 7 | 8 | ema = close 9 | ema := alpha * ema + (1 - alpha) * nz(ema[1], ema) 10 | 11 | plot(ema, title="ADEMA", linewidth=2, color=color.orange) 12 | -------------------------------------------------------------------------------- /movings/apirine_adaptive_exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Vitali Apirine 3 | // Copyright (c) 2019-present, Alex Orekhov (everget) 4 | // Adaptive Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 5 | study("Adaptive Exponential Moving Average", shorttitle="AEMA", overlay=true) 6 | 7 | length = input(title="Length", type=integer, defval=10) 8 | hlLookback = input(title="Highest/Lowest Lookback", type=integer, defval=10) 9 | src = input(title="Source", type=source, defval=close) 10 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=false) 11 | 12 | hh = highest(hlLookback) 13 | ll = lowest(hlLookback) 14 | 15 | mltp1 = 2 / (length + 1) 16 | mltp2 = hh - ll != 0 ? abs(2 * src - ll - hh) / (hh - ll) : 0 17 | 18 | rate = mltp1 * (1 + mltp2) 19 | 20 | ma = 0.0 21 | if n <= length 22 | ma := sma(src, length) 23 | else 24 | ma := nz(ma[1], src) + rate * (src - nz(ma[1], src)) 25 | 26 | maColor = highlightMovements ? (ma > ma[1] ? green : red) : #512da8 27 | plot(ma, title="AMA", linewidth=2, color=maColor, transp=0) 28 | -------------------------------------------------------------------------------- /movings/apirine_adaptive_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Apirine Adaptive Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Apirine Adaptive Moving Average", shorttitle="AAMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | fastLength = input(title="Fast EMA Length", type=input.integer, defval=2) 8 | slowLength = input(title="Slow EMA Length", type=input.integer, defval=30) 9 | src = input(title="Source", type=input.source, defval=close) 10 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 11 | 12 | fastAlpha = 2 / (fastLength + 1) 13 | slowAlpha = 2 / (slowLength + 1) 14 | 15 | hh = highest(length + 1) 16 | ll = lowest(length + 1) 17 | 18 | mltp = hh - ll != 0 ? abs(2 * src - ll - hh) / (hh - ll) : 0 19 | 20 | ssc = mltp * (fastAlpha - slowAlpha) + slowAlpha 21 | 22 | aama = 0.0 23 | aama := nz(aama[1], src) + pow(ssc, 2) * (src - nz(aama[1], src)) 24 | 25 | aamaColor = highlight ? aama > aama[1] ? color.green : color.red : #6d1e7f 26 | plot(aama, title="AAMA", linewidth=2, color=aamaColor, transp=0) 27 | -------------------------------------------------------------------------------- /movings/arnaud_legoux_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Arnaud Legoux Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Arnaud Legoux Moving Average", shorttitle="ALMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=9) 7 | offset = input(title="Offset", type=float, defval=0.85) 8 | sigma = input(title="Sigma", type=float, defval=6) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | plot(alma(src, length, offset, sigma), title="ALMA", linewidth=2, color=#e69138, transp=0) 12 | -------------------------------------------------------------------------------- /movings/bryant_adaptive_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2014-present, Michael R. Bryant 3 | // Copyright (c) 2019-present, Alex Orekhov (everget) 4 | // Bryant Adaptive Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 5 | study("Bryant Adaptive Moving Average", shorttitle="BAMA", overlay=true) 6 | 7 | length = input(title="Length", type=integer, defval=14) 8 | trendParam = input(title="Trend Parameter", type=float, defval=-1, step=0.1) 9 | maxLength = input(title="Max Length", type=integer, defval=100) 10 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=false) 11 | src = input(title="Source", type=source, defval=close) 12 | 13 | mom = abs(change(src, length)) 14 | volatility = sum(abs(change(src)), length) 15 | 16 | // Efficiency Ratio 17 | er = volatility != 0 ? mom / volatility : 0 18 | 19 | // Variable Efficiency Ratio 20 | ver = pow(er - (2 * er - 1) / 2 * (1 - trendParam) + 0.5, 2) 21 | 22 | vlength = (length - ver + 1) / ver 23 | vlength := vlength > maxLength ? maxLength : vlength 24 | 25 | valpha = 2 / (vlength + 1) 26 | 27 | bama = src 28 | bama := valpha * src + (1 - valpha) * nz(bama[1], bama) 29 | 30 | bamaColor = highlightMovements ? (bama > bama[1] ? green : red) : #6d1e7f 31 | plot(bama, title="BAMA", linewidth=2, color=bamaColor, transp=0) 32 | -------------------------------------------------------------------------------- /movings/butterworth_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Butterworth Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Butterworth Filter", shorttitle="BF", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, minval=1, defval=14) 7 | poles = input(title="Poles", type=input.integer, defval=2, options=[2, 3]) 8 | src = input(title="Source", type=input.source, defval=close) 9 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 10 | 11 | PI = 2 * asin(1) 12 | 13 | _bf2(src, length) => 14 | a = exp(-sqrt(2) * PI / length) 15 | b = 2 * a * cos(sqrt(2) * PI / length) 16 | 17 | src1 = nz(src[1], src) 18 | src2 = nz(src[2], src1) 19 | 20 | bf = 0.0 21 | bf1 = nz(bf[1], src) 22 | bf2 = nz(bf[2], bf1) 23 | 24 | bf := 25 | b * bf1 - 26 | pow(a, 2) * bf2 + 27 | (1 - b + pow(a, 2)) / 4 * (src + 2 * src1 + src2) 28 | bf 29 | 30 | _bf3(src, length) => 31 | a = exp(-PI / length) 32 | b = 2 * a * cos(1.738 * PI / length) 33 | c = pow(a, 2) 34 | 35 | src1 = nz(src[1], src) 36 | src2 = nz(src[2], src1) 37 | src3 = nz(src[3], src2) 38 | 39 | bf = 0.0 40 | bf1 = nz(bf[1], src) 41 | bf2 = nz(bf[2], bf1) 42 | bf3 = nz(bf[3], bf2) 43 | 44 | bf := 45 | (b + c) * bf1 - 46 | (c + b * c) * bf2 + 47 | pow(c, 2) * bf3 + 48 | (1 - b + c) * (1 - c) / 8 * (src + 3 * src1 + 3 * src2 + src3) 49 | bf 50 | 51 | bf = poles == 2 52 | ? _bf2(src, length) 53 | : _bf3(src, length) 54 | 55 | bfColor = highlight ? bf > bf[1] ? color.green : color.red : #6d1e7f 56 | plot(bf, title="BF", linewidth=2, color=bfColor, transp=0) 57 | -------------------------------------------------------------------------------- /movings/corrected_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2020-present, Alex Orekhov (everget) 3 | // Corrected Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Corrected Moving Average", shorttitle="CMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=35) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight CMA ?", type=input.bool, defval=false) 9 | applyFilling = input(title="Apply Ribbon Filling ?", type=input.bool, defval=true) 10 | 11 | sma = sma(src, length) 12 | cma = sma 13 | 14 | v1 = variance(src, length) 15 | v2 = pow(nz(cma[1], cma) - sma, 2) 16 | v3 = v1 == 0 or v2 == 0 ? 1 : v2 / (v1 + v2) 17 | 18 | var tolerance = pow(10, -5) 19 | float err = 1 20 | 21 | // Gain Factor 22 | float kPrev = 1 23 | float k = 1 24 | 25 | for i = 0 to 5000 26 | if err > tolerance 27 | k := v3 * kPrev * (2 - kPrev) 28 | err := kPrev - k 29 | kPrev := k 30 | 31 | cma := nz(cma[1], src) + k * (sma - nz(cma[1], src)) 32 | 33 | cmaColor = highlight ? (cma > cma[1] ? color.green : color.red) : color.orange 34 | cmaPlot = plot(cma, title="CMA", linewidth=2, color=cmaColor) 35 | smaPlot = plot(sma, title="SMA", linewidth=2, color=color.blue) 36 | 37 | fillColor = applyFilling ? (sma > cma ? #0ebb23 : #cc0000) : color.new(color.white, 100) 38 | fill(smaPlot, cmaPlot, color=fillColor, transp=80) 39 | 40 | long = crossover(sma, cma) 41 | short = crossunder(sma, cma) 42 | 43 | alertcondition(long, title="Long", message="Long") 44 | alertcondition(short, title="Short", message="Short") 45 | -------------------------------------------------------------------------------- /movings/distance_coefficient_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Distance Coefficient Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ehlers Distance Coefficient Filter", shorttitle="EDCF", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | src = input(title="Source", type=source, defval=hl2) 8 | 9 | srcSum = 0.0 10 | coefSum = 0.0 11 | 12 | for count = 0 to length - 1 13 | distance = 0.0 14 | 15 | for lookback = 1 to length - 1 16 | distance := distance + pow(src[count] - src[count + lookback], 2) 17 | 18 | srcSum := srcSum + distance * src[count] 19 | coefSum := coefSum + distance 20 | 21 | dcf = coefSum != 0 ? srcSum / coefSum : 0.0 22 | 23 | plot(dcf, title="EDCF", linewidth=2, color=#6d1e7f, transp=0) 24 | -------------------------------------------------------------------------------- /movings/distance_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Distance Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Distance Weighted Moving Average", shorttitle="DWMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | sum = 0.0 11 | weightSum = 0.0 12 | 13 | calcWeight(src, length, i) => 14 | distanceSum = 0.0 15 | for j = 0 to length - 1 16 | distanceSum := distanceSum + abs(nz(src[i]) - nz(src[j])) 17 | 1 / distanceSum 18 | 19 | for i = 0 to length - 1 20 | weight = calcWeight(src, length, i) 21 | sum := sum + nz(src[i]) * weight 22 | weightSum := weightSum + weight 23 | 24 | dwma = sum / weightSum 25 | 26 | dwmaColor = highlightMovements ? (dwma > dwma[1] ? green : red) : #6d1e7f 27 | plot(dwma, title="DWMA", linewidth=2, color=dwmaColor, transp=0) 28 | -------------------------------------------------------------------------------- /movings/double_exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Double Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Double Exponential Moving Average", shorttitle="DEMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | dema(src, length) => 10 | ema1 = ema(src, length) 11 | ema2 = ema(ema1, length) 12 | dema = 2 * ema1 - ema2 13 | 14 | plot(dema(src, length), title="DEMA", linewidth=2, color=#6d1e7f, transp=0) 15 | -------------------------------------------------------------------------------- /movings/double_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Double Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Double Weighted Moving Average", shorttitle="DWMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=10) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | dwma = wma(wma(src, length), length) 11 | 12 | dwmaColor = highlightMovements ? (dwma > dwma[1] ? green : red) : #6d1e7f 13 | plot(dwma, title="DWMA", linewidth=2, color=dwmaColor, transp=0) 14 | -------------------------------------------------------------------------------- /movings/ehlers_deviation_scaled_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Deviation-Scaled Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ehlers Deviation-Scaled Moving Average", shorttitle="EDSMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=40, minval=2) 7 | ssfLength = input(title="Super Smoother Filter Length", type=integer, defval=20, minval=1) 8 | numberOfPoles = input(title="Number of Poles", type=integer, defval=2, options=[2, 3]) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | PI = 2 * asin(1) 12 | 13 | twoPoleSuperSmootherFilter(src, length) => 14 | arg = sqrt(2) * PI / length 15 | a1 = exp(-arg) 16 | b1 = 2 * a1 * cos(arg) 17 | c2 = b1 18 | c3 = -pow(a1, 2) 19 | c1 = 1 - c2 - c3 20 | 21 | ssf = 0.0 22 | ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2]) 23 | 24 | threePoleSuperSmootherFilter(src, length) => 25 | arg = PI / length 26 | a1 = exp(-arg) 27 | b1 = 2 * a1 * cos(1.738 * arg) 28 | c1 = pow(a1, 2) 29 | 30 | coef2 = b1 + c1 31 | coef3 = -(c1 + b1 * c1) 32 | coef4 = pow(c1, 2) 33 | coef1 = 1 - coef2 - coef3 - coef4 34 | 35 | ssf = 0.0 36 | ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3]) 37 | 38 | zeros = src - nz(src[2]) 39 | 40 | // Ehlers Super Smoother Filter 41 | ssf = numberOfPoles == 2 42 | ? twoPoleSuperSmootherFilter((zeros + zeros[1]) / 2, ssfLength) 43 | : threePoleSuperSmootherFilter((zeros + zeros[1]) / 2, ssfLength) 44 | 45 | // Rescale filter in terms of Standard Deviations 46 | scaledFilter = stdev(ssf, length) != 0 47 | ? ssf / stdev(ssf, length) 48 | : 0 49 | 50 | alpha = abs(scaledFilter) * 5 / length 51 | 52 | edsma = 0.0 53 | edsma := alpha * src + (1 - alpha) * nz(edsma[1]) 54 | 55 | plot(edsma, title="EDSMA", linewidth=2, color=#6d1e7f, transp=0) 56 | -------------------------------------------------------------------------------- /movings/ehlers_distance_coefficient_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Distance Coefficient Filter script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Ehlers Distance Coefficient Filter", shorttitle="EDCF", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | src = input(title="Source", type=source, defval=hl2) 8 | 9 | srcSum = 0.0 10 | coefSum = 0.0 11 | 12 | for count = 0 to length - 1 13 | distance = 0.0 14 | 15 | for lookback = 1 to length - 1 16 | distance := distance + pow(src[count] - src[count + lookback], 2) 17 | 18 | srcSum := srcSum + distance * src[count] 19 | coefSum := coefSum + distance 20 | 21 | dcf = coefSum != 0 ? srcSum / coefSum : 0.0 22 | 23 | plot(dcf, title="EDCF", linewidth=2, color=#6d1e7f, transp=0) 24 | -------------------------------------------------------------------------------- /movings/ehlers_leading_indicator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Leading Indicator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ehlers Leading Indicator", shorttitle="ELI", overlay=true) 5 | 6 | alpha1 = input(title="Alpha 1", type=float, step=0.1, defval=0.25) 7 | alpha2 = input(title="Alpha 2", type=float, step=0.1, defval=0.33) 8 | src = input(title="Source", type=source, defval=hl2) 9 | 10 | lead = 0.0 11 | lead := 2 * src + (alpha1 - 2) * nz(src[1]) + (1 - alpha1) * nz(lead[1]) 12 | 13 | leadingIndicator = 0.0 14 | leadingIndicator := alpha2 * lead + (1 - alpha2) * nz(leadingIndicator[1]) 15 | 16 | plot(leadingIndicator, title="ELI", linewidth=2, color=#741b47, transp=0) 17 | -------------------------------------------------------------------------------- /movings/ehlers_modified_optimum_elliptic_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Ehlers Modified Optimum Elliptic Filter script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Ehlers Modified Optimum Elliptic Filter", shorttitle="MOEF", overlay=true) 5 | 6 | src = input(title="Source", type=source, defval=hl2) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=false) 8 | 9 | src1 = nz(src[1], src) 10 | src2 = nz(src[2], src1) 11 | src3 = nz(src[3], src2) 12 | 13 | moef = src 14 | moef := 0.13785 * (2 * src - src1) + 15 | 0.0007 * (2 * src1 - src2) + 16 | 0.13785 * (2 * src2 - src3) + 17 | 1.2103 * nz(moef[1], moef) - 18 | 0.4867 * nz(moef[2], moef) 19 | 20 | moefColor = highlightMovements ? (moef > moef[1] ? green : red) : #6d1e7f 21 | plot(moef, title="MOEF", linewidth=2, color=moefColor, transp=0) 22 | -------------------------------------------------------------------------------- /movings/ehlers_optimum_elliptic_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Ehlers Optimum Elliptic Filter script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Ehlers Optimum Elliptic Filter", shorttitle="OEF", overlay=true) 5 | 6 | src = input(title="Source", type=source, defval=hl2) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=false) 8 | 9 | oef = 0.0 10 | oef := 0.13785 * src + 0.0007 * nz(src[1]) + 0.13785 * nz(src[2]) + 1.2103 * nz(oef[1]) - 0.4867 * nz(oef[2]) 11 | 12 | oefColor = highlightMovements ? (oef > oef[1] ? green : red) : #6d1e7f 13 | plot(oef, title="OEF", linewidth=2, color=oefColor, transp=0) 14 | -------------------------------------------------------------------------------- /movings/ehlers_super_smoother_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Super Smoother Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ehlers Super Smoother Filter", shorttitle="ESSF", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=15) 7 | numberOfPoles = input(title="Number of Poles", type=integer, defval=2, options=[2, 3]) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | PI = 2 * asin(1) 11 | 12 | get2PoleSSF(src, length) => 13 | arg = sqrt(2) * PI / length 14 | a1 = exp(-arg) 15 | b1 = 2 * a1 * cos(arg) 16 | c2 = b1 17 | c3 = -pow(a1, 2) 18 | c1 = 1 - c2 - c3 19 | 20 | ssf = 0.0 21 | ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2]) 22 | 23 | get3PoleSSF(src, length) => 24 | arg = PI / length 25 | a1 = exp(-arg) 26 | b1 = 2 * a1 * cos(1.738 * arg) 27 | c1 = pow(a1, 2) 28 | 29 | coef2 = b1 + c1 30 | coef3 = -(c1 + b1 * c1) 31 | coef4 = pow(c1, 2) 32 | coef1 = 1 - coef2 - coef3 - coef4 33 | 34 | ssf = 0.0 35 | ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3]) 36 | 37 | essf = numberOfPoles == 2 38 | ? get2PoleSSF(src, length) 39 | : get3PoleSSF(src, length) 40 | 41 | plot(essf, title="ESSF", linewidth=2, color=#741b47, transp=0) 42 | -------------------------------------------------------------------------------- /movings/elastic_volume_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Elastic Volume Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Elastic Volume Weighted Moving Average", shorttitle="EVWMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | volumeSum = sum(volume, length) 11 | 12 | evwma = 0.0 13 | evwma := ((volumeSum - volume) * nz(evwma[1]) + volume * src) / volumeSum 14 | 15 | evwmaColor = highlight ? evwma > evwma[1] ? color.green : color.red : #6d1e7f 16 | plot(evwma, title="EVWMA", linewidth=2, color=evwmaColor, transp=0) 17 | -------------------------------------------------------------------------------- /movings/exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Exponential Moving Average", shorttitle="EMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | plot(ema(src, length), title="EMA", linewidth=2, color=#6d1e7f, transp=0) 10 | -------------------------------------------------------------------------------- /movings/fibonacci_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Fibonacci Weighted Moving Average script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Fibonacci Weighted Moving Average", shorttitle="FWMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | phi = (1 + sqrt(5)) / 2 10 | 11 | fiboWeight(i) => 12 | pow = pow(phi, i) 13 | (pow - pow(-1, i) / pow) / sqrt(5) 14 | 15 | fwma(src, length) => 16 | sum = 0.0 17 | weightSum = 0.0 18 | 19 | for i = 0 to length - 1 20 | weight = fiboWeight(length - i) 21 | sum := sum + nz(src[i]) * weight 22 | weightSum := weightSum + weight 23 | 24 | sum / weightSum 25 | 26 | plot(fwma(src, length), title="FWMA", linewidth=2, color=#741b47, transp=0) 27 | -------------------------------------------------------------------------------- /movings/finite_impulse_response_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Finite Impulse Response (FIR) Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Finite Impulse Response (FIR) Filter", shorttitle="FIRF", overlay=true) 5 | 6 | coef1 = input(title="1st Coefficient", type=input.float, step=0.1, defval=1) 7 | coef2 = input(title="2nd Coefficient", type=input.float, step=0.1, defval=3.5) 8 | coef3 = input(title="3rd Coefficient", type=input.float, step=0.1, defval=4.5) 9 | coef4 = input(title="4th Coefficient", type=input.float, step=0.1, defval=3) 10 | coef5 = input(title="5th Coefficient", type=input.float, step=0.1, defval=0.5) 11 | coef6 = input(title="6th Coefficient", type=input.float, step=0.1, defval=-0.5) 12 | coef7 = input(title="7th Coefficient", type=input.float, step=0.1, defval=-1.5) 13 | src = input(title="Source", type=input.source, defval=close) 14 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 15 | 16 | src1 = nz(src[1], src) 17 | src2 = nz(src[2], src1) 18 | src3 = nz(src[3], src2) 19 | src4 = nz(src[4], src3) 20 | src5 = nz(src[5], src4) 21 | src6 = nz(src[6], src5) 22 | 23 | coefSum = coef1 + coef2 + coef3 + coef4 + coef5 + coef6 + coef7 24 | 25 | firf = ( 26 | coef1 * src + 27 | coef2 * src1 + 28 | coef3 * src2 + 29 | coef4 * src3 + 30 | coef5 * src4 + 31 | coef6 * src5 + 32 | coef7 * src6 33 | ) / coefSum 34 | 35 | firfColor = highlight ? firf > firf[1] ? color.green : color.red : #6d1e7f 36 | plot(firf, title="FIRF", linewidth=2, color=firfColor, transp=0) 37 | -------------------------------------------------------------------------------- /movings/fractal_adaptive_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Fractal Adaptive Moving Average script may be freely distributed under the terms of GPL-3.0 license. 4 | study(title="Fractal Adaptive Moving Average", shorttitle="FRAMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | length2 = floor(length / 2) 11 | 12 | hh2 = highest(length2) 13 | ll2 = lowest(length2) 14 | 15 | N1 = (hh2 - ll2) / length2 16 | 17 | N2 = (hh2[length2] - ll2[length2]) / length2 18 | 19 | N3 = (highest(length) - lowest(length)) / length 20 | 21 | D = (log(N1 + N2) - log(N3)) / log(2) 22 | 23 | factor = exp(-4.6 * (D - 1)) 24 | 25 | frama = 0.0 26 | frama := factor * src + (1 - factor) * nz(frama[1]) 27 | 28 | framaColor = highlightMovements ? (frama > frama[1] ? green : red) : #6d1e7f 29 | plot(frama, title="FRAMA", linewidth=2, color=framaColor, transp=0) 30 | -------------------------------------------------------------------------------- /movings/gaussian_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Gaussian Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Gaussian Filter", shorttitle="GF", overlay=true) 5 | 6 | cyclePeriod = input(title="Cycle Period", type=input.integer, minval=1, defval=14) 7 | polesNumber = input(title="Number of Poles", type=input.integer, defval=4, options=[1, 2, 3, 4]) 8 | src = input(title="Source", type=input.source, defval=close) 9 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 10 | 11 | PI = 2 * asin(1) 12 | beta = (1 - cos(2 * PI / cyclePeriod)) / (pow(2, 1 / polesNumber) - 1) 13 | alpha = -beta + sqrt(pow(beta, 2) + 2 * beta) 14 | 15 | _gf(poles) => 16 | filter = 0.0 17 | filter1 = nz(filter[1], src) 18 | filter2 = nz(filter[2], filter1) 19 | filter3 = nz(filter[3], filter2) 20 | filter4 = nz(filter[4], filter3) 21 | 22 | if poles == 1 23 | filter := alpha * src + (1 - alpha) * filter1 24 | 25 | if poles == 2 26 | filter := 27 | pow(alpha, 2) * src + 28 | 2 * (1 - alpha) * filter1 - 29 | pow(1 - alpha, 2) * filter2 30 | 31 | if poles == 3 32 | filter := 33 | pow(alpha, 3) * src + 34 | 3 * (1 - alpha) * filter1 - 35 | 3 * pow(1 - alpha, 2) * filter2 + 36 | pow(1 - alpha, 3) * filter3 37 | 38 | if poles == 4 39 | filter := 40 | pow(alpha, 4) * src + 41 | 4 * (1 - alpha) * filter1 - 42 | 6 * pow(1 - alpha, 2) * filter2 + 43 | 4 * pow(1 - alpha, 3) * filter3 - 44 | pow(1 - alpha, 4) * filter4 45 | filter 46 | 47 | gf = _gf(polesNumber) 48 | gfColor = highlight ? gf > gf[1] ? color.green : color.red : #6d1e7f 49 | plot(gf, title="GF", linewidth=2, color=gfColor, transp=0) 50 | -------------------------------------------------------------------------------- /movings/hampel_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Hampel Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Hampel Filter", shorttitle="HF", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, minval=1, defval=14) 7 | scalingFactor = input(title="Scaling Factor", type=input.float, step=0.1, defval=3) 8 | src = input(title="Source", type=input.source, defval=close) 9 | 10 | _median(src, length) => 11 | percentile_nearest_rank(src, length, 50) 12 | 13 | sampleMedian = _median(src, length) 14 | 15 | // Median Absolute Deviation 16 | mad = _median(abs(src - sampleMedian), length) 17 | 18 | hf = abs(src - sampleMedian) <= scalingFactor * mad 19 | ? src 20 | : sampleMedian 21 | 22 | // Plot EMA of the filtered samples 23 | plot(ema(hf, length), title="HF", linewidth=2, color=#6d1e7f, transp=0) 24 | -------------------------------------------------------------------------------- /movings/henderson_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Henderson Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Henderson Weighted Moving Average", shorttitle="HWMA", overlay=true) 5 | 6 | termsNumber = input(title="Terms Number", type=input.integer, minval=1, defval=7) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | // The general form of the weights of the (2m + 1)-term Henderson Weighted Moving Average 11 | _weight(m, j) => 12 | powj2 = pow(j, 2) 13 | powm22 = pow(m + 2, 2) 14 | 15 | numerator = 16 | 315 * (pow(m + 1, 2) - powj2) * 17 | (powm22 - powj2) * 18 | (pow(m + 3, 2) - powj2) * 19 | (3 * powm22 - 11 * powj2 - 16) 20 | denominator = 21 | 8 * (m + 2) * (powm22 - 1) * 22 | (4 * powm22 - 1) * 23 | (4 * powm22 - 9) * 24 | (4 * powm22 - 25) 25 | out = denominator != 0 ? numerator / denominator : 0 26 | out 27 | 28 | sum = 0.0 29 | weightSum = 0.0 30 | 31 | termMult = floor((termsNumber - 1) / 2) 32 | 33 | for i = 0 to termsNumber - 1 34 | weight = _weight(termMult, i - termMult) 35 | sum := sum + nz(src[i]) * weight 36 | weightSum := weightSum + weight 37 | 38 | hwma = sum / weightSum 39 | 40 | hwmaColor = highlight ? hwma > hwma[1] ? color.green : color.red : #6d1e7f 41 | plot(hwma, title="HWMA", linewidth=2, color=hwmaColor, transp=0) 42 | -------------------------------------------------------------------------------- /movings/holt_exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Holt Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Holt Exponential Moving Average", shorttitle="HEMA", overlay=true) 5 | 6 | alphaLength = input(title="Alpha Length", type=input.integer, defval=20, minval=1) 7 | gammaLength = input(title="Gamma Length", type=input.integer, defval=20, minval=1) 8 | src = input(title="Source", type=input.source, defval=close) 9 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 10 | 11 | alpha = 2 / (alphaLength + 1) 12 | gamma = 2 / (gammaLength + 1) 13 | 14 | b = 0.0 15 | hema = 0.0 16 | 17 | hema := (1 - alpha) * (nz(hema[1]) + nz(b[1], src)) + alpha * src 18 | b := (1 - gamma) * nz(b[1]) + gamma * (hema - nz(hema[1])) 19 | 20 | hemaColor = highlight ? hema > hema[1] ? color.green : color.red : #6d1e7f 21 | plot(hema, title="HEMA", linewidth=2, color=hemaColor, transp=0) 22 | -------------------------------------------------------------------------------- /movings/hull_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Hull Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Hull Moving Average", shorttitle="HMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14, minval=1) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | hma(src, length) => 10 | wma(2 * wma(src, length / 2) - wma(src, length), round(sqrt(length))) 11 | 12 | plot(hma(src, length), title="HMA", linewidth=2, color=#6d1e7f, transp=0) 13 | -------------------------------------------------------------------------------- /movings/infinite_impulse_response_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Infinite Impulse Response (IIR) Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Infinite Impulse Response (IIR) Filter", shorttitle="IIRF", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14, minval=2) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | iirfAlpha = 2 / (length + 1) 11 | iirfLag = round(1 / iirfAlpha - 1) 12 | 13 | iirf = 0.0 14 | iirf := iirfAlpha * (src + change(src, iirfLag)) + (1 - iirfAlpha) * nz(iirf[1]) 15 | 16 | iirfColor = highlight ? iirf > iirf[1] ? color.green : color.red : #6d1e7f 17 | plot(iirf, title="IIRF", linewidth=2, color=iirfColor, transp=0) 18 | -------------------------------------------------------------------------------- /movings/inverse_distance_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Inverse Distance Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Inverse Distance Weighted Moving Average", shorttitle="IDWMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | sum = 0.0 11 | weightSum = 0.0 12 | 13 | calcWeight(src, length, i) => 14 | distanceSum = 0.0 15 | for j = 0 to length - 1 16 | distanceSum := distanceSum + abs(nz(src[i]) - nz(src[j])) 17 | distanceSum 18 | 19 | for i = 0 to length - 1 20 | weight = calcWeight(src, length, i) 21 | sum := sum + nz(src[i]) * weight 22 | weightSum := weightSum + weight 23 | 24 | idwma = sum / weightSum 25 | 26 | idwmaColor = highlightMovements ? (idwma > idwma[1] ? green : red) : #6d1e7f 27 | plot(idwma, title="IDWMA", linewidth=2, color=idwmaColor, transp=0) 28 | -------------------------------------------------------------------------------- /movings/jurik_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2007-present Jurik Research and Consulting. All rights reserved. 3 | // Copyright (c) 2018-present, Alex Orekhov (everget) 4 | // Jurik Moving Average script may be freely distributed under the terms of GPL-3.0 license. 5 | study("Jurik Moving Average", shorttitle="JMA", overlay=true) 6 | 7 | length = input(title="Length", type=integer, defval=7) 8 | phase = input(title="Phase", type=integer, defval=50) 9 | power = input(title="Power", type=integer, defval=2) 10 | src = input(title="Source", type=source, defval=close) 11 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 12 | 13 | phaseRatio = phase < -100 ? 0.5 : phase > 100 ? 2.5 : phase / 100 + 1.5 14 | 15 | beta = 0.45 * (length - 1) / (0.45 * (length - 1) + 2) 16 | alpha = pow(beta, power) 17 | 18 | jma = 0.0 19 | 20 | e0 = 0.0 21 | e0 := (1 - alpha) * src + alpha * nz(e0[1]) 22 | 23 | e1 = 0.0 24 | e1 := (src - e0) * (1 - beta) + beta * nz(e1[1]) 25 | 26 | e2 = 0.0 27 | e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1]) 28 | 29 | jma := e2 + nz(jma[1]) 30 | 31 | jmaColor = highlightMovements ? (jma > jma[1] ? green : red) : #6d1e7f 32 | plot(jma, title="JMA", linewidth=2, color=jmaColor, transp=0) 33 | -------------------------------------------------------------------------------- /movings/kaufman_adaptive_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Kaufman Adaptive Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Kaufman Adaptive Moving Average", shorttitle="KAMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | fastLength = input(title="Fast EMA Length", type=input.integer, defval=2) 8 | slowLength = input(title="Slow EMA Length", type=input.integer, defval=30) 9 | src = input(title="Source", type=input.source, defval=close) 10 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 11 | 12 | mom = abs(change(src, length)) 13 | volatility = sum(abs(change(src)), length) 14 | 15 | // Efficiency Ratio 16 | er = volatility != 0 ? mom / volatility : 0 17 | 18 | fastAlpha = 2 / (fastLength + 1) 19 | slowAlpha = 2 / (slowLength + 1) 20 | 21 | alpha = pow(er * (fastAlpha - slowAlpha) + slowAlpha, 2) 22 | 23 | kama = 0.0 24 | kama := alpha * src + (1 - alpha) * nz(kama[1], src) 25 | 26 | kamaColor = highlight ? kama > kama[1] ? color.green : color.red : #6d1e7f 27 | plot(kama, title="KAMA", linewidth=2, color=kamaColor, transp=0) 28 | -------------------------------------------------------------------------------- /movings/laguerre_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Laguerre Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Laguerre Filter", shorttitle="LF", overlay=true) 5 | 6 | alpha = input(title="Alpha", type=input.float, minval=0, maxval=1, step=0.1, defval=0.7) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | L0 = 0.0 11 | L0 := alpha * src + (1 - alpha) * nz(L0[1]) 12 | 13 | L1 = 0.0 14 | L1 := -(1 - alpha) * L0 + nz(L0[1]) + (1 - alpha) * nz(L1[1]) 15 | 16 | L2 = 0.0 17 | L2 := -(1 - alpha) * L1 + nz(L1[1]) + (1 - alpha) * nz(L2[1]) 18 | 19 | L3 = 0.0 20 | L3 := -(1 - alpha) * L2 + nz(L2[1]) + (1 - alpha) * nz(L3[1]) 21 | 22 | lf = (L0 + 2 * L1 + 2 * L2 + L3) / 6 23 | 24 | lfColor = highlight ? lf > lf[1] ? color.green : color.red : #6d1e7f 25 | plot(lf, title="LF", linewidth=2, color=lfColor, transp=0) 26 | -------------------------------------------------------------------------------- /movings/least_squares_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Least Squares Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Least Squares Moving Average", shorttitle="LSMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | offset = input(title="Offset", type=integer, defval=0) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | plot(linreg(src, length, offset), title="LSMA", linewidth=2, color=#6d1e7f, transp=0) 11 | -------------------------------------------------------------------------------- /movings/leo_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Leo Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Leo Moving Average", shorttitle="LMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | lma = 2 * wma(src, length) - sma(src, length) 11 | 12 | lmaColor = highlightMovements ? (lma > lma[1] ? green : red) : #6d1e7f 13 | 14 | plot(lma, title="LMA", linewidth=2, color=lmaColor, transp=0) 15 | -------------------------------------------------------------------------------- /movings/linear_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Linear Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Linear Weighted Moving Average", shorttitle="LWMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | lwma(src, length) => 10 | weightSum = 0.0 11 | sum = 0.0 12 | 13 | for i = 0 to length - 1 14 | weight = length - i 15 | weightSum := weightSum + weight 16 | sum := sum + nz(src[i]) * weight 17 | 18 | sum / weightSum 19 | 20 | plot(lwma(src, length), title="LWMA", linewidth=2, color=#e69138, transp=0) 21 | -------------------------------------------------------------------------------- /movings/mcginley_dynamic.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // McGinley Dynamic script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("McGinley Dynamic", shorttitle="MD", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | k = input(title="K", type=float, step=0.1, defval=0.6) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | md(src, length, k) => 11 | md = 0.0 12 | md := na(md[1]) ? src : md[1] + (src - md[1]) / (k * length * pow(src / md[1], 4)) 13 | 14 | plot(md(src, length, k), title="MD", linewidth=2, color=#6d1e7f, transp=0) 15 | -------------------------------------------------------------------------------- /movings/mcnicholl_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 1998-present, Dennis McNicholl 3 | // Copyright (c) 2019-present, Alex Orekhov (everget) 4 | // McNicholl Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 5 | study("McNicholl Moving Average", shorttitle="MNMA", overlay=true) 6 | 7 | length = input(title="Length", type=integer, defval=20) 8 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | alpha = 2 / (length + 1) 12 | 13 | ema1 = ema(src, length) 14 | ema2 = ema(ema1, length) 15 | 16 | mnma = ((2 - alpha) * ema1 - ema2) / (1 - alpha) 17 | 18 | mnmaColor = highlightMovements ? (mnma > mnma[1] ? green : red) : #6d1e7f 19 | plot(mnma, title="MNMA", linewidth=2, color=mnmaColor, transp=0) 20 | -------------------------------------------------------------------------------- /movings/middle_high_low_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Middle-High-Low Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Middle-High-Low Moving Average", shorttitle="MHLMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | mhlRange = input(title="High-Low Range", type=integer, defval=10) 8 | maType = input(title="MA Type", defval="EMA", options=["EMA", "SMA"]) 9 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 10 | 11 | mhl = avg(highest(mhlRange), lowest(mhlRange)) 12 | mhlma = maType == "EMA" ? ema(mhl, length) : sma(mhl, length) 13 | 14 | mhlmaColor = highlightMovements ? (mhlma > mhlma[1] ? green : red) : #6d1e7f 15 | 16 | plot(mhlma, title="MHLMA", linewidth=2, color=mhlmaColor, transp=0) 17 | -------------------------------------------------------------------------------- /movings/moving_geometric_mean.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Moving Geometric Mean script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Moving Geometric Mean", shorttitle="MGM", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | mgm(src, length) => 10 | exp(sum(log(src), length) / length) 11 | 12 | plot(mgm(src, length), title="MGM", linewidth=2, color=#6d1e7f, transp=0) 13 | -------------------------------------------------------------------------------- /movings/moving_harmonic_mean.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Moving Harmonic Mean script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Moving Harmonic Mean", shorttitle="MHM", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14, minval=1) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | mhm(src, length) => 10 | sum = 0.0 11 | 12 | for i = 0 to length - 1 13 | sum := sum + 1 / (na(src[i]) ? 1 : src[i]) 14 | 15 | length / sum 16 | 17 | plot(mhm(src, length), title="MHM", linewidth=2, color=#6d1e7f, transp=0) 18 | -------------------------------------------------------------------------------- /movings/moving_median.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Moving Median script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Moving Median", shorttitle="MM", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 8 | src = input(title="Source", type=input.source, defval=close) 9 | 10 | median = percentile_nearest_rank(src, length, 50) 11 | 12 | medianColor = highlight ? median > median[1] ? color.green : color.red : #6d1e7f 13 | plot(median, title="MM", linewidth=2, color=medianColor, transp=0) 14 | -------------------------------------------------------------------------------- /movings/moving_quadratic_mean.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Moving Quadratic Mean (RMS) script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Moving Quadratic Mean (RMS)", shorttitle="RMS", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | rms(src, length) => 10 | sqrt(sum(src * src, length) / length) 11 | 12 | plot(rms(src, length), title="RMS", linewidth=2, color=#6d1e7f, transp=0) 13 | -------------------------------------------------------------------------------- /movings/multiple_hull_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Multiple Hull Moving Average script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Multiple Hull Moving Average", shorttitle="HMA", overlay=true) 5 | 6 | len1 = input(title="1st Length", type=integer, defval=20) 7 | src1 = input(title="1st Source", type=source, defval=close) 8 | hma1 = wma(2 * wma(src1, len1 / 2) - wma(src1, len1), round(sqrt(len1))) 9 | plot(hma1, title="1", linewidth=2, color=#85200c, transp=0) 10 | 11 | len2 = input(title="2nd Length", type=integer, defval=50) 12 | src2 = input(title="2nd Source", type=source, defval=close) 13 | hma2 = wma(2 * wma(src2, len2 / 2) - wma(src2, len2), round(sqrt(len2))) 14 | plot(hma2, title="2", linewidth=2, color=#1155cc, transp=0) 15 | 16 | len3 = input(title="3rd Length", type=integer, defval=100) 17 | src3 = input(title="3rd Source", type=source, defval=close) 18 | hma3 = wma(2 * wma(src3, len3 / 2) - wma(src3, len3), round(sqrt(len3))) 19 | plot(hma3, title="3", linewidth=2, color=#f1c232, transp=0) 20 | -------------------------------------------------------------------------------- /movings/parabolic_sar.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Parabolic SAR script may be freely distributed under the terms of the GPL-3.0 license. 4 | study(title="Parabolic SAR", shorttitle="PSAR", overlay=true) 5 | 6 | start = input(0.02) 7 | increment = input(0.02) 8 | maximum = input(0.2) 9 | 10 | psar = sar(start, increment, maximum) 11 | 12 | plot(psar, style=cross, color=blue) 13 | -------------------------------------------------------------------------------- /movings/parabolic_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Parabolic Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Parabolic Weighted Moving Average", shorttitle="PWMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | power = input(title="Power", type=integer, minval=0, defval=2) 8 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | sum = 0.0 12 | weightSum = 0.0 13 | 14 | for i = 0 to length - 1 15 | weight = pow(length - i, power) 16 | sum := sum + nz(src[i]) * weight 17 | weightSum := weightSum + weight 18 | 19 | pwma = sum / weightSum 20 | 21 | pwmaColor = highlightMovements ? (pwma > pwma[1] ? green : red) : #6d1e7f 22 | plot(pwma, title="PWMA", linewidth=2, color=pwmaColor, transp=0) 23 | -------------------------------------------------------------------------------- /movings/pentuple_exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2010-present, Bruno Pio 3 | // Copyright (c) 2019-present, Alex Orekhov (everget) 4 | // Pentuple Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 5 | study("Pentuple Exponential Moving Average", shorttitle="PEMA", overlay=true) 6 | 7 | length = input(title="Length", type=integer, defval=20) 8 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | ema1 = ema(src, length) 12 | ema2 = ema(ema1, length) 13 | ema3 = ema(ema2, length) 14 | ema4 = ema(ema3, length) 15 | ema5 = ema(ema4, length) 16 | ema6 = ema(ema5, length) 17 | ema7 = ema(ema6, length) 18 | ema8 = ema(ema7, length) 19 | 20 | pema = 8 * ema1 - 28 * ema2 + 56 * ema3 - 70 * ema4 + 56 * ema5 - 28 * ema6 + 8 * ema7 - ema8 21 | 22 | pemaColor = highlightMovements ? (pema > pema[1] ? green : red) : #6d1e7f 23 | plot(pema, title="PEMA", linewidth=2, color=pemaColor, transp=0) 24 | -------------------------------------------------------------------------------- /movings/quadruple_exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2010-present, Bruno Pio 3 | // Copyright (c) 2019-present, Alex Orekhov (everget) 4 | // Quadruple Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 5 | study("Quadruple Exponential Moving Average", shorttitle="QEMA", overlay=true) 6 | 7 | length = input(title="Length", type=integer, defval=20) 8 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | ema1 = ema(src, length) 12 | ema2 = ema(ema1, length) 13 | ema3 = ema(ema2, length) 14 | ema4 = ema(ema3, length) 15 | ema5 = ema(ema4, length) 16 | 17 | qema = 5 * ema1 - 10 * ema2 + 10 * ema3 - 5 * ema4 + ema5 18 | 19 | qemaColor = highlightMovements ? (qema > qema[1] ? green : red) : #6d1e7f 20 | plot(qema, title="QEMA", linewidth=2, color=qemaColor, transp=0) 21 | -------------------------------------------------------------------------------- /movings/quick_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2008-present, John McCormick 3 | // Copyright (c) 2019-present, Alex Orekhov (everget) 4 | // Quick Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 5 | study("Quick Moving Average", shorttitle="QMA", overlay=true) 6 | 7 | length = input(title="Length", type=integer, minval=1, defval=14) 8 | src = input(title="Source", type=source, defval=close) 9 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=false) 10 | 11 | peak = length / 3 12 | num = 0.0 13 | denom = 0.0 14 | 15 | for i = 1 to length + 1 16 | mult = 0.0 17 | if i <= peak 18 | mult := i / peak 19 | else 20 | mult := (length + 1 - i) / (length + 1 - peak) 21 | num := num + src[i - 1] * mult 22 | denom := denom + mult 23 | 24 | qma = denom != 0.0 ? num / denom : src 25 | 26 | qmaColor = highlightMovements ? (qma > qma[1] ? green : red) : #6d1e7f 27 | plot(qma, title="QMA", linewidth=2, color=qmaColor, transp=0) 28 | -------------------------------------------------------------------------------- /movings/recursive_median_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Recursive Median Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Recursive Median Filter", shorttitle="RMF", overlay=true) 5 | 6 | medianLength = input(title="Median Length", type=input.integer, defval=5, minval=1) 7 | lowpassLength = input(title="Lowpass Length", type=input.integer, defval=12, minval=1) 8 | src = input(title="Source", type=input.source, defval=close) 9 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 10 | 11 | _median(src, length) => 12 | percentile_nearest_rank(src, length, 50) 13 | 14 | PI = 2 * asin(1) 15 | 16 | alphaArg = 2 * PI / lowpassLength 17 | cos = cos(alphaArg) 18 | 19 | alpha = 0.0 20 | alpha := cos != 0 ? (cos + sin(alphaArg) - 1) / cos : nz(alpha[1]) 21 | 22 | rmf = 0.0 23 | rmf := alpha * _median(src, medianLength) + (1 - alpha) * nz(rmf[1]) 24 | 25 | rmfColor = highlight ? rmf > rmf[1] ? color.green : color.red : #6d1e7f 26 | plot(rmf, title="RMF", linewidth=2, color=rmfColor, transp=0) 27 | -------------------------------------------------------------------------------- /movings/recursive_median_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Recursive Median Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Recursive Median Filter", shorttitle="RMF", overlay=true) 5 | 6 | medianLength = input(title="Length", type=integer, minval=1, defval=5) 7 | lowpassLength = input(title="Lowpass Length", type=integer, minval=1, defval=12) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | median(src, length) => 11 | percentile_nearest_rank(src, length, 50) 12 | 13 | PI = 2 * asin(1) 14 | 15 | alphaArg = 2 * PI / lowpassLength 16 | 17 | alpha = 0.0 18 | alpha := cos(alphaArg) != 0 ? (cos(alphaArg) + sin(alphaArg) - 1) / cos(alphaArg) : nz(alpha[1]) 19 | 20 | rmf = 0.0 21 | rmf := alpha * median(src, medianLength) + (1 - alpha) * nz(rmf[1]) 22 | 23 | plot(rmf, title="RMF", linewidth=2, color=#6d1e7f, transp=0) 24 | -------------------------------------------------------------------------------- /movings/recursive_moving_trend_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Recursive Moving Trend Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Recursive Moving Trend Average", shorttitle="RMTA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14, minval=1) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | alpha = 2 / (length + 1) 11 | 12 | b = 0.0 13 | b := (1 - alpha) * nz(b[1], src) + src 14 | 15 | rmta = 0.0 16 | rmta := (1 - alpha) * nz(rmta[1], src) + alpha * (src + b - nz(b[1])) 17 | 18 | rmtaColor = highlight ? rmta > rmta[1] ? color.green : color.red : #6d1e7f 19 | plot(rmta, title="RMTA", linewidth=2, color=rmtaColor, transp=0) 20 | -------------------------------------------------------------------------------- /movings/regularized_exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Regularized Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Regularized Exponential Moving Average", shorttitle="REMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | lambda = input(title="Regularization Constant", type=input.float, minval=0, defval=0.5) 8 | src = input(title="Source", type=input.source, defval=close) 9 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 10 | 11 | alpha = 2 / (length + 1) 12 | 13 | rema = 0.0 14 | rema1 = nz(rema[1], src) 15 | rema2 = nz(rema[2], rema1) 16 | 17 | rema := (rema1 + alpha * (src - rema1) + lambda * (2 * rema1 - rema2)) / (lambda + 1) 18 | 19 | remaColor = highlight ? rema > rema[1] ? color.green : color.red : #6d1e7f 20 | plot(rema, title="REMA", linewidth=2, color=remaColor, transp=0) 21 | -------------------------------------------------------------------------------- /movings/self_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Self-Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Self-Weighted Moving Average", shorttitle="SEWMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=false) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | sum = 0.0 11 | weightSum = 0.0 12 | 13 | for i = 0 to length - 1 14 | weight = src[length + i] 15 | weightSum := weightSum + weight 16 | sum := sum + weight * src[i] 17 | 18 | sewma = sum / weightSum 19 | 20 | sewmaColor = highlightMovements ? (sewma > sewma[1] ? green : red) : #6d1e7f 21 | plot(sewma, title="SEWMA", linewidth=2, color=sewmaColor, transp=0) 22 | -------------------------------------------------------------------------------- /movings/sharp_modified_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Sharp Modified Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Sharp Modified Moving Average", shorttitle="SHMMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | factor = 0.0 11 | slope = 0.0 12 | 13 | for i = 1 to length 14 | factor := 1 + 2 * (i - 1) 15 | slope := slope + src[i - 1] * (length - factor) / 2 16 | 17 | shmma = sma(src, length) + 6 * slope / ((length + 1) * length) 18 | 19 | shmmaColor = highlight ? shmma > shmma[1] ? color.green : color.red : #6d1e7f 20 | plot(shmma, title="SHMMA", linewidth=2, color=shmmaColor, transp=0) 21 | -------------------------------------------------------------------------------- /movings/simple_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Simple Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Simple Moving Average", shorttitle="SMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | plot(sma(src, length), title="SMA", linewidth=2, color=#6d1e7f, transp=0) 10 | -------------------------------------------------------------------------------- /movings/sine_weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Sine Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Sine Weighted Moving Average", shorttitle="SWMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | PI = 2 * asin(1) 11 | sum = 0.0 12 | weightSum = 0.0 13 | 14 | for i = 0 to length - 1 15 | weight = sin((i + 1) * PI / (length + 1)) 16 | sum := sum + nz(src[i]) * weight 17 | weightSum := weightSum + weight 18 | weightSum 19 | 20 | swma = sum / weightSum 21 | 22 | swmaColor = highlight ? swma > swma[1] ? color.green : color.red : #6d1e7f 23 | plot(swma, title="SWMA", linewidth=2, color=swmaColor, transp=0) 24 | -------------------------------------------------------------------------------- /movings/spencer_15_point_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Spencer 15-Point Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Spencer 15-Point Moving Average", shorttitle="SPMA 15", overlay=true) 5 | 6 | src = input(title="Source", type=input.source, defval=close) 7 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 8 | 9 | _weight(i) => 10 | weight = 0.0 11 | 12 | if i == 0 13 | weight := -3 14 | if i == 1 15 | weight := -6 16 | if i == 2 17 | weight := -5 18 | if i == 3 19 | weight := 3 20 | if i == 4 21 | weight := 21 22 | if i == 5 23 | weight := 46 24 | if i == 6 25 | weight := 67 26 | if i == 7 27 | weight := 74 28 | if i == 8 29 | weight := 67 30 | if i == 9 31 | weight := 46 32 | if i == 10 33 | weight := 21 34 | if i == 11 35 | weight := 3 36 | if i == 12 37 | weight := -5 38 | if i == 13 39 | weight := -6 40 | if i == 14 41 | weight := -3 42 | weight 43 | 44 | sum = 0.0 45 | weightSum = 0.0 46 | 47 | for i = 0 to 14 48 | weight = _weight(i) 49 | sum := sum + nz(src[i]) * weight 50 | weightSum := weightSum + weight 51 | 52 | spma15 = sum / weightSum 53 | 54 | spma15Color = highlight ? spma15 > spma15[1] ? color.green : color.red : #6d1e7f 55 | plot(spma15, title="SPMA 15", linewidth=2, color=spma15Color, transp=0) 56 | -------------------------------------------------------------------------------- /movings/spencer_21_point_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Spencer 21-Point Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Spencer 21-Point Moving Average", shorttitle="SPMA 21", overlay=true) 5 | 6 | src = input(title="Source", type=input.source, defval=close) 7 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 8 | 9 | _weight(i) => 10 | weight = 0.0 11 | 12 | if i == 0 13 | weight := -1 14 | if i == 1 15 | weight := -3 16 | if i == 2 17 | weight := -5 18 | if i == 3 19 | weight := -5 20 | if i == 4 21 | weight := -2 22 | if i == 5 23 | weight := 6 24 | if i == 6 25 | weight := 18 26 | if i == 7 27 | weight := 33 28 | if i == 8 29 | weight := 47 30 | if i == 9 31 | weight := 57 32 | if i == 10 33 | weight := 60 34 | if i == 11 35 | weight := 57 36 | if i == 12 37 | weight := 47 38 | if i == 13 39 | weight := 33 40 | if i == 14 41 | weight := 18 42 | if i == 15 43 | weight := 6 44 | if i == 16 45 | weight := -2 46 | if i == 17 47 | weight := -5 48 | if i == 18 49 | weight := -5 50 | if i == 19 51 | weight := -3 52 | if i == 20 53 | weight := -1 54 | weight 55 | 56 | sum = 0.0 57 | weightSum = 0.0 58 | 59 | for i = 0 to 20 60 | weight = _weight(i) 61 | sum := sum + nz(src[i]) * weight 62 | weightSum := weightSum + weight 63 | 64 | spma21 = sum / weightSum 65 | 66 | spma21Color = highlight ? spma21 > spma21[1] ? color.green : color.red : #6d1e7f 67 | plot(spma21, title="SPMA 21", linewidth=2, color=spma21Color, transp=0) 68 | -------------------------------------------------------------------------------- /movings/t3_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // T3 Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("T3 Moving Average", shorttitle="T3", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=5) 7 | factor = input(title="Factor", type=input.float, minval=0, maxval=1, defval=0.7) 8 | src = input(title="Source", type=input.source, defval=close) 9 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 10 | 11 | _gd(src, length) => 12 | ema(src, length) * (1 + factor) - ema(ema(src, length), length) * factor 13 | 14 | t3 = _gd(_gd(_gd(src, length), length), length) 15 | 16 | t3Color = highlight ? t3 > t3[1] ? color.green : color.red : #6d1e7f 17 | plot(t3, title="T3", linewidth=2, color=t3Color, transp=0) 18 | -------------------------------------------------------------------------------- /movings/triangular_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Triangular Moving Average script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Triangular Moving Average", shorttitle="TMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=20) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | tma = sma(sma(src, ceil(length / 2)), floor(length / 2) + 1) 11 | tmaColor = highlightMovements ? (tma > tma[1] ? green : red) : #6d1e7f 12 | 13 | plot(tma, title="TMA", linewidth=2, color=tmaColor, transp=0) 14 | -------------------------------------------------------------------------------- /movings/trimean.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Trimean script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Trimean", shorttitle="Trimean", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, minval=1, defval=14) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | q1 = percentile_nearest_rank(src, length, 25) 11 | median = percentile_nearest_rank(src, length, 50) 12 | q3 = percentile_nearest_rank(src, length, 75) 13 | 14 | trimean = (q1 + 2 * median + q3) / 4 15 | 16 | trimeanColor = highlight ? trimean > trimean[1] ? color.green : color.red : #6d1e7f 17 | plot(trimean, title="Trimean", linewidth=2, color=trimeanColor, transp=0) 18 | -------------------------------------------------------------------------------- /movings/vidya_variable_index_dynamic_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Variable Index Dynamic Average script may be freely distributed under the terms of GPL-3.0 license. 4 | study(title="Variable Index Dynamic Average", shorttitle="VIDYA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | // Chande Momentum Oscillator 11 | getCMO(src, length) => 12 | mom = change(src) 13 | upSum = sum(max(mom, 0), length) 14 | downSum = sum(-min(mom, 0), length) 15 | out = (upSum - downSum) / (upSum + downSum) 16 | out 17 | 18 | cmo = abs(getCMO(src, length)) 19 | 20 | alpha = 2 / (length + 1) 21 | 22 | vidya = 0.0 23 | vidya := src * alpha * cmo + nz(vidya[1]) * (1 - alpha * cmo) 24 | 25 | vidyaColor = highlightMovements ? (vidya > vidya[1] ? green : red) : #6d1e7f 26 | plot(vidya, title="VIDYA", linewidth=2, color=vidyaColor, transp=0) 27 | -------------------------------------------------------------------------------- /movings/weighted_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Weighted Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Weighted Moving Average", shorttitle="WMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | plot(wma(src, length), title="WMA", linewidth=2, color=#6d1e7f, transp=0) 10 | -------------------------------------------------------------------------------- /movings/wilder_modified_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Wilder Modified Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Wilder Modified Moving Average", shorttitle="WMMA", overlay=true) 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | plot(rma(src, length), title="WMMA", linewidth=2, color=#6d1e7f, transp=0) 10 | -------------------------------------------------------------------------------- /movings/zero_lag_exponential_moving_average.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Zero Lag Exponential Moving Average script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Zero Lag Exponential Moving Average", shorttitle="ZLEMA", overlay=true) 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | src = input(title="Source", type=input.source, defval=close) 8 | highlight = input(title="Highlight ?", type=input.bool, defval=true) 9 | 10 | lag = floor((length - 1) / 2) 11 | zlema = ema(src + (src - src[lag]), length) 12 | 13 | zlemaColor = highlight ? zlema > zlema[1] ? color.green : color.red : #6d1e7f 14 | plot(zlema, title="ZLEMA", linewidth=2, color=zlemaColor, transp=0) 15 | -------------------------------------------------------------------------------- /oscillators/accelerator_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Accelerator Oscillator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Accelerator Oscillator", shorttitle="AC") 5 | 6 | fastLength = input(title="Fast Length", type=integer, defval=5) 7 | slowLength = input(title="Slow Length", type=integer, defval=34) 8 | smoothLength = input(title="Smoothing Length", type=integer, defval=5) 9 | 10 | ao = sma(hl2, fastLength) - sma(hl2, slowLength) 11 | 12 | ac = ao - sma(ao, smoothLength) 13 | 14 | acColor = ac >= 0 ? (ac[1] < ac ? #26A69A : #B2DFDB) : (ac[1] < ac ? #FFCDD2 : #EF5350) 15 | plot(ac, title="AC", style=columns, color=acColor, transp=0) 16 | -------------------------------------------------------------------------------- /oscillators/accumulative_swing_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2017-present, Alex Orekhov (everget) 3 | // Accumulative Swing Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Accumulative Swing Index", shorttitle="ASI") 5 | 6 | limit = input(title="Limit Move Value", type=float, defval=10000) 7 | 8 | // Swing Index 9 | getSI(limit) => 10 | H_C1 = abs(high - close[1]) 11 | L_C1 = abs(low - close[1]) 12 | H_L = abs(high - low) 13 | C1_O1 = abs(close[1] - open[1]) 14 | K = max(H_C1, L_C1) 15 | R = iff(H_C1 >= max(L_C1, H_L), H_C1 - 0.5 * L_C1 + 0.25 * C1_O1, iff(L_C1 >= max(H_C1, H_L), L_C1 - 0.5 * H_C1 + 0.25 * C1_O1, H_L + 0.25 * C1_O1)) 16 | result = 50 * ((close - close[1] + 0.5 * (close - open) + 0.25 * (close[1] - open[1])) / R) * K / limit 17 | result 18 | 19 | // Accumulative Swing Index 20 | asi = cum(getSI(limit)) 21 | 22 | asiColor = asi >= asi[1] ? #0ebb23 : red 23 | 24 | plot(asi, title="ASI", color=asiColor, transp=0) -------------------------------------------------------------------------------- /oscillators/asymmetrical_rsi.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Asymmetrical RSI script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Asymmetrical RSI", shorttitle="ARSI") 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | obLevel = input(title="Overbought Level", type=input.integer, defval=70) 8 | osLevel = input(title="Oversold Level", type=input.integer, defval=30) 9 | src = input(title="Source", type=input.source, defval=close) 10 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=input.bool, defval=true) 11 | 12 | roc = roc(src, 1) 13 | 14 | upCount = sum(roc >= 0 ? 1 : 0, length) 15 | upAlpha = 1 / upCount 16 | 17 | upSum = 0.0 18 | upSum := upAlpha * (roc >= 0 ? roc : 0) + (1 - upAlpha) * nz(upSum[1], upSum) 19 | 20 | downCount = length - upCount 21 | downAlpha = 1 / downCount 22 | 23 | downSum = 0.0 24 | downSum := downAlpha * (roc >= 0 ? 0 : abs(roc)) + (1 - downAlpha) * nz(downSum[1], downSum) 25 | 26 | arsi = fixnan(100 * upSum / (upSum + downSum)) 27 | 28 | arsiColor = arsi > obLevel ? #0ebb23 : arsi < osLevel ? #ff0000 : #f4b77d 29 | plot(arsi, title="ARSI", linewidth=2, color=arsiColor, transp=0) 30 | 31 | transparent = color.new(color.white, 100) 32 | 33 | maxLevelPlot = hline(100, title="Max Level", linestyle=hline.style_dotted, color=transparent) 34 | obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=hline.style_dotted) 35 | hline(50, title="Middle Level", linestyle=hline.style_dotted) 36 | osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=hline.style_dotted) 37 | minLevelPlot = hline(0, title="Min Level", linestyle=hline.style_dotted, color=transparent) 38 | 39 | fill(obLevelPlot, osLevelPlot, color=color.purple, transp=95) 40 | 41 | obFillColor = arsi > obLevel and highlightBreakouts ? color.green : transparent 42 | osFillColor = arsi < osLevel and highlightBreakouts ? color.red : transparent 43 | 44 | fill(maxLevelPlot, obLevelPlot, color=obFillColor, transp=90) 45 | fill(minLevelPlot, osLevelPlot, color=osFillColor, transp=90) 46 | -------------------------------------------------------------------------------- /oscillators/awesome_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Awesome Oscillator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Awesome Oscillator", shorttitle="AO") 5 | 6 | fastLength = input(title="Fast Length", type=integer, defval=5) 7 | slowLength = input(title="Slow Length", type=integer, defval=34) 8 | 9 | ao = sma(hl2, fastLength) - sma(hl2, slowLength) 10 | 11 | aoColor = ao >= 0 ? (ao[1] < ao ? #26A69A : #B2DFDB) : (ao[1] < ao ? #FFCDD2 : #EF5350) 12 | plot(ao, title="AO", style=columns, color=aoColor, transp=0) 13 | -------------------------------------------------------------------------------- /oscillators/center_of_gravity_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // CG Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("CG Oscillator", shorttitle="CGO") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=10) 7 | applyFilling = input(title="Apply Filling ?", type=bool, defval=false) 8 | src = input(title="Source", type=source, defval=hl2) 9 | 10 | numeratorSum = 0.0 11 | denominatorSum = 0.0 12 | 13 | for i = 0 to length - 1 14 | numeratorSum := numeratorSum + (i + 1) * nz(src[i]) 15 | denominatorSum := denominatorSum + nz(src[i]) 16 | 17 | cgo = -numeratorSum / denominatorSum 18 | 19 | cgoPlot = plot(cgo, title="CGO", color=#3d85c6, transp=0) 20 | cgoPrevPlot = plot(cgo[1], title="CGO Prev", color=#ff3e7d, transp=0) 21 | 22 | fillColor = applyFilling ? (cgo > cgo[1] ? #0ebb23 : #cc0000) : color(white, 100) 23 | fill(cgoPlot, cgoPrevPlot, color=fillColor, transp=0) 24 | -------------------------------------------------------------------------------- /oscillators/chande_momentum_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Chande Momentum Oscillator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Chande Momentum Oscillator", shorttitle="CMO") 5 | 6 | length = input(title="Length", type=integer, defval=9) 7 | obLevel = input(title="Overbought Level", type=integer, defval=50) 8 | osLevel = input(title="Oversold Level", type=integer, defval=-50) 9 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 10 | src = input(title="Source", type=source, defval=close) 11 | 12 | mom = change(src) 13 | 14 | upSum = sum(max(mom, 0), length) 15 | downSum = sum(-min(mom, 0), length) 16 | 17 | cmo = 100 * (upSum - downSum) / (upSum + downSum) 18 | 19 | cmoColor = cmo > obLevel ? #0ebb23 : cmo < osLevel ? #ff0000 : #f4b77d 20 | 21 | plot(cmo, title="CMO", linewidth=2, color=cmoColor, transp=0) 22 | 23 | transparent = color(white, 100) 24 | 25 | maxBand = hline(100, title="Max Level", linestyle=dotted, color=transparent) 26 | hline(0, title="Zero Level", linestyle=dotted) 27 | minBand = hline(-100, title="Min Level", linestyle=dotted, color=transparent) 28 | 29 | obBand = hline(obLevel, title="Overbought Level", linestyle=dotted) 30 | osBand = hline(osLevel, title="Oversold Level", linestyle=dotted) 31 | fill(obBand, osBand, color=purple, transp=95) 32 | 33 | obFillColor = cmo > obLevel and highlightBreakouts ? green : transparent 34 | osFillColor = cmo < osLevel and highlightBreakouts ? red : transparent 35 | 36 | fill(maxBand, obBand, color=obFillColor, transp=80) 37 | fill(minBand, osBand, color=osFillColor, transp=80) 38 | -------------------------------------------------------------------------------- /oscillators/coppock_curve.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Coppock Curve script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Coppock Curve") 5 | 6 | length = input(title="Smoothing Length", type=integer, defval=10) 7 | longRocLength = input(title="Long ROC Length", type=integer, defval=14) 8 | shortRocLength = input(title="Short ROC Length", type=integer, defval=11) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | coppock = wma(roc(src, longRocLength) + roc(src, shortRocLength), length) 12 | 13 | coppockColor = coppock > 0 ? #0ebb23 : red 14 | 15 | plot(coppock, title="Coppock", linewidth=2, color=coppockColor, transp=0) 16 | hline(0, title="Zero Level", linestyle=dotted) 17 | -------------------------------------------------------------------------------- /oscillators/demarker.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // DeMarker script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("DeMarker", shorttitle="DeMarker") 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | maType = input(title="Smoothing Type", defval="SMA", options=["EMA", "SMA", "VWMA", "WMA"]) 8 | obLevel = input(title="Overbought Level", type=float, step=0.1, defval=0.7) 9 | osLevel = input(title="Oversold Level", type=float, step=0.1, defval=0.3) 10 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 11 | src = input(title="Source", type=source, defval=close) 12 | 13 | getMA(type, src, length) => 14 | type == "SMA" ? sma(src, length) : 15 | type == "EMA" ? ema(src, length) : 16 | type == "VWMA" ? vwma(src, length) : 17 | type == "WMA" ? wma(src, length) : 18 | na 19 | 20 | demax = max(change(high), 0) 21 | demin = -min(change(low), 0) 22 | 23 | demarker = getMA(maType, demax, length) / (getMA(maType, demax, length) + getMA(maType, demin, length)) 24 | 25 | demarkerColor = demarker > obLevel ? #0ebb23 : demarker < osLevel ? #ff0000 : #f4b77d 26 | plot(demarker, title="DeMarker", linewidth=2, color=demarkerColor, transp=0) 27 | 28 | transparent = color(white, 100) 29 | 30 | maxLevelPlot = hline(1, title="Max Level", linestyle=dotted, color=transparent) 31 | obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=dotted) 32 | hline(0.5, title="Middle Level", linestyle=dotted) 33 | osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=dotted) 34 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 35 | 36 | fill(obLevelPlot, osLevelPlot, color=purple, transp=95) 37 | 38 | obFillColor = demarker > obLevel and highlightBreakouts ? green : transparent 39 | osFillColor = demarker < osLevel and highlightBreakouts ? red : transparent 40 | 41 | fill(maxLevelPlot, obLevelPlot, color=obFillColor, transp=90) 42 | fill(minLevelPlot, osLevelPlot, color=osFillColor, transp=90) 43 | -------------------------------------------------------------------------------- /oscillators/derivative_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Derivative Oscillator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Derivative Oscillator", shorttitle="DOSC") 5 | 6 | rsiLength = input(title="RSI Length", type=input.integer, defval=14) 7 | ema1Length = input(title="1st EMA Smoothing Length", type=input.integer, defval=5) 8 | ema2Length = input(title="2nd EMA Smoothing Length", type=input.integer, defval=3) 9 | smaLength = input(title="3rd SMA Smoothing Length", type=input.integer, defval=9) 10 | signalLength = input(title="Signal Length", type=input.integer, defval=9) 11 | src = input(title="Source", type=input.source, defval=close) 12 | 13 | smoothedRSI = ema(ema(rsi(src, rsiLength), ema1Length), ema2Length) 14 | dosc = smoothedRSI - sma(smoothedRSI, smaLength) 15 | signal = sma(dosc, signalLength) 16 | 17 | doscColor = dosc >= 0 ? dosc[1] < dosc ? #26A69A : #B2DFDB : dosc[1] < dosc ? #FFCDD2 : #EF5350 18 | plot(dosc, title="DOSC", style=plot.style_columns, linewidth=2, color=doscColor, transp=0) 19 | plot(signal, title="Signal", linewidth=2, color=color.black, transp=0) 20 | -------------------------------------------------------------------------------- /oscillators/didi_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Didi Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Didi Index") 5 | 6 | curtaLength = input(title="Curta (Short) Length", type=integer, defval=3) 7 | mediaLength = input(title="Media (Medium) Length", type=integer, defval=8) 8 | longaLength = input(title="Longa (Long) Length", type=integer, defval=20) 9 | src = input(title="Source", type=source, defval=close) 10 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=true) 11 | highlightCrossovers = input(title="Highlight Crossovers ?", type=bool, defval=true) 12 | 13 | media = sma(src, mediaLength) 14 | curta = sma(src, curtaLength) / media 15 | longa = sma(src, longaLength) / media 16 | 17 | curtaPlot = plot(curta, title="Curta", color=green) 18 | plot(1, title="Media", color=black, transp=0) 19 | longaPlot = plot(longa, title="Longa", color=red) 20 | 21 | fillColor = applyFilling ? (curta > longa ? #0ebb23 : red) : color(white, 100) 22 | fill(curtaPlot, longaPlot, color=fillColor, transp=80) 23 | 24 | plotshape(crossover(curta, longa) and highlightCrossovers ? avg(longa, longa[1]) : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=20) 25 | plotshape(crossunder(curta, longa) and highlightCrossovers ? avg(longa, longa[1]) : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=20) 26 | -------------------------------------------------------------------------------- /oscillators/disparity_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Disparity Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Disparity Index", shorttitle="DI") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | di = 100 * (src - sma(src, length)) / sma(src, length) 10 | 11 | diColor = di >= 0.0 ? #0ebb23 : #ff0000 12 | plot(di, title="Disparity Index", linewidth=2, color=diColor, transp=0) 13 | 14 | hline(0, title="Zero Level", linestyle=dotted, color=#989898) 15 | -------------------------------------------------------------------------------- /oscillators/dorsey_inertia.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Dorsey Inertia script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Dorsey Inertia", shorttitle="Inertia") 5 | 6 | stdevLength = input(title="Standard Deviation Length", type=integer, defval=21) 7 | rviSmoothLength = input(title="RVI Smoothing Length", type=integer, defval=14) 8 | smoothLength = input(title="Inertia Smoothing Length", type=integer, defval=14) 9 | 10 | // Relative Volatility Index (1993) 11 | rviOriginal(src, stdevLength, smoothLength) => 12 | stdev = stdev(src, stdevLength) 13 | upSum = ema(change(src) >= 0 ? stdev : 0, smoothLength) 14 | downSum = ema(change(src) >= 0 ? 0 : stdev, smoothLength) 15 | 100 * upSum / (upSum + downSum) 16 | 17 | rvi = avg(rviOriginal(high, stdevLength, rviSmoothLength), rviOriginal(low, stdevLength, rviSmoothLength)) 18 | inertia = linreg(rvi, smoothLength, 0) 19 | 20 | inertiaColor = inertia > 50 ? #0ebb23 : red 21 | 22 | plot(inertia, title="Inertia", linewidth=2, color=inertiaColor, transp=0) 23 | hline(50, title="Middle Level", linestyle=dotted) 24 | -------------------------------------------------------------------------------- /oscillators/dynamic_momentum_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Dynamic Momentum Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Dynamic Momentum Index", shorttitle="DMI") 5 | 6 | rsiLength = input(title="Initial RSI Length", type=integer, minval=1, defval=14) 7 | stdevLength = input(title="Standard Deviation Length", type=integer, minval=1, defval=5) 8 | maLength = input(title="Smoothing Length", type=integer, minval=1, defval=10) 9 | lower = input(title="Lower Bound", type=integer, defval=5) 10 | upper = input(title="Upper Bound", type=integer, defval=30) 11 | obLevel = input(title="Overbought Level", type=integer, defval=70) 12 | osLevel = input(title="Oversold Level", type=integer, defval=30) 13 | src = input(title="Source", type=source, defval=close) 14 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 15 | 16 | stdev = stdev(src, stdevLength) 17 | V = stdev / sma(stdev, maLength) 18 | 19 | T = round(rsiLength / V) 20 | T := T > upper ? upper : T < lower ? lower : T 21 | 22 | // Wilder's Smoothing (Running Moving Average) 23 | _rma(src, length) => 24 | out = 0.0 25 | out := ((length - 1) * nz(out[1]) + src) / length 26 | 27 | _rsi(src, length) => 28 | upSum = _rma(max(change(src), 0), length) 29 | downSum = _rma(-min(change(src), 0), length) 30 | rsi = downSum == 0 31 | ? 100 32 | : upSum == 0 33 | ? 0 34 | : 100 - (100 / (1 + upSum / downSum)) 35 | rsi 36 | 37 | dmi = _rsi(src, T) 38 | 39 | dmiColor = dmi > obLevel ? #0ebb23 : dmi < osLevel ? red : #f4b77d 40 | plot(dmi, title="DMI", linewidth=2, color=dmiColor, transp=0) 41 | 42 | transparent = color(white, 100) 43 | 44 | maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent) 45 | obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=dotted) 46 | hline(50, title="Middle Level", linestyle=dotted) 47 | osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=dotted) 48 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 49 | 50 | fill(obLevelPlot, osLevelPlot, color=purple, transp=95) 51 | 52 | obFillColor = dmi > obLevel and highlightBreakouts ? green : transparent 53 | osFillColor = dmi < osLevel and highlightBreakouts ? red : transparent 54 | 55 | fill(maxLevelPlot, obLevelPlot, color=obFillColor, transp=90) 56 | fill(minLevelPlot, osLevelPlot, color=osFillColor, transp=90) 57 | -------------------------------------------------------------------------------- /oscillators/ehlers_cyber_cycle.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Cyber Cycle script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ehlers Cyber Cycle", shorttitle="ECC") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | alpha = input(title="Alpha", type=float, step=0.1, defval=0.7) 8 | applyFilling = input(title="Apply Filling ?", type=bool, defval=false) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | smooth = (src + 2 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 6 12 | 13 | ecc = 0.0 14 | ecc := pow(1 - alpha / 2, 2) * (smooth - 2 * nz(smooth[1]) + nz(smooth[2])) + 2 * (1 - alpha) * nz(ecc[1]) - pow(1 - alpha, 2) * nz(ecc[2]) 15 | 16 | eccPlot = plot(ecc, title="ECC", color=#3d85c6, transp=0) 17 | eccPrevPlot = plot(ecc[1], title="Trigger", color=#ff3e7d, transp=0) 18 | 19 | fillColor = applyFilling ? (ecc > ecc[1] ? #0ebb23 : #cc0000) : color(white, 100) 20 | fill(eccPlot, eccPrevPlot, color=fillColor, transp=0) 21 | -------------------------------------------------------------------------------- /oscillators/ehlers_decycler_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Ehlers Decycler Oscillator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Ehlers Decycler Oscillator", shorttitle="Decycler Oscillator") 5 | 6 | hpPeriod = input(title="High-pass Filter Period", type=integer, defval=125) 7 | k = input(title="K Multiplier", type=float, step=0.1, defval=1) 8 | hpPeriod2 = input(title="High-pass Filter Period 2", type=integer, defval=100) 9 | k2 = input(title="K Multiplier 2", type=float, step=0.1, defval=1.2) 10 | src = input(title="Source", type=source, defval=close) 11 | highlightCrossovers = input(title="Highlight Crossovers ?", type=bool, defval=true) 12 | highlightZeroCrossovers = input(title="Highlight Zero Line Crossovers ?", type=bool, defval=false) 13 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=false) 14 | 15 | PI = 2 * asin(1) 16 | 17 | // High-pass Filter 18 | _hp(src, hpPeriod, mult) => 19 | alphaArg = 2 * PI / (mult * hpPeriod * sqrt(2)) 20 | 21 | alpha = 0.0 22 | alpha := cos(alphaArg) != 0 23 | ? (cos(alphaArg) + sin(alphaArg) - 1) / cos(alphaArg) 24 | : nz(alpha[1]) 25 | 26 | hp = 0.0 27 | hp := pow(1 - (alpha / 2), 2) * (src - 2 * nz(src[1]) + nz(src[2])) + 2 * (1 - alpha) * nz(hp[1]) - pow(1 - alpha, 2) * nz(hp[2]) 28 | hp 29 | 30 | hp = _hp(src, hpPeriod, 1) 31 | decycler = src - hp 32 | decosc = 100 * k * _hp(decycler, hpPeriod, 0.5) / src 33 | 34 | hp2 = _hp(src, hpPeriod2, 1) 35 | decycler2 = src - hp2 36 | decosc2 = 100 * k2 * _hp(decycler2, hpPeriod2, 0.5) / src 37 | 38 | trendColor = decosc2 > decosc ? #0ebb23 : red 39 | 40 | decoscColor = applyFilling ? trendColor : #ff5048 41 | decosc2Color = applyFilling ? trendColor : #f5c75e 42 | 43 | decoscPlot = plot(decosc, title="1", linewidth=2, color=decoscColor, transp=0) 44 | decosc2Plot = plot(decosc2, title="2", linewidth=2, color=decosc2Color, transp=0) 45 | hline(0, title="Zero Level", linestyle=dotted) 46 | 47 | transparent = color(white, 100) 48 | 49 | fillColor = applyFilling ? trendColor : transparent 50 | fill(decoscPlot, decosc2Plot, color=fillColor, transp=70) 51 | 52 | zeroCrossBgColor = highlightZeroCrossovers ? (decosc > 0 or decosc2 > 0 ? green : red) : transparent 53 | bgcolor(zeroCrossBgColor, transp=85) 54 | 55 | plotshape(highlightCrossovers and crossover(decosc, decosc2) ? avg(decosc, decosc[1]) : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 56 | plotshape(highlightCrossovers and crossunder(decosc, decosc2) ? avg(decosc, decosc[1]) : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 57 | -------------------------------------------------------------------------------- /oscillators/ehlers_roofing_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Roofing Filter indicator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ehlers Roofing Filter", shorttitle="ERF") 5 | 6 | highpassLength = input(title="HighPass Length", type=integer, minval=1, defval=48) 7 | ssfLength = input(title="Super Smoother Filter Length", type=integer, minval=1, defval=10) 8 | numberOfPoles = input(title="Number of Poles", type=integer, defval=2, options=[2, 3]) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | PI = 2 * asin(1) 12 | 13 | twoPoleSuperSmootherFilter(src, length) => 14 | arg = sqrt(2) * PI / length 15 | a1 = exp(-arg) 16 | b1 = 2 * a1 * cos(arg) 17 | c2 = b1 18 | c3 = -pow(a1, 2) 19 | c1 = 1 - c2 - c3 20 | 21 | ssf = 0.0 22 | ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2]) 23 | 24 | threePoleSuperSmootherFilter(src, length) => 25 | arg = PI / length 26 | a1 = exp(-arg) 27 | b1 = 2 * a1 * cos(1.738 * arg) 28 | c1 = pow(a1, 2) 29 | 30 | coef2 = b1 + c1 31 | coef3 = -(c1 + b1 * c1) 32 | coef4 = pow(c1, 2) 33 | coef1 = 1 - coef2 - coef3 - coef4 34 | 35 | ssf = 0.0 36 | ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3]) 37 | 38 | roofingFilter(src, highpassLength, ssfLength, numberOfPoles) => 39 | alphaArg = 2 * PI / (highpassLength * sqrt(2)) 40 | 41 | alpha = 0.0 42 | alpha := cos(alphaArg) != 0 43 | ? (cos(alphaArg) + sin(alphaArg) - 1) / cos(alphaArg) 44 | : nz(alpha[1]) 45 | 46 | highpass = 0.0 47 | highpass := pow(1 - (alpha / 2), 2) * (src - 2 * nz(src[1]) + nz(src[2])) + 2 * (1 - alpha) * nz(highpass[1]) - pow(1 - alpha, 2) * nz(highpass[2]) 48 | 49 | numberOfPoles == 2 50 | ? twoPoleSuperSmootherFilter((highpass + nz(highpass[1])) / 2, ssfLength) 51 | : threePoleSuperSmootherFilter((highpass + nz(highpass[1])) / 2, ssfLength) 52 | 53 | erf = roofingFilter(src, highpassLength, ssfLength, numberOfPoles) 54 | 55 | erfColor = erf >= 0.0 ? #0ebb23 : #ff0000 56 | 57 | plot(erf, title="ERF", linewidth=2, color=erfColor, transp=0) 58 | 59 | hline(0, title="Zero Level", linestyle=dotted, color=#989898) 60 | -------------------------------------------------------------------------------- /oscillators/ehlers_stochastic_cyber_cycle.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Stochastic Cyber Cycle script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ehlers Stochastic Cyber Cycle", shorttitle="ESCC") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | alpha = input(title="Alpha", type=float, step=0.1, defval=0.7) 8 | applyFilling = input(title="Apply Filling ?", type=bool, defval=false) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | smooth = (src + 2 * nz(src[1]) + 2 * nz(src[2]) + nz(src[3])) / 6 12 | 13 | cycle = 0.0 14 | cycle := pow(1 - alpha / 2, 2) * (smooth - 2 * nz(smooth[1]) + nz(smooth[2])) + 2 * (1 - alpha) * nz(cycle[1]) - pow(1 - alpha, 2) * nz(cycle[2]) 15 | 16 | maxCycle = highest(cycle, length) 17 | minCycle = lowest(cycle, length) 18 | 19 | stoch = (cycle - minCycle) / (maxCycle - minCycle) 20 | 21 | escc = 2 * ((4 * stoch + 3 * nz(stoch[1]) + 2 * nz(stoch[2]) + nz(stoch[3])) / 10 - 0.5) 22 | esccPrev = 0.96 * (escc[1] + 0.02) 23 | 24 | esccPlot = plot(escc, title="ESCC", color=#3d85c6, transp=0) 25 | esccPrevPlot = plot(esccPrev, title="Trigger", color=#ff3e7d, transp=0) 26 | 27 | hline(0, title="Zero Level", linestyle=dotted) 28 | 29 | fillColor = applyFilling ? (escc > esccPrev ? #0ebb23 : #cc0000) : color(white, 100) 30 | fill(esccPlot, esccPrevPlot, color=fillColor, transp=0) 31 | -------------------------------------------------------------------------------- /oscillators/ehlers_super_passband_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ehlers Super Passband Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ehlers Super Passband Filter", shorttitle="ESPF") 5 | 6 | fastLength = input(title="Fast Length", type=integer, minval=1, defval=40) 7 | slowLength = input(title="Slow Length", type=integer, minval=1, defval=60) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | ehlersSuperPassbandFilter(src, fastLength, slowLength) => 11 | a1 = 5 / fastLength 12 | a2 = 5 / slowLength 13 | 14 | espf = 0.0 15 | espf := (a1 - a2) * src + 16 | (a2 * (1 - a1) - a1 * (1 - a2)) * nz(src[1]) + 17 | ((1 - a1) + (1 - a2)) * nz(espf[1]) - 18 | (1 - a1) * (1 - a2) * nz(espf[2]) 19 | 20 | espf = ehlersSuperPassbandFilter(src, fastLength, slowLength) 21 | 22 | // Compute Root Mean Square 23 | rms = sqrt(sum(espf * espf, 50) / 50) 24 | 25 | spbColor = espf > rms ? #0ebb23 : espf < -rms ? #ff0000 : #674ea7 26 | 27 | plot(rms, title="+RMS", linewidth=1, color=#f6b26b, transp=0) 28 | plot(espf, title="ESPF", linewidth=2, color=spbColor, transp=0) 29 | plot(-rms, title="-RMS", linewidth=1, color=#f6b26b, transp=0) 30 | 31 | hline(0, title="Zero Level", linestyle=dotted, color=#989898) 32 | -------------------------------------------------------------------------------- /oscillators/ehlers_triple_delay_line_detrender.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Ehlers Triple Delay-Line Detrender script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Ehlers Triple Delay-Line Detrender", shorttitle="TDLD") 5 | 6 | src = input(title="Source", type=source, defval=hl2) 7 | showSignal = input(title="Show Signal Line ?", type=bool, defval=true) 8 | showHistogram = input(title="Show Histogram ?", type=bool, defval=false) 9 | highlightCrossovers = input(title="Highlight Signal Crossovers ?", type=bool, defval=true) 10 | highlightZeroCrossovers = input(title="Highlight Zero Line Crossovers ?", type=bool, defval=false) 11 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=false) 12 | 13 | tmp1 = 0.0 14 | tmp1 := src + .088 * nz(tmp1[6]) 15 | 16 | tmp2 = 0.0 17 | tmp2 := tmp1 - nz(tmp1[6]) + 1.2 * nz(tmp2[6]) - 0.7 * nz(tmp2[12]) 18 | 19 | detrender = nz(tmp2[12]) - 2 * nz(tmp2[6]) + tmp2 20 | 21 | _moef(src) => 22 | src1 = nz(src[1], src) 23 | src2 = nz(src[2], src1) 24 | src3 = nz(src[3], src2) 25 | 26 | moef = src 27 | moef := 0.13785 * (2 * src - src1) + 28 | 0.0007 * (2 * src1 - src2) + 29 | 0.13785 * (2 * src2 - src3) + 30 | 1.2103 * nz(moef[1], moef) - 31 | 0.4867 * nz(moef[2], moef) 32 | moef 33 | 34 | tdld = _moef(detrender) 35 | signal = _moef(tdld) 36 | 37 | hist = tdld - signal 38 | histColor = hist >= 0 ? (hist[1] < hist ? #26a69a : #b2dfdb) : (hist[1] < hist ? #ffcdd2 : #ef5350) 39 | plot(showHistogram ? hist : na, title="Histogram", style=columns, color=histColor, transp=0) 40 | hline(0, title="Zero Level", linestyle=dotted) 41 | 42 | trendColor = tdld > signal ? #0ebb23 : red 43 | 44 | tdldColor = applyFilling ? trendColor : (tdld > 0 ? #0ebb23 : red) 45 | signalColor = applyFilling ? trendColor : #ff9800 46 | 47 | tdldPlot = plot(tdld, title="TDLD", linewidth=2, color=tdldColor, transp=0) 48 | signalPlot = plot(showSignal ? signal : na, title="Signal", color=signalColor, transp=0) 49 | 50 | transparent = color(white, 100) 51 | 52 | fillColor = applyFilling ? trendColor : transparent 53 | fill(tdldPlot, signalPlot, color=fillColor, transp=70) 54 | 55 | zeroCrossBgColor = highlightZeroCrossovers ? (tdld > 0 ? green : red) : transparent 56 | bgcolor(zeroCrossBgColor, transp=80) 57 | 58 | plotshape(highlightCrossovers and crossover(tdld, signal) ? avg(tdld, tdld[1]) : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 59 | plotshape(highlightCrossovers and crossunder(tdld, signal) ? avg(tdld, tdld[1]) : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 60 | -------------------------------------------------------------------------------- /oscillators/ergodic_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ergodic Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Ergodic Oscillator", shorttitle="EOSC") 5 | 6 | firstSmoothingLength = input(title="1st Smoothing Length", type=integer, minval=1, defval=8) 7 | secondSmoothingLength = input(title="2nd Smoothing Length", type=integer, minval=1, defval=5) 8 | signalLength = input(title="Signal Length", type=integer, minval=1, defval=5) 9 | ergodicLength = input(title="Ergodic Length", type=integer, minval=1, defval=5) 10 | ergodicSignalLength = input(title="Ergodic Signal Length", type=integer, minval=1, defval=14) 11 | overboughtLevel = input(title="Overbought Level", type=integer, defval=20) 12 | oversoldLevel = input(title="Oversold Level", type=integer, defval=-20) 13 | src = input(title="Source", type=source, defval=close) 14 | 15 | momentum = change(src) 16 | 17 | ema1 = ema(momentum, firstSmoothingLength) 18 | ema1Abs = ema(abs(momentum), firstSmoothingLength) 19 | 20 | ema2 = ema(ema1, secondSmoothingLength) 21 | ema2Abs = ema(abs(ema1Abs), secondSmoothingLength) 22 | 23 | tsi = 100 * ema2 / ema2Abs 24 | 25 | signal = ema(tsi, signalLength) 26 | 27 | ergodic = ema(signal, ergodicLength) 28 | 29 | ergodicSignal = ema(ergodic, ergodicSignalLength) 30 | 31 | plot(ergodic, title="Ergodic", linewidth=2, color=#3c78d8, transp=0) 32 | plot(ergodicSignal, title="Signal", linewidth=2, color=#cc0000, transp=0) 33 | 34 | hline(overboughtLevel, title="Overbought Level", linestyle=dotted, linewidth=2, color=#0ebb23) 35 | hline(oversoldLevel, title="Oversold Level", linestyle=dotted, linewidth=2, color=#ff9370) 36 | -------------------------------------------------------------------------------- /oscillators/forecast_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Forecast Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Forecast Oscillator", shorttitle="FOSC") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | fosc = 100 * (src - linreg(src, length, 0)) / src 10 | 11 | foscColor = fosc >= 0.0 ? #0ebb23 : #ff0000 12 | 13 | plot(fosc, title="FOSC", linewidth=2, color=foscColor, transp=0) 14 | 15 | hline(0, title="Zero Level", linestyle=dotted, color=#989898) 16 | -------------------------------------------------------------------------------- /oscillators/gator_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Gator Oscillator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Gator Oscillator", shorttitle="Gator") 5 | 6 | jawLength = input(title="Jaw Length", type=integer, defval=13) 7 | teethLength = input(title="Teeth Length", type=integer, defval=8) 8 | lipsLength = input(title="Lips Length", type=integer, defval=5) 9 | 10 | jaw = offset(rma(hl2, jawLength), 8) 11 | teeth = offset(rma(hl2, teethLength), 5) 12 | lips = offset(rma(hl2, lipsLength), 3) 13 | 14 | upper = abs(jaw - teeth) 15 | lower = -abs(teeth - lips) 16 | 17 | upperColor = (upper[1] < upper ? #26A69A : #EF5350) 18 | lowerColor = (lower[1] > lower ? #26A69A : #EF5350) 19 | 20 | plot(upper, title="Upper", style=columns, color=upperColor, transp=0) 21 | plot(lower, title="Lower", style=columns, color=lowerColor, transp=0) 22 | -------------------------------------------------------------------------------- /oscillators/intraday_momentum_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Intraday Momentum Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Intraday Momentum Index", shorttitle="IMI") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | gain = close > open ? close - open : 0 11 | loss = close > open ? 0 : open - close 12 | 13 | upSum = sum(gain, length) 14 | downSum = sum(loss, length) 15 | 16 | imi = 100 * upSum / (upSum + downSum) 17 | 18 | obLevel = 70 19 | osLevel = 30 20 | 21 | imiColor = imi > obLevel ? #0ebb23 : imi < osLevel ? #ff0000 : #f4b77d 22 | plot(imi, title="IMI", linewidth=2, color=imiColor, transp=0) 23 | 24 | transparent = color(white, 100) 25 | 26 | maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent) 27 | obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=dotted) 28 | hline(50, title="Middle Level", linestyle=dotted) 29 | osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=dotted) 30 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 31 | 32 | fill(obLevelPlot, osLevelPlot, color=purple, transp=95) 33 | 34 | obFillColor = imi > obLevel and highlightBreakouts ? green : transparent 35 | osFillColor = imi < osLevel and highlightBreakouts ? red : transparent 36 | 37 | fill(maxLevelPlot, obLevelPlot, color=obFillColor, transp=90) 38 | fill(minLevelPlot, osLevelPlot, color=osFillColor, transp=90) 39 | -------------------------------------------------------------------------------- /oscillators/kairi_relative_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Kairi Relative Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Kairi Relative Index", shorttitle="KRI") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | kri = 100 * (src - sma(src, length)) / sma(src, length) 10 | 11 | plot(kri, title="KRI", linewidth=1, color=#134f5c, transp=0) 12 | 13 | hline(0, title="Zero Level", linestyle=dotted, color=#989898) 14 | -------------------------------------------------------------------------------- /oscillators/laguerre_rsi.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Laguerre RSI script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Laguerre RSI", shorttitle="LRSI") 5 | 6 | alpha = input(title="Alpha", type=float, minval=0, step=0.1, defval=0.7) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | L0 = 0.0 10 | L1 = 0.0 11 | L2 = 0.0 12 | L3 = 0.0 13 | 14 | L0 := alpha * src + (1 - alpha) * nz(L0[1]) 15 | L1 := -(1 - alpha) * L0 + nz(L0[1]) + (1 - alpha) * nz(L1[1]) 16 | L2 := -(1 - alpha) * L1 + nz(L1[1]) + (1 - alpha) * nz(L2[1]) 17 | L3 := -(1 - alpha) * L2 + nz(L2[1]) + (1 - alpha) * nz(L3[1]) 18 | 19 | CU = 0.0 20 | CD = 0.0 21 | 22 | CU := (L0 >= L1 ? L0 - L1 : 0) + (L1 >= L2 ? L1 - L2 : 0) + (L2 >= L3 ? L2 - L3 : 0) 23 | CD := (L0 >= L1 ? 0 : L1 - L0) + (L1 >= L2 ? 0 : L2 - L1) + (L2 >= L3 ? 0 : L3 - L2) 24 | 25 | lrsi = iff(CU + CD != 0, CU / (CU + CD), 0) 26 | 27 | overboughtLevel = hline(0.8, title="Overbought Level", linestyle=dashed, color=#686868) 28 | oversoldLevel = hline(0.2, title="Oversold Level", linestyle=dashed, color=#686868) 29 | 30 | plot(lrsi, title="LRSI", linewidth=2, color=#ff3e7d, transp=0) 31 | -------------------------------------------------------------------------------- /oscillators/laguerre_rsi_self_adjusting_alpha_with_fractals_energy.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Laguerre RSI (Self Adjusting Alpha with Fractals Energy) script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Laguerre RSI (Self Adjusting Alpha with Fractals Energy)", shorttitle="LRSI") 5 | 6 | alpha = input(title="Alpha", type=float, minval=0, step=0.1, defval=0.7) 7 | applyFractalEnergy = input(title="Apply Fractal Energy ?", type=bool, defval=true) 8 | feLength = input(title="Fractals Energy Length", type=integer, minval=1, defval=13) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | OC = (open + nz(close[1])) / 2 12 | HC = max(high, nz(close[1])) 13 | LC = min(low, nz(close[1])) 14 | 15 | feSrc = (OC + HC + LC + close) / 4 16 | 17 | feAlpha = log(sum((max(high, nz(close[1])) - min(low, nz(close[1]))) / (highest(high, feLength) - lowest(low, feLength)), feLength)) / log(feLength) 18 | 19 | L0 = 0.0 20 | L1 = 0.0 21 | L2 = 0.0 22 | L3 = 0.0 23 | 24 | lrsiAlpha = applyFractalEnergy ? feAlpha : alpha 25 | 26 | L0 := lrsiAlpha * (applyFractalEnergy ? feSrc : src) + (1 - lrsiAlpha) * nz(L0[1]) 27 | L1 := -(1 - lrsiAlpha) * L0 + nz(L0[1]) + (1 - lrsiAlpha) * nz(L1[1]) 28 | L2 := -(1 - lrsiAlpha) * L1 + nz(L1[1]) + (1 - lrsiAlpha) * nz(L2[1]) 29 | L3 := -(1 - lrsiAlpha) * L2 + nz(L2[1]) + (1 - lrsiAlpha) * nz(L3[1]) 30 | 31 | CU = 0.0 32 | CD = 0.0 33 | 34 | CU := (L0 >= L1 ? L0 - L1 : 0) + (L1 >= L2 ? L1 - L2 : 0) + (L2 >= L3 ? L2 - L3 : 0) 35 | CD := (L0 >= L1 ? 0 : L1 - L0) + (L1 >= L2 ? 0 : L2 - L1) + (L2 >= L3 ? 0 : L3 - L2) 36 | 37 | lrsi = iff(CU + CD != 0, CU / (CU + CD), 0) 38 | 39 | overboughtLevel = hline(0.8, title="Overbought Level", linestyle=dashed, color=#686868) 40 | oversoldLevel = hline(0.2, title="Oversold Level", linestyle=dashed, color=#686868) 41 | 42 | plot(lrsi, title="LRSI", linewidth=2, color=#ff3e7d, transp=0) 43 | plot(applyFractalEnergy ? feAlpha : na, title="FE Alpha", linewidth=2, color=#674ea7, transp=0) 44 | -------------------------------------------------------------------------------- /oscillators/mass_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Mass Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Mass Index") 5 | 6 | smoothLength = input(title="Smoothing Length", type=integer, defval=9) 7 | sumLength = input(title="Summation Length", type=integer, defval=25) 8 | breakout = input(title="Breakout Level", type=integer, defval=27) 9 | 10 | mi = sum(ema(high - low, smoothLength) / ema(ema(high - low, smoothLength), smoothLength), sumLength) 11 | 12 | miColor = mi > breakout - 0.5 ? #ff9800 : #3c78d8 13 | 14 | plot(mi, title="Mass Index", linewidth=2, color=miColor, transp=0) 15 | 16 | transparent = color(white, 100) 17 | 18 | maxLevel = hline(29, title="Max Level", linestyle=dotted, color=transparent) 19 | breakoutLevel = hline(breakout, title="Breakout Level", linestyle=dotted) 20 | hline(breakout - 0.5, title="Confirmation Level", linestyle=dotted) 21 | 22 | breakoutFillColor = mi > breakout ? #e06666 : transparent 23 | 24 | fill(maxLevel, breakoutLevel, color=breakoutFillColor, transp=80) 25 | -------------------------------------------------------------------------------- /oscillators/normalized_relative_vigor_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Normalized Relative Vigor Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Normalized Relative Vigor Index", shorttitle="NRVGI") 5 | 6 | length = input(title="Length", type=integer, defval=10, minval=1) 7 | applyFilling = input(title="Apply Filling ?", type=bool, defval=false) 8 | 9 | rvgi = sum(swma(close - open), length) / sum(swma(high - low), length) 10 | signal = swma(rvgi) 11 | 12 | rvgiPlot = plot(100 * rvgi, title="NRVGI", color=green, transp=0) 13 | signalPlot = plot(100 * signal, title="Signal", color=red, transp=0) 14 | 15 | fillColor = applyFilling ? (rvgi > signal ? #0ebb23 : #cc0000) : color(white, 100) 16 | fill(rvgiPlot, signalPlot, color=fillColor, transp=0) 17 | -------------------------------------------------------------------------------- /oscillators/percentage_price_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Percentage Price Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Percentage Price Oscillator", shorttitle="PPO") 5 | 6 | fastLength = input(title="Fast Length", type=integer, minval=1, defval=12) 7 | slowLength = input(title="Slow Length", type=integer, minval=1, defval=26) 8 | signalLength = input(title="Signal Length", type=integer, minval=1, defval=9) 9 | applyFilling = input(title="Apply Filling ?", type=bool, defval=false) 10 | src = input(title="Source", type=source, defval=close) 11 | 12 | ppo = 100 * (ema(src, fastLength) - ema(src, slowLength)) / ema(src, slowLength) 13 | 14 | signal = ema(ppo, signalLength) 15 | 16 | hist = ppo - signal 17 | 18 | plot(hist, title="Histogram", style=histogram, transp=0, color=#ff006e) 19 | ppoPlot = plot(ppo, title="PPO", transp=0, color=#0094ff) 20 | signalPlot = plot(signal, title="Signal", transp=0, color=#ff6a00) 21 | 22 | fillColor = applyFilling ? (ppo > signal ? #0ebb23 : #cc0000) : color(white, 100) 23 | fill(ppoPlot, signalPlot, color=fillColor, transp=0) 24 | -------------------------------------------------------------------------------- /oscillators/percentage_volume_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Percentage Volume Oscillator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Percentage Volume Oscillator", shorttitle="PVO") 5 | 6 | fastLength = input(title="Fast Length", type=integer, defval=12) 7 | slowLength = input(title="Slow Length", type=integer, defval=26) 8 | signalLength = input(title="Signal Length", type=integer, defval=9) 9 | showHistogram = input(title="Show Histogram ?", type=bool, defval=true) 10 | highlightCrossovers = input(title="Highlight PVO/Signal Crossovers ?", type=bool, defval=true) 11 | highlightZeroCrossovers = input(title="Highlight Zero Line Crossovers ?", type=bool, defval=false) 12 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=false) 13 | 14 | src = volume 15 | 16 | pvo = 100 * (ema(src, fastLength) - ema(src, slowLength)) / ema(src, slowLength) 17 | signal = ema(pvo, signalLength) 18 | 19 | hist = pvo - signal 20 | histColor = hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #EF5350) 21 | 22 | plot(showHistogram ? hist : na, title="Histogram", style=columns, color=histColor, transp=0) 23 | hline(0, title="Zero Line", linestyle=dotted) 24 | 25 | trendColor = pvo > signal ? #0ebb23 : red 26 | pvoColor = applyFilling ? trendColor : #0094ff 27 | signalColor = applyFilling ? trendColor : #ff6a00 28 | 29 | pvoPlot = plot(pvo, title="PVO", color=pvoColor, transp=0) 30 | signalPlot = plot(signal, title="Signal", color=signalColor, transp=0) 31 | 32 | transparent = color(white, 100) 33 | 34 | fillColor = applyFilling ? trendColor : transparent 35 | fill(pvoPlot, signalPlot, color=fillColor, transp=70) 36 | 37 | zeroCrossBgColor = highlightZeroCrossovers ? (pvo > 0 ? green : red) : transparent 38 | bgcolor(zeroCrossBgColor, transp=90) 39 | 40 | plotshape(highlightCrossovers and crossover(pvo, signal) ? pvo : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 41 | plotshape(highlightCrossovers and crossunder(pvo, signal) ? pvo : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 42 | -------------------------------------------------------------------------------- /oscillators/phase_change_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Phase Change Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Phase Change Index", shorttitle="PCI") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=35) 7 | upperLevel = input(title="Upper Level", type=integer, defval=80) 8 | lowerLevel = input(title="Lower Level", type=integer, defval=20) 9 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 10 | applySmoothing = input(title="Apply Smoothing ?", type=bool, defval=false) 11 | smoothingType = input(title="Smoothing Type", defval="SMA", options=["EMA", "SMA", "VWMA", "WMA"]) 12 | smoothingLength = input(title="Smoothing Length", type=integer, minval=1, defval=3) 13 | src = input(title="Source", type=source, defval=close) 14 | 15 | getMA(src, length) => 16 | ma = 0.0 17 | if smoothingType == "EMA" 18 | ma := ema(src, length) 19 | if smoothingType == "SMA" 20 | ma := sma(src, length) 21 | if smoothingType == "VWMA" 22 | ma := vwma(src, length) 23 | if smoothingType == "WMA" 24 | ma := wma(src, length) 25 | ma 26 | 27 | mom = change(src, length) 28 | 29 | positiveSum = 0.0 30 | negativeSum = 0.0 31 | 32 | for i = 0 to length - 1 33 | gradient = nz(src[length]) + mom * (length - i) / (length - 1) 34 | deviation = nz(src[length - i]) - gradient 35 | 36 | if deviation > 0 37 | positiveSum := positiveSum + deviation 38 | else 39 | negativeSum := negativeSum - deviation 40 | 41 | sum = positiveSum + negativeSum 42 | pci = sum != 0 ? 100 * positiveSum / sum : 0 43 | pci := applySmoothing ? getMA(pci, smoothingLength) : pci 44 | 45 | pciColor = pci > upperLevel ? #0ebb23 : pci < lowerLevel ? #ff0000 : #f4b77d 46 | plot(pci, title="PCI", linewidth=2, color=pciColor, transp=0) 47 | 48 | transparent = color(white, 100) 49 | 50 | maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent) 51 | upperLevelPlot = hline(upperLevel, title="Upper Level", linestyle=dotted) 52 | hline(50, title="Middle Level", linestyle=dotted) 53 | lowerLevelPlot = hline(lowerLevel, title="Lower Level", linestyle=dotted) 54 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 55 | 56 | fill(upperLevelPlot, lowerLevelPlot, color=purple, transp=95) 57 | 58 | upperFillColor = pci > upperLevel and highlightBreakouts ? green : transparent 59 | lowerFillColor = pci < lowerLevel and highlightBreakouts ? red : transparent 60 | 61 | fill(maxLevelPlot, upperLevelPlot, color=upperFillColor, transp=90) 62 | fill(minLevelPlot, lowerLevelPlot, color=lowerFillColor, transp=90) 63 | -------------------------------------------------------------------------------- /oscillators/pretty_good_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Pretty Good Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Pretty Good Oscillator", shorttitle="PGO") 5 | 6 | length = input(title="Length", type=integer, defval=14, minval=1) 7 | upperLevel = input(title="Upper Level", type=float, step=0.1, defval=2.0) 8 | lowerLevel = input(title="Lower Level", type=float, step=0.1, defval=-2.0) 9 | maxLevel = input(title="Max Level", type=float, step=0.1, defval=4.0) 10 | minLevel = input(title="Min Level", type=float, step=0.1, defval=-4.0) 11 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 12 | src = input(title="Source", type=source, defval=close) 13 | 14 | pgo = (src - sma(src, length)) / atr(length) 15 | 16 | pgoColor = pgo > upperLevel ? #0ebb23 : pgo < lowerLevel ? #ff0000 : #f4b77d 17 | plot(pgo, title="PGO", linewidth=2, color=pgoColor, transp=0) 18 | 19 | transparent = color(white, 100) 20 | 21 | maxLevelPlot = hline(maxLevel, title="Max Level", linestyle=dotted, color=transparent) 22 | upperLevelPlot = hline(upperLevel, title="Upper Level", linestyle=dotted) 23 | hline(0, title="Zero Level", linestyle=dotted) 24 | lowerLevelPlot = hline(lowerLevel, title="Lower Level", linestyle=dotted) 25 | minLevelPlot = hline(minLevel, title="Min Level", linestyle=dotted, color=transparent) 26 | 27 | fill(upperLevelPlot, lowerLevelPlot, color=purple, transp=95) 28 | 29 | upperFillColor = pgo > upperLevel and highlightBreakouts ? green : transparent 30 | lowerFillColor = pgo < lowerLevel and highlightBreakouts ? red : transparent 31 | 32 | fill(maxLevelPlot, upperLevelPlot, color=upperFillColor, transp=90) 33 | fill(minLevelPlot, lowerLevelPlot, color=lowerFillColor, transp=90) 34 | -------------------------------------------------------------------------------- /oscillators/price_momentum_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Price Momentum Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Price Momentum Oscillator", shorttitle="PMO") 5 | 6 | firstLength = input(title="1st Smoothing Length", type=integer, minval=1, defval=35) 7 | secondLength = input(title="2nd Smoothing Length", type=integer, minval=1, defval=20) 8 | signalLength = input(title="Signal Length", type=integer, minval=1, defval=10) 9 | applyFilling = input(title="Apply Filling ?", type=bool, defval=false) 10 | src = input(title="Source", type=source, defval=close) 11 | 12 | rocMA = 0.0 13 | rocMA := (nz(rocMA[1]) + (roc(src, 1) - nz(rocMA[1])) * (2 / firstLength)) 14 | 15 | pmo = 0.0 16 | pmo := nz(pmo[1]) + (10 * rocMA - nz(pmo[1])) * (2 / secondLength) 17 | 18 | pmoSignal = 0.0 19 | pmoSignal := (2 / signalLength) * (pmo - nz(pmoSignal[1])) + nz(pmoSignal[1]) 20 | 21 | pmoPlot = plot(pmo, title="PMO", color=#1155cc, transp=0) 22 | pmoSignalPlot = plot(pmoSignal, title="Signal", color=red, transp=0) 23 | 24 | fillColor = applyFilling ? (pmo > pmoSignal ? #0ebb23 : #cc0000) : color(white, 100) 25 | fill(pmoPlot, pmoSignalPlot, color=fillColor, transp=0) 26 | 27 | hline(0, title="Zero Level", linestyle=dotted) 28 | -------------------------------------------------------------------------------- /oscillators/pring_special_k.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Pring Special K script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Pring Special K", shorttitle="PSK") 5 | 6 | src = input(title="Source", type=source, defval=close) 7 | 8 | psk = sma(roc(src, 10), 10) + 9 | sma(roc(src, 10), 15) * 2 + 10 | sma(roc(src, 10), 20) * 3 + 11 | sma(roc(src, 15), 30) * 4 + 12 | sma(roc(src, 50), 40) + 13 | sma(roc(src, 65), 65) * 2 + 14 | sma(roc(src, 75), 75) * 3 + 15 | sma(roc(src, 100), 100) * 4 + 16 | sma(roc(src, 130), 195) + 17 | sma(roc(src, 130), 265) * 2 + 18 | sma(roc(src, 130), 390) * 3 + 19 | sma(roc(src, 195), 530) * 4 20 | 21 | pskColor = psk >= 0.0 ? #0ebb23 : #ff0000 22 | 23 | plot(psk, title="PSK", linewidth=2, color=pskColor, transp=0) 24 | 25 | hline(0, title="Zero Level", linestyle=dotted) 26 | -------------------------------------------------------------------------------- /oscillators/random_walk_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Random Walk Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Random Walk Index", shorttitle="RWI") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | 8 | rwiHigh = (high - nz(low[length])) / (atr(length) * sqrt(length)) 9 | rwiLow = (nz(high[length]) - low) / (atr(length) * sqrt(length)) 10 | 11 | plot(rwiHigh, title="High", linewidth=2, color=#6d1e7f, transp=0) 12 | plot(rwiLow, title="Low", linewidth=2, color=#ff3737, transp=0) 13 | -------------------------------------------------------------------------------- /oscillators/range_action_verification_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Range Action Verification Index (RAVI) script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Range Action Verification Index (RAVI)", shorttitle="RAVI") 5 | 6 | fastLength = input(title="Fast MA Length", type=integer, minval=1, defval=7) 7 | fastMAInput = input(title="Fast MA", defval="SMA", options=["EMA", "SMA", "VWMA", "WMA"]) 8 | slowLength = input(title="Slow MA Length", type=integer, minval=1, defval=65) 9 | slowMAInput = input(title="Slow MA", defval="SMA", options=["EMA", "SMA", "VWMA", "WMA"]) 10 | comparisonLookback = input(title="Comparison Lookback", type=integer, minval=1, defval=1) 11 | src = input(title="Source", type=source, defval=close) 12 | 13 | fastMA = iff(fastMAInput == "EMA", ema(src, fastLength), 14 | iff(fastMAInput == "SMA", sma(src, fastLength), 15 | iff(fastMAInput == "VWMA", vwma(src, fastLength), 16 | iff(fastMAInput == "WMA", wma(src, fastLength), 17 | na)))) 18 | 19 | slowMA = iff(slowMAInput == "EMA", ema(src, slowLength), 20 | iff(slowMAInput == "SMA", sma(src, slowLength), 21 | iff(slowMAInput == "VWMA", vwma(src, slowLength), 22 | iff(slowMAInput == "WMA", wma(src, slowLength), 23 | na)))) 24 | 25 | ravi = abs(100 * (fastMA - slowMA) / slowMA) 26 | 27 | raviColor = ravi > nz(ravi[comparisonLookback]) ? green : red 28 | 29 | plot(ravi, title="RAVI", linewidth=2, color=raviColor, transp=0) 30 | -------------------------------------------------------------------------------- /oscillators/rapid_rsi.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Rapid RSI script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Rapid RSI", shorttitle="RRSI") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | upSum = sum(max(change(src), 0), length) 11 | downSum = sum(max(-change(src), 0), length) 12 | 13 | rrsi = downSum == 0 ? 100 : upSum == 0 ? 0 : 100 - (100 / (1 + upSum / downSum)) 14 | 15 | obLevel = 70 16 | osLevel = 30 17 | 18 | rrsiColor = rrsi > obLevel ? #0ebb23 : rrsi < osLevel ? #ff0000 : #f4b77d 19 | plot(rrsi, title="RRSI", linewidth=2, color=rrsiColor, transp=0) 20 | 21 | transparent = color(white, 100) 22 | 23 | maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent) 24 | obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=dotted) 25 | hline(50, title="Middle Level", linestyle=dotted) 26 | osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=dotted) 27 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 28 | 29 | fill(obLevelPlot, osLevelPlot, color=purple, transp=95) 30 | 31 | obFillColor = rrsi > obLevel and highlightBreakouts ? green : transparent 32 | osFillColor = rrsi < osLevel and highlightBreakouts ? red : transparent 33 | 34 | fill(maxLevelPlot, obLevelPlot, color=obFillColor, transp=90) 35 | fill(minLevelPlot, osLevelPlot, color=osFillColor, transp=90) 36 | -------------------------------------------------------------------------------- /oscillators/recursive_median_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Recursive Median Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Recursive Median Oscillator", shorttitle="RMO") 5 | 6 | medianLength = input(title="Length", type=integer, minval=1, defval=5) 7 | lowpassLength = input(title="Lowpass Length", type=integer, minval=1, defval=12) 8 | highpassLength = input(title="Highpass Length", type=integer, minval=1, defval=30) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | median(src, length) => 12 | percentile_nearest_rank(src, length, 50) 13 | 14 | PI = 2 * asin(1) 15 | 16 | alpha1Arg = 2 * PI / lowpassLength 17 | alpha1 = (cos(alpha1Arg) + sin(alpha1Arg) - 1) / cos(alpha1Arg) 18 | 19 | rm = 0.0 20 | rm := alpha1 * median(src, medianLength) + (1 - alpha1) * nz(rm[1]) 21 | 22 | alpha2Arg = 1 / sqrt(2) * 2 * PI / highpassLength 23 | alpha2 = (cos(alpha2Arg) + sin(alpha2Arg) - 1) / cos(alpha2Arg) 24 | 25 | rmo = 0.0 26 | rmo := pow(1 - alpha2 / 2, 2) * (rm - 2 * nz(rm[1]) + nz(rm[2])) + 2 * (1 - alpha2) * nz(rmo[1]) - pow(1 - alpha2, 2) * nz(rmo[2]) 27 | 28 | rmoColor = rmo >= 0.0 ? #0ebb23 : #ff0000 29 | 30 | plot(rmo, title="RMO", linewidth=2, color=rmoColor, transp=0) 31 | 32 | hline(0, title="Zero Level", linestyle=dashed, color=#3c78d8) 33 | -------------------------------------------------------------------------------- /oscillators/regression_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Regression Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Regression Oscillator", shorttitle="ROSC") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=63) 7 | linregOffset = input(title="Linear Regression Offset", type=integer, defval=0) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | rosc = 100 * (src / linreg(src, length, linregOffset) - 1) 11 | 12 | roscColor = rosc >= 0.0 ? #0ebb23 : #ff0000 13 | 14 | plot(rosc, title="ROSC", linewidth=2, color=roscColor, transp=0) 15 | 16 | hline(0, title="Zero Level", linestyle=dotted, color=#989898) 17 | -------------------------------------------------------------------------------- /oscillators/relative_momentum_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Relative Momentum Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Relative Momentum Index", shorttitle="RMI") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | momentumLength = input(title="Momentum Length", type=integer, minval=1, defval=3) 8 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | up = rma(max(change(src, momentumLength), 0), length) 12 | down = rma(-min(change(src, momentumLength), 0), length) 13 | 14 | rmi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) 15 | 16 | obLevel = 70 17 | osLevel = 30 18 | 19 | rmiColor = rmi > obLevel ? #0ebb23 : rmi < osLevel ? #ff0000 : #f4b77d 20 | plot(rmi, title="RMI", linewidth=2, color=rmiColor, transp=0) 21 | 22 | transparent = color(white, 100) 23 | 24 | maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent) 25 | obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=dotted) 26 | hline(50, title="Middle Level", linestyle=dotted) 27 | osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=dotted) 28 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 29 | 30 | fill(obLevelPlot, osLevelPlot, color=purple, transp=95) 31 | 32 | obFillColor = rmi > obLevel and highlightBreakouts ? green : transparent 33 | osFillColor = rmi < osLevel and highlightBreakouts ? red : transparent 34 | 35 | fill(maxLevelPlot, obLevelPlot, color=obFillColor, transp=90) 36 | fill(minLevelPlot, osLevelPlot, color=osFillColor, transp=90) 37 | -------------------------------------------------------------------------------- /oscillators/relative_spread_strength.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Relative Spread Strength script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Relative Spread Strength", shorttitle="RSS") 5 | 6 | rsiLength = input(title="RSI Length", type=integer, defval=14, minval=1) 7 | fastLength = input(title="Fast MA Length", type=integer, defval=10, minval=1) 8 | slowLength = input(title="Slow MA Length", type=integer, defval=40, minval=1) 9 | smoothingLength = input(title="Smoothing Length", type=integer, defval=5, minval=1) 10 | smoothingType = input(title="Smoothing Type", defval="EMA", options=["EMA", "SMA"]) 11 | highLevel = input(title="High Level", type=integer, defval=80, maxval=100) 12 | lowLevel = input(title="Low Level", type=integer, defval=20, minval=0) 13 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 14 | src = input(title="Source", type=source, defval=close) 15 | 16 | spread = smoothingType == "EMA" ? ema(src, fastLength) - ema(src, slowLength) : sma(src, fastLength) - sma(src, slowLength) 17 | 18 | rs = rsi(spread, rsiLength) 19 | rss = sma(rs, smoothingLength) 20 | 21 | rssColor = rss > highLevel ? #0ebb23 : rss < lowLevel ? #ff0000 : #f4b77d 22 | plot(rss, title="RSS", linewidth=2, color=rssColor, transp=0) 23 | 24 | transparent = color(white, 100) 25 | 26 | maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent) 27 | highLevelPlot = hline(highLevel, title="High Level", linestyle=dotted) 28 | hline(50, title="Middle Level", linestyle=dotted) 29 | lowLevelPlot = hline(lowLevel, title="Low Level", linestyle=dotted) 30 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 31 | 32 | fill(highLevelPlot, lowLevelPlot, color=purple, transp=95) 33 | 34 | highFillColor = rss > highLevel and highlightBreakouts ? green : transparent 35 | lowFillColor = rss < lowLevel and highlightBreakouts ? red : transparent 36 | 37 | fill(maxLevelPlot, highLevelPlot, color=highFillColor, transp=90) 38 | fill(minLevelPlot, lowLevelPlot, color=lowFillColor, transp=90) 39 | -------------------------------------------------------------------------------- /oscillators/relative_volatility_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Relative Volatility Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Relative Volatility Index", shorttitle="RVI") 5 | 6 | stdevLength = input(title="Standard Deviation Length", type=integer, minval=1, defval=10) 7 | stdevType = input(title="Standard Deviation Type", defval="Population", options=["Population", "Sample"]) 8 | smoothLength = input(title="Smoothing Length", type=integer, minval=1, defval=14) 9 | obLevel = input(title="Overbought Level", type=integer, defval=60) 10 | osLevel = input(title="Oversold Level", type=integer, defval=40) 11 | useRefined = input(title="Use Refined Version of RVI ?", type=bool, defval=true) 12 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 13 | src = input(title="Source", type=source, defval=close) 14 | 15 | sampleStdev(src, length) => 16 | dev = src - sma(src, length) 17 | variance = sum(pow(dev, 2), length) / (length - 1) 18 | sqrt(variance) 19 | 20 | selectedStdev = stdevType == "Population" 21 | ? stdev(src, stdevLength) 22 | : sampleStdev(src, stdevLength) 23 | 24 | // Original version (1993) 25 | rviOriginal(src) => 26 | upSum = ema(change(src) >= 0 ? selectedStdev : 0, smoothLength) 27 | downSum = ema(change(src) >= 0 ? 0 : selectedStdev, smoothLength) 28 | 100 * upSum / (upSum + downSum) 29 | 30 | // Refined version (1995) 31 | rvi = useRefined 32 | ? avg(rviOriginal(high), rviOriginal(low)) 33 | : rviOriginal(src) 34 | 35 | rviColor = rvi > obLevel ? #0ebb23 : rvi < osLevel ? #ff0000 : #f4b77d 36 | plot(rvi, title="RVI", linewidth=2, color=rviColor, transp=0) 37 | 38 | transparent = color(white, 100) 39 | 40 | maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent) 41 | obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=dotted) 42 | hline(50, title="Middle Level", linestyle=dotted) 43 | osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=dotted) 44 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 45 | 46 | fill(obLevelPlot, osLevelPlot, color=purple, transp=95) 47 | 48 | obFillColor = rvi > obLevel and highlightBreakouts ? green : transparent 49 | osFillColor = rvi < osLevel and highlightBreakouts ? red : transparent 50 | 51 | fill(maxLevelPlot, obLevelPlot, color=obFillColor, transp=90) 52 | fill(minLevelPlot, osLevelPlot, color=osFillColor, transp=90) 53 | -------------------------------------------------------------------------------- /oscillators/repulse.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Repulse script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Repulse") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=5) 7 | 8 | bullPower = 100 * (3 * close - 2 * lowest(length) - open[length - 1]) / close 9 | 10 | bearPower = 100 * (open[length - 1] + 2 * highest(length) - 3 * close) / close 11 | 12 | repulse = ema(bullPower, 5 * length) - ema(bearPower, 5 * length) 13 | 14 | repulseColor = repulse >= repulse[1] ? #0ebb23 : red 15 | plot(repulse, title="Repulse", linewidth=2, color=repulseColor, transp=0) 16 | 17 | hline(0, title="Zero Level", linestyle=dotted) 18 | -------------------------------------------------------------------------------- /oscillators/rocket_rsi.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Rocket RSI script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Rocket RSI", shorttitle="Rocket RSI") 5 | 6 | rsiLength = input(title="RSI Length", type=integer, minval=1, defval=10) 7 | smoothingLength = input(title="Smoothing Length", type=integer, minval=1, defval=8) 8 | obosLevel = input(title="Overbought / Oversold Level", type=float, minval=0.0, defval=2.0) 9 | applyNormalization = input(title="Apply Normalization to [-100, 100] values ?", type=bool, defval=false) 10 | src = input(title="Source", type=source, defval=close) 11 | 12 | PI = 2 * asin(1) 13 | 14 | a1 = 0.0 15 | b1 = 0.0 16 | c1 = 0.0 17 | c2 = 0.0 18 | c3 = 0.0 19 | 20 | // Compute Super Smoother coefficients 21 | a1 := exp(-1.414 * PI / smoothingLength) 22 | b1 := 2 * a1 * cos(1.414 * 180 / smoothingLength) 23 | c2 := b1 24 | c3 := -a1 * a1 25 | c1 := 1 - c2 - c3 26 | 27 | // Create half dominant cycle momentum 28 | mom = change(src, rsiLength - 1) 29 | 30 | // Super Smoother Filter 31 | ssf = 0.0 32 | ssf := c1 * (mom + nz(mom[1])) / 2 + c2 * nz(ssf[1]) + c3 * nz(ssf[2]) 33 | 34 | // Accumulate `Closes Up` and `Closes Down` 35 | upSum = sum(change(ssf, 1) > 0 ? change(ssf, 1) : 0.0, rsiLength) 36 | downSum = sum(change(ssf, 1) > 0 ? 0.0 : abs(change(ssf, 1)), rsiLength) 37 | 38 | tmpRSI = 0.0 39 | tmpRSI := upSum + downSum != 0 ? (upSum - downSum) / (upSum + downSum) : nz(tmpRSI[1]) 40 | 41 | // Limit RocketRSI output to +/-3 Standard Deviations 42 | if tmpRSI > 0.999 43 | tmpRSI := 0.999 44 | 45 | if tmpRSI < -0.999 46 | tmpRSI := -0.999 47 | 48 | // Apply Fisher Transform to establish Gaussian Probability Distribution 49 | rocketRSI = 0.5 * log((1 + tmpRSI) / (1 - tmpRSI)) 50 | rocketRSI := applyNormalization ? rocketRSI * 25 : rocketRSI 51 | 52 | overboughtLevel = applyNormalization ? obosLevel * 25 : obosLevel 53 | oversoldLevel = applyNormalization ? obosLevel * -25 : obosLevel * -1 54 | 55 | rocketRSIColor = rocketRSI > overboughtLevel ? green : rocketRSI < oversoldLevel ? red : #ff9370 56 | 57 | plot(rocketRSI, title="RRSI", linewidth=2, color=rocketRSIColor, transp=0) 58 | 59 | plot(overboughtLevel, title="OB Level", style=circles, color=#3d85c6, transp=0) 60 | hline(0, title="Zero Level", linestyle=dotted) 61 | plot(oversoldLevel, title="OS Level", style=circles, color=#3d85c6, transp=0) 62 | -------------------------------------------------------------------------------- /oscillators/self_adjusting_rsi.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Self-Adjusting RSI script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Self-Adjusting RSI", shorttitle="SARSI") 5 | 6 | rsiLength = input(title="RSI Length", type=integer, defval=14, minval=1) 7 | adjusting = input(title="Method of Adjusting OB/OS Levels", defval="Standard Deviation", options=["Standard Deviation", "SMA"]) 8 | mult = input(title="Adjustment Multiplier", type=float, defval=2, step=0.1) 9 | smoothingType = input(title="Smoothing Type", defval="SMA", options=["EMA", "SMA"]) 10 | smoothingLength = input(title="Smoothing Length", type=integer, defval=21, minval=1) 11 | highlightMovements = input(title="Highlight Smoothing ?", type=bool, defval=false) 12 | src = input(title="Source", type=source, defval=close) 13 | 14 | rsi = rsi(src, rsiLength) 15 | 16 | _adjusting() => 17 | adjusting == "Standard Deviation" ? mult * stdev(rsi, rsiLength) : 18 | adjusting == "SMA" ? mult * sma(abs(rsi - sma(rsi, rsiLength)), rsiLength) : 19 | na 20 | 21 | adjust = _adjusting() 22 | obLevel = 50 + adjust 23 | osLevel = 50 - adjust 24 | 25 | hline(50, title="Middle Level", linestyle=dotted) 26 | transparent = color(white, 100) 27 | 28 | rsiColor = rsi > obLevel ? #0ebb23 : rsi < osLevel ? red : #f4b77d 29 | rsiPlot = plot(rsi, title="SARSI", linewidth=1, color=rsiColor, transp=0) 30 | 31 | smooth = smoothingType == "EMA" ? ema(rsi, smoothingLength) : sma(rsi, smoothingLength) 32 | smoothColor = highlightMovements ? (smooth > smooth[1] ? #0ebb23 : red) : #6d1e7f 33 | plot(smooth, title="Smooth", linewidth=1, color=smoothColor, transp=0) 34 | 35 | obosColor = #f1bc05 //#7b1fa2 36 | obLevelPlot = plot(obLevel, title="OB", color=obosColor, transp=100) 37 | osLevelPlot = plot(osLevel, title="OS", color=obosColor, transp=100) 38 | fill(obLevelPlot, osLevelPlot, title="OB/OS Filling", color=#f1bc05, transp=80) 39 | 40 | obFillColor = rsi > obLevel ? green : transparent 41 | fill(rsiPlot, obLevelPlot, title="SARSI/OB Filling", color=obFillColor, transp=85) 42 | 43 | osFillColor = rsi < osLevel ? red : transparent 44 | fill(rsiPlot, osLevelPlot, title="SARSI/OS Filling", color=osFillColor, transp=85) 45 | 46 | co = crossover(rsi, obLevel) 47 | cu = crossunder(rsi, osLevel) 48 | 49 | alertcondition(co, title="Alert on SARSI Overbought", message="SARSI Overbought!") 50 | alertcondition(cu, title="Alert on SARSI Oversold", message="SARSI Oversold!") 51 | -------------------------------------------------------------------------------- /oscillators/smoothed_rate_of_change.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Smoothed Rate of Change script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Smoothed Rate of Change", shorttitle="S-RoC") 5 | 6 | rocLength = input(title="ROC Length", type=integer, minval=1, defval=21) 7 | smoothingLength = input(title="Smoothing Length", type=integer, minval=1, defval=13) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | ma = ema(src, smoothingLength) 11 | 12 | sroc = nz(ma[rocLength]) == 0 13 | ? 100 14 | : ma - nz(ma[rocLength]) == 0 15 | ? 0 16 | : 100 * (ma - nz(ma[rocLength])) / ma[rocLength] 17 | 18 | srocColor = sroc >= 0.0 ? #0ebb23 : #ff0000 19 | 20 | plot(sroc, title="S-RoC", linewidth=2, color=srocColor, transp=0) 21 | 22 | hline(0, title="Zero Level", linestyle=dotted, color=#989898) 23 | -------------------------------------------------------------------------------- /oscillators/stiffness_indicator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Stiffness Indicator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Stiffness Indicator", shorttitle="Stiffness") 5 | 6 | maLength = input(title="Moving Average Length", minval=1, defval=100) 7 | stiffLength = input(title="Stiffness Length", minval=1, defval=60) 8 | stiffSmooth = input(title="Stiffness Smoothing Length", minval=1, defval=3) 9 | threshold = input(title="Threshold", minval=1, defval=90) 10 | highlightThresholdCrossovers = input(title="Highlight Threshold Crossovers ?", type=bool, defval=false) 11 | 12 | bound = sma(close, maLength) - 0.2 * stdev(close, maLength) 13 | sumAbove = sum(close > bound ? 1 : 0, stiffLength) 14 | stiffness = ema(sumAbove * 100 / stiffLength, stiffSmooth) 15 | 16 | transparent = color(white, 100) 17 | 18 | bgColor = highlightThresholdCrossovers ? (stiffness > threshold ? #0ebb23 : red) : transparent 19 | bgcolor(bgColor, transp=90) 20 | 21 | plot(stiffness, title="Stiffness", style=histogram, color=#f5c75e, transp=0) 22 | plot(threshold, title="Threshold", color=red, transp=0) 23 | -------------------------------------------------------------------------------- /oscillators/stochastic_connors_rsi.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2017-present, Alex Orekhov (everget) 3 | // Stochastic Connors RSI indicator script may be freely distributed under the terms of GPL-3.0 license. 4 | study(title="Stochastic Connors RSI", shorttitle="Stoch CRSI") 5 | 6 | stochLength = input(title="Stochastic Length", type=integer, defval=3, minval=1) 7 | smoothK = input(title="K", type=integer, defval=3, minval=1, maxval=10000) 8 | smoothD = input(title="D", type=integer, defval=3, minval=1, maxval=10000) 9 | 10 | rsiLength = input(title="RSI Length", type=integer, defval=3, minval=1) 11 | updownLength = input(title="Updown RSI Length", type=integer, defval=2, minval=1) 12 | rocLength = input(title="ROC Length", type=integer, defval=100, minval=1) 13 | src = input(title="RSI Source", type=source, defval=close) 14 | 15 | updown = 0 16 | updown_calc(s, ud) => 17 | newupdown = 0 18 | if s > s[1] 19 | newupdown := nz(ud[1]) >= 0 ? nz(ud[1]) + 1 : 1 20 | else 21 | if s < s[1] 22 | newupdown := nz(ud[1]) <= 0 ? nz(ud[1]) - 1 : -1 23 | else 24 | newupdown := 0 25 | 26 | updown := updown_calc(src, updown) 27 | 28 | updownrsi = rsi(updown, updownLength) 29 | 30 | rsi = rsi(src, rsiLength) 31 | 32 | percentrank = percentrank(roc(src, 1), rocLength) 33 | 34 | crsi = avg(rsi, updownrsi, percentrank) 35 | 36 | stochcalc = stoch(crsi, crsi, crsi, stochLength) 37 | 38 | band1 = hline(80, color=gray, linestyle=dashed) 39 | band2 = hline(20, color=gray, linestyle=dashed) 40 | fill(band1, band2, color=#f9cb9c0f) 41 | 42 | band3 = hline(70, color=gray, linestyle=dashed) 43 | band4 = hline(30, color=gray, linestyle=dashed) 44 | fill(band3, band4, color=#de9ba6) 45 | 46 | smaK = sma(stochcalc, smoothK) 47 | smaD = sma(smaK, smoothD) 48 | 49 | plot(smaK, title="K", color=#0094ff) 50 | plot(smaD, title="D", color=#ff6a00) 51 | -------------------------------------------------------------------------------- /oscillators/stochastic_momentum_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Stochastic Momentum Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Stochastic Momentum Index", shorttitle="SMI") 5 | 6 | q = input(title="Length (Stochastic Lookback)", type=integer, minval=1, defval=13) 7 | r = input(title="First Smoothing Length", type=integer, minval=1, defval=25) 8 | s = input(title="Second Smoothing Length", type=integer, minval=1, defval=2) 9 | signalLength = input(title="Signal Length", type=integer, minval=1, defval=12) 10 | overboughtLevel = input(title="Overbought Level", type=integer, defval=40) 11 | oversoldLevel = input(title="Oversold Level", type=integer, defval=-40) 12 | applyFilling = input(title="Apply Filling ?", type=bool, defval=false) 13 | src = input(title="Source", type=source, defval=close) 14 | 15 | hhq = highest(high, q) 16 | llq = lowest(low, q) 17 | 18 | numerator = ema(ema(src - 0.5 * (hhq + llq), r), s) 19 | 20 | denominator = 0.5 * ema(ema(hhq - llq, r), s) 21 | 22 | smi = 100 * numerator / denominator 23 | 24 | signal = ema(smi, signalLength) 25 | 26 | smiPlot = plot(smi, title="SMI", color=#ff3e7d, transp=0) 27 | signalPlot = plot(signal, title="Signal", color=#3c78d8, transp=0) 28 | 29 | overbought = hline(title="Overbought Level", price=overboughtLevel, linestyle=dotted, color=#e69138) 30 | hline(title="Zero Level", price=0, linestyle=dashed, color=#989898) 31 | oversold = hline(title="Oversold Level", price=oversoldLevel, linestyle=dotted, color=#e69138) 32 | 33 | fillColor = applyFilling ? (smi > signal ? #0ebb23 : #cc0000) : color(white, 100) 34 | fill(smiPlot, signalPlot, color=fillColor, transp=0) 35 | -------------------------------------------------------------------------------- /oscillators/tick_line_momentum_oscillator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Tick Line Momentum Oscillator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Tick Line Momentum Oscillator", shorttitle="TLMO") 5 | 6 | cumoMALength = input(title="Cumo MA Length", type=integer, minval=1, defval=10) 7 | cumoMAInput = input(title="Cumo MA", defval="EMA", options=["EMA", "SMA", "VWMA", "WMA"]) 8 | rocLength = input(title="ROC Length", type=integer, minval=1, defval=5) 9 | smoothingLength = input(title="Smoothing Length", type=integer, minval=1, defval=5) 10 | smoothingMAInput = input(title="Smoothing MA", defval="EMA", options=["EMA", "SMA", "VWMA", "WMA"]) 11 | obosLevel = input(title="Overbought / Oversold Level", type=integer, minval=1, defval=5) 12 | src = input(title="Source", type=source, defval=close) 13 | 14 | cumoMA = iff(cumoMAInput == "EMA", ema(src, cumoMALength), 15 | iff(cumoMAInput == "SMA", sma(src, cumoMALength), 16 | iff(cumoMAInput == "VWMA", vwma(src, cumoMALength), 17 | iff(cumoMAInput == "WMA", wma(src, cumoMALength), 18 | na)))) 19 | 20 | cumoExpression = src > nz(cumoMA[1]) 21 | ? 1 22 | : src < nz(cumoMA[1]) 23 | ? -1 24 | : 0 25 | 26 | tlmo = iff(smoothingMAInput == "EMA", ema(roc(cum(cumoExpression), rocLength), smoothingLength), 27 | iff(smoothingMAInput == "SMA", sma(roc(cum(cumoExpression), rocLength), smoothingLength), 28 | iff(smoothingMAInput == "VWMA", vwma(roc(cum(cumoExpression), rocLength), smoothingLength), 29 | iff(smoothingMAInput == "WMA", wma(roc(cum(cumoExpression), rocLength), smoothingLength), 30 | na)))) 31 | 32 | tlmoColor = tlmo > obosLevel ? #0ebb23 : tlmo < -obosLevel ? #ff0000 : #674ea7 33 | plot(tlmo, title="TLMO", linewidth=2, color=tlmoColor, transp=0) 34 | 35 | hline(obosLevel, title="Overbought", linestyle=dotted, color=#0ebb23) 36 | hline(0, title="Zero Level", linestyle=solid, color=#f6b26b) 37 | hline(-1 * obosLevel, title="Oversold", linestyle=dotted, color=#ff0000) 38 | -------------------------------------------------------------------------------- /oscillators/total_power_indicator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Total Power Indicator script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Total Power Indicator", shorttitle="TPI") 5 | 6 | length = input(title="Length", type=integer, defval=45) 7 | powersLength = input(title="Elder Powers Length", type=integer, defval=10) 8 | adjustableLevel = input(title="Adjustable Entry Level", type=integer, defval=75) 9 | applyFilling = input(title="Apply Powers Filling ?", type=bool, defval=false) 10 | 11 | elderBullPower = high - ema(close, powersLength) 12 | elderBearPower = low - ema(close, powersLength) 13 | 14 | adjust(value) => 100 * value / length 15 | 16 | bullCount = sum(elderBullPower > 0 ? 1 : 0, length) 17 | bearCount = sum(elderBearPower < 0 ? 1 : 0, length) 18 | total = adjust(abs(bullCount - bearCount)) 19 | bull = adjust(bullCount) 20 | bear = adjust(bearCount) 21 | 22 | bullPlot = plot(bull, title="Bull", linewidth=2, color=#0ebb23, transp=0) 23 | bearPlot = plot(bear, title="Bear", linewidth=2, color=red, transp=0) 24 | plot(total, title="Total", linewidth=2, color=#3c78d8, transp=0) 25 | 26 | fillColor = applyFilling ? (bull > bear ? #0ebb23 : red) : color(white, 100) 27 | fill(bullPlot, bearPlot, color=fillColor, transp=80) 28 | 29 | hline(adjustableLevel, title="Adjustable Entry Level", linestyle=dotted) 30 | hline(50, title="Middle Level", linestyle=dotted, color=#f49517) 31 | -------------------------------------------------------------------------------- /oscillators/trend_continuation_factor.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Trend Continuation Factor script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Trend Continuation Factor", shorttitle="TCF") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=35) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | plusChange(src) => change(src) > 0 ? change(src) : 0.0 10 | minusChange(src) => change(src) > 0 ? 0.0 : -change(src) 11 | 12 | plusCF = 0.0 13 | plusCF := plusChange(src) == 0 ? 0.0 : plusChange(src) + nz(plusCF[1]) 14 | 15 | minusCF = 0.0 16 | minusCF := minusChange(src) == 0 ? 0.0 : minusChange(src) + nz(minusCF[1]) 17 | 18 | plusTCF = sum(plusChange(src) - minusCF, length) 19 | minusTCF = sum(minusChange(src) - plusCF, length) 20 | 21 | plot(plusTCF, title="+TCF", linewidth=2, color=#38761d, transp=0) 22 | plot(minusTCF, title="-TCF", linewidth=2, color=#cc4125, transp=0) 23 | 24 | hline(0, title="Zero Level", linestyle=line, color=#e69138) 25 | -------------------------------------------------------------------------------- /oscillators/trend_detection_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Trend Detection Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Trend Detection Index", shorttitle="TDI") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=20) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | momentum = change(src, length) 10 | 11 | tdi = abs(sum(momentum, length)) - (sum(abs(momentum), length * 2) - sum(abs(momentum), length)) 12 | 13 | // Direction Indicator 14 | direction = sum(momentum, length) 15 | 16 | plot(tdi, title="TDI", color=#ff0000, transp=0) 17 | plot(direction, title="Direction", color=#0ebb23, transp=0) 18 | 19 | hline(0, title="Zero Level", linestyle=dotted) 20 | -------------------------------------------------------------------------------- /oscillators/trend_intensity_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Trend Intensity Index script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Trend Intensity Index", shorttitle="TII") 5 | 6 | majorLength = input(title="Major Length", type=integer, defval=60) 7 | minorLength = input(title="Minor Length", type=integer, defval=30) 8 | upperLevel = input(title="Upper Level", type=integer, defval=80) 9 | lowerLevel = input(title="Lower Level", type=integer, defval=20) 10 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 11 | src = input(title="Source", type=source, defval=close) 12 | 13 | sma = sma(src, majorLength) 14 | 15 | positiveSum = 0.0 16 | negativeSum = 0.0 17 | 18 | for i = 0 to minorLength - 1 19 | price = nz(src[i]) 20 | avg = nz(sma[i]) 21 | positiveSum := positiveSum + (price > avg ? price - avg : 0) 22 | negativeSum := negativeSum + (price > avg ? 0 : avg - price) 23 | 24 | tii = 100 * positiveSum / (positiveSum + negativeSum) 25 | 26 | tiiColor = tii > upperLevel ? #0ebb23 : tii < lowerLevel ? #ff0000 : #f4b77d 27 | plot(tii, title="TII", linewidth=2, color=tiiColor, transp=0) 28 | 29 | transparent = color(white, 100) 30 | 31 | maxLevelPlot = hline(100, title="Max Level", linestyle=dotted, color=transparent) 32 | upperLevelPlot = hline(upperLevel, title="Upper Level", linestyle=dotted) 33 | hline(50, title="Middle Level", linestyle=dotted) 34 | lowerLevelPlot = hline(lowerLevel, title="Lower Level", linestyle=dotted) 35 | minLevelPlot = hline(0, title="Min Level", linestyle=dotted, color=transparent) 36 | 37 | fill(upperLevelPlot, lowerLevelPlot, color=purple, transp=95) 38 | 39 | upperFillColor = tii > upperLevel and highlightBreakouts ? green : transparent 40 | lowerFillColor = tii < lowerLevel and highlightBreakouts ? red : transparent 41 | 42 | fill(maxLevelPlot, upperLevelPlot, color=upperFillColor, transp=90) 43 | fill(minLevelPlot, lowerLevelPlot, color=lowerFillColor, transp=90) 44 | 45 | -------------------------------------------------------------------------------- /oscillators/trend_trigger_factor.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Trend Trigger Factor script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Trend Trigger Factor", shorttitle="TTF") 5 | 6 | length = input(title="Lookback Length", type=integer, defval=15) 7 | upperLevel = input(title="Upper Trigger Level", type=integer, defval=100, minval=1) 8 | lowerLevel = input(title="Lower Trigger Level", type=integer, defval=-100, maxval=-1) 9 | highlightBreakouts = input(title="Highlight Overbought/Oversold Breakouts ?", type=bool, defval=true) 10 | src = input(title="Source", type=source, defval=close) 11 | 12 | hh = highest(length) 13 | ll = lowest(length) 14 | 15 | buyPower = hh - nz(ll[length]) 16 | sellPower = nz(hh[length]) - ll 17 | 18 | ttf = 200 * (buyPower - sellPower) / (buyPower + sellPower) 19 | 20 | ttfColor = ttf > upperLevel ? #0ebb23 : ttf < lowerLevel ? #ff0000 : #f4b77d 21 | plot(ttf, title="TTF", linewidth=2, color=ttfColor, transp=0) 22 | 23 | transparent = color(white, 100) 24 | 25 | maxLevelPlot = hline(200, title="Max Level", linestyle=dotted, color=transparent) 26 | upperLevelPlot = hline(upperLevel, title="Upper Trigger Level", linestyle=dotted) 27 | hline(0, title="Zero Level", linestyle=dotted) 28 | lowerLevelPlot = hline(lowerLevel, title="Lower Trigger Level", linestyle=dotted) 29 | minLevelPlot = hline(-200, title="Min Level", linestyle=dotted, color=transparent) 30 | 31 | fill(upperLevelPlot, lowerLevelPlot, color=purple, transp=95) 32 | 33 | upperFillColor = ttf > upperLevel and highlightBreakouts ? green : transparent 34 | lowerFillColor = ttf < lowerLevel and highlightBreakouts ? red : transparent 35 | 36 | fill(maxLevelPlot, upperLevelPlot, color=upperFillColor, transp=90) 37 | fill(minLevelPlot, lowerLevelPlot, color=lowerFillColor, transp=90) 38 | -------------------------------------------------------------------------------- /oscillators/trendscore.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Trendscore script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Trendscore", shorttitle="Trendscore") 5 | 6 | fromIndex = input(title="From", type=integer, minval=1, defval=11) 7 | toIndex = input(title="To", type=integer, minval=1, defval=20) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | trendscore(src, fromIndex, toIndex) => 11 | sum = 0.0 12 | 13 | for i = fromIndex to toIndex 14 | sum := src >= nz(src[i]) ? sum + 1 : sum - 1 15 | sum 16 | 17 | plot(trendscore(src, fromIndex, toIndex), title="Trendscore", linewidth=2, color=#e69138, transp=0) 18 | -------------------------------------------------------------------------------- /oscillators/trix.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // TRIX script may be freely distributed under the terms of GPL-3.0 license. 4 | study("TRIX") 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | mult = input(title="TRIX Value Multiplier", type=integer, defval=1) 8 | signalType = input(title="Signal Smoothing Type", defval="SMA", options=["EMA", "SMA"]) 9 | signalLength = input(title="Signal Smoothing Length", type=integer, defval=9) 10 | src = input(title="Source", type=source, defval=close) 11 | showSignal = input(title="Show Signal Line ?", type=bool, defval=true) 12 | showHistogram = input(title="Show Histogram ?", type=bool, defval=false) 13 | highlightCrossovers = input(title="Highlight TRIX/Signal Crossovers ?", type=bool, defval=true) 14 | highlightZeroCrossovers = input(title="Highlight Zero Line Crossovers ?", type=bool, defval=false) 15 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=false) 16 | 17 | triple = ema(ema(ema(src, length), length), length) 18 | 19 | trix = mult * roc(triple, 1) 20 | signal = signalType == "SMA" ? sma(trix, signalLength) : ema(trix, signalLength) 21 | 22 | hist = trix - signal 23 | histColor = hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #EF5350) 24 | plot(showHistogram ? hist : na, title="Histogram", style=columns, color=histColor, transp=0) 25 | hline(0, title="Zero Level", linestyle=dotted) 26 | 27 | trendColor = trix > signal ? #0ebb23 : red 28 | 29 | trixColor = applyFilling ? trendColor : (trix > 0 ? #0ebb23 : red) 30 | signalColor = applyFilling ? trendColor : #ff9800 31 | 32 | trixPlot = plot(trix, title="TRIX", linewidth=2, color=trixColor, transp=0) 33 | signalPlot = plot(showSignal ? signal : na, title="Signal", color=signalColor, transp=0) 34 | 35 | transparent = color(white, 100) 36 | 37 | fillColor = applyFilling ? trendColor : transparent 38 | fill(trixPlot, signalPlot, color=fillColor, transp=70) 39 | 40 | zeroCrossBgColor = highlightZeroCrossovers ? (trix > 0 ? green : red) : transparent 41 | bgcolor(zeroCrossBgColor, transp=90) 42 | 43 | plotshape(highlightCrossovers and crossover(trix, signal) ? trix : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 44 | plotshape(highlightCrossovers and crossunder(trix, signal) ? trix : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 45 | -------------------------------------------------------------------------------- /oscillators/true_range_double.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // True Range Double script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("True Range Double", shorttitle="TRD") 5 | 6 | trd = max(max(high, high[1]), close[2]) - min(min(low, low[1]), close[2]) 7 | 8 | plot(trd, title="TRD", linewidth=1, color=#741b47, transp=0) 9 | -------------------------------------------------------------------------------- /oscillators/v_macd.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // V-MACD script may be freely distributed under the terms of GPL-3.0 license. 4 | study("V-MACD") 5 | 6 | fastLength = input(title="Fast Length", type=integer, defval=12) 7 | slowLength = input(title="Slow Length", type=integer, defval=26) 8 | signalLength = input(title="Signal Length", type=integer, defval=9) 9 | showHistogram = input(title="Show Histogram ?", type=bool, defval=true) 10 | highlightCrossovers = input(title="Highlight V-MACD/Signal Crossovers ?", type=bool, defval=false) 11 | highlightZeroCrossovers = input(title="Highlight Zero Line Crossovers ?", type=bool, defval=false) 12 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=false) 13 | 14 | [vmacd, signal, hist] = macd(volume, fastLength, slowLength, signalLength) 15 | 16 | histColor = hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #EF5350) 17 | 18 | plot(showHistogram ? hist : na, title="Histogram", style=columns, color=histColor, transp=0) 19 | hline(0, title="Zero Line", linestyle=dotted) 20 | 21 | trendColor = vmacd > signal ? #0ebb23 : red 22 | 23 | vmacdColor = applyFilling ? trendColor : #0094ff 24 | signalColor = applyFilling ? trendColor : #ff6a00 25 | 26 | vmacdPlot = plot(vmacd, title="V-MACD", color=vmacdColor, transp=0) 27 | signalPlot = plot(signal, title="Signal", color=signalColor, transp=0) 28 | 29 | transparent = color(white, 100) 30 | 31 | fillColor = applyFilling ? trendColor : transparent 32 | fill(vmacdPlot, signalPlot, color=fillColor, transp=70) 33 | 34 | zeroCrossBgColor = highlightZeroCrossovers ? (vmacd > 0 ? green : red) : transparent 35 | bgcolor(zeroCrossBgColor, transp=90) 36 | 37 | plotshape(highlightCrossovers and crossover(vmacd, signal) ? vmacd : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 38 | plotshape(highlightCrossovers and crossunder(vmacd, signal) ? vmacd : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 39 | -------------------------------------------------------------------------------- /oscillators/vertical_horizontal_filter.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Vertical Horizontal Filter script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Vertical Horizontal Filter", shorttitle="VHF") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=28) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | vhf = abs(highest(src, length) - lowest(src, length)) / sum(abs(change(src)), length) 10 | 11 | plot(vhf, title="VHF", color=#674ea7, transp=0) 12 | -------------------------------------------------------------------------------- /oscillators/vw_macd.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // VW-MACD script may be freely distributed under the terms of GPL-3.0 license. 4 | study("VW-MACD") 5 | 6 | fastLength = input(title="Fast Length", type=integer, defval=12) 7 | slowLength = input(title="Slow Length", type=integer, defval=26) 8 | signalLength = input(title="Signal Length", type=integer, defval=9) 9 | showHistogram = input(title="Show Histogram ?", type=bool, defval=true) 10 | highlightCrossovers = input(title="Highlight VW-MACD/Signal Crossovers ?", type=bool, defval=false) 11 | highlightZeroCrossovers = input(title="Highlight Zero Line Crossovers ?", type=bool, defval=false) 12 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=false) 13 | 14 | vwmacd = vwma(close, fastLength) - vwma(close, slowLength) 15 | signal = ema(vwmacd, signalLength) 16 | hist = vwmacd - signal 17 | 18 | histColor = hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #EF5350) 19 | 20 | plot(showHistogram ? hist : na, title="Histogram", style=columns, color=histColor, transp=0) 21 | hline(0, title="Zero Line", linestyle=dotted) 22 | 23 | trendColor = vwmacd > signal ? #0ebb23 : red 24 | 25 | vwmacdColor = applyFilling ? trendColor : #0094ff 26 | signalColor = applyFilling ? trendColor : #ff6a00 27 | 28 | vwmacdPlot = plot(vwmacd, title="VW-MACD", color=vwmacdColor, transp=0) 29 | signalPlot = plot(signal, title="Signal", color=signalColor, transp=0) 30 | 31 | transparent = color(white, 100) 32 | 33 | fillColor = applyFilling ? trendColor : transparent 34 | fill(vwmacdPlot, signalPlot, color=fillColor, transp=70) 35 | 36 | zeroCrossBgColor = highlightZeroCrossovers ? (vwmacd > 0 ? green : red) : transparent 37 | bgcolor(zeroCrossBgColor, transp=90) 38 | 39 | plotshape(highlightCrossovers and crossover(vwmacd, signal) ? vwmacd : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 40 | plotshape(highlightCrossovers and crossunder(vwmacd, signal) ? vwmacd : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 41 | -------------------------------------------------------------------------------- /research/custom_median_vs_built_in_median.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Custom Median vs Built-in Median script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Custom Median vs Built-in Median", shorttitle="CMvsBM") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | src = input(title="Source", type=source, defval=close) 8 | 9 | // Built-in Median 10 | median(src, length) => 11 | percentile_nearest_rank(src, length, 50) 12 | 13 | sort(src, length, i) => 14 | min = -10000.0 15 | 16 | for j = 0 to i 17 | min_local = 10000.0 18 | 19 | for l = 0 to length - 1 20 | if (nz(src[l]) <= min) 21 | continue 22 | 23 | min_local := min(min_local, max(min, nz(src[l]))) 24 | 25 | if min_local != 10000 26 | min := min_local 27 | min 28 | 29 | // Custom Median 30 | customMedian(src, length) => 31 | out = 0.0 32 | 33 | if length % 2 == 0 34 | out := (sort(src, length, length / 2 - 1) + sort(src, length, length / 2)) / 2 35 | else 36 | out := sort(src, length, length / 2 - 0.5) 37 | out 38 | 39 | diff = median(src, length) - customMedian(src, length) 40 | 41 | plot(diff, title="CMvsBM", transp=0) 42 | -------------------------------------------------------------------------------- /research/dashed_line_style.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Dashed Line Style script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Dashed Line Style", overlay=true) 5 | 6 | sma = sma(close, 14) 7 | 8 | plot(n % 3 != 0 ? sma : na, style=linebr, linewidth=3, color=black, transp=0) 9 | -------------------------------------------------------------------------------- /research/heikin_ashi_chart_identifier.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Heikin-Ashi Chart Identifier script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Heikin-Ashi Chart Identifier", overlay=true) 5 | 6 | var int gapsCount = -1 7 | gapsCount := low[1] > high or high[1] < low ? gapsCount + 1 : gapsCount 8 | 9 | var int matchedCandles = -1 10 | matchedCandles := open == (open[1] + close[1]) / 2 ? matchedCandles + 1 : matchedCandles 11 | 12 | isHA = matchedCandles == bar_index - 1 and matchedCandles != -1 and gapsCount == -1 13 | 14 | labelText = isHA ? "This is Heikin-Ashi Chart" : "This is not Heikin-Ashi Chart" 15 | stats = "\n------------------------------------" + 16 | "\nBar Index: " + tostring(int(bar_index)) + 17 | "\nMatched: " + tostring(matchedCandles) 18 | 19 | labelColor = #1e90ff 20 | whiteColor = color.white 21 | 22 | var label l = label.new( 23 | x=bar_index, 24 | y=na, 25 | text="", 26 | color=labelColor, 27 | textcolor=whiteColor, 28 | style=label.style_labeldown, 29 | size=size.normal 30 | ) 31 | 32 | label.set_text(l, labelText + stats) 33 | label.set_xy(l, bar_index, highest(high, 50)) 34 | -------------------------------------------------------------------------------- /research/kagi_chart_identifier.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Kagi Chart Identifier script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Kagi Chart Identifier", overlay=true) 5 | 6 | var ocCount = -1 7 | if open[1] == close or close[1] == open 8 | ocCount := ocCount + 1 9 | 10 | var hCount = -1 11 | if open == high or close == high 12 | hCount := hCount + 1 13 | 14 | var lCount = -1 15 | if open == low or close == low 16 | lCount := lCount + 1 17 | 18 | isKagi = hCount == bar_index and lCount == bar_index and ocCount == bar_index - 1 19 | 20 | labelText = isKagi ? "This is Kagi Chart" : "This is not Kagi Chart" 21 | stats = "\n------------------------------" + 22 | "\nBar Index: " + tostring(int(bar_index)) + 23 | "\nO==C Candles: " + tostring(ocCount) + 24 | "\nOC==H Candles: " + tostring(hCount) + 25 | "\nOC==L Candles: " + tostring(lCount) 26 | labelColor = #1e90ff 27 | whiteColor = color.white 28 | 29 | var label kagiLabel = label.new( 30 | x=bar_index, 31 | y=na, 32 | text="", 33 | color=labelColor, 34 | textcolor=whiteColor, 35 | style=label.style_labeldown, 36 | size=size.normal 37 | ) 38 | 39 | label.set_text(kagiLabel, labelText + stats) 40 | label.set_xy(kagiLabel, bar_index, highest(close, 10)) 41 | -------------------------------------------------------------------------------- /research/litecoin_halving_utc_countdown.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Litecoin Halving UTC Countdown script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Litecoin Halving UTC Countdown", overlay=true) 5 | 6 | halvingDay = input(title="Halving Day", minval=1, maxval=31, defval=5) 7 | halvingHour = input(title="Halving Hour", minval=1, maxval=24, defval=11) 8 | halvingMinute = input(title="Halving Minute", minval=1, maxval=60, defval=55) 9 | 10 | halvingStamp = timestamp('GMT', 2019, 8, halvingDay, halvingHour, halvingMinute) 11 | 12 | secondsRaw = floor((halvingStamp - timenow) / 1000) 13 | minutesRaw = floor(secondsRaw / 60) 14 | hoursRaw = floor(minutesRaw / 60) 15 | 16 | seconds = secondsRaw % 60 17 | minutes = minutesRaw % 60 18 | hours = hoursRaw % 24 19 | days = floor(hoursRaw / 24) 20 | 21 | f_format(_val) => 22 | (0 < _val and _val < 10 ? "0" : "") + tostring(_val, "##") + (_val == 0 ? "0" : "") 23 | 24 | labelText = f_format(days) + "d " + f_format(hours) + ":" + f_format(minutes) + ":" + f_format(seconds) 25 | 26 | var label l = label.new( 27 | x=bar_index, 28 | y=na, 29 | text="", 30 | textcolor=color.black, 31 | style=label.style_none, 32 | size=size.huge 33 | ) 34 | 35 | label.set_text(l, labelText) 36 | label.set_xy(l, bar_index, highest(100)) 37 | -------------------------------------------------------------------------------- /research/mean_absolute_deviation.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Mean Absolute Deviation script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Mean Absolute Deviation", shorttitle="MAD") 5 | 6 | src = close 7 | len = 14 8 | 9 | sma = sma(src, len) 10 | 11 | median(src, length) => 12 | percentile_nearest_rank(src, length, 50) 13 | 14 | dev0 = dev(src, len) 15 | dev1 = src - sma 16 | dev2 = sum(abs(src - sma), len) / len 17 | dev3 = abs(src - sma) / len 18 | dev4 = (src - sma) / len 19 | dev5 = median(src - median(src, len), len) 20 | 21 | sum = 0.0 22 | for i = 0 to len - 1 23 | sum := sum + abs(src[i] - sma) 24 | 25 | dev6 = sum / len 26 | 27 | plot(dev0, title="Built-in", color=purple) 28 | plot(dev1, title="1", color=olive) 29 | plot(dev2, title="2", color=teal) 30 | plot(dev3, title="3", color=green) 31 | plot(dev4, title="4", color=red) 32 | plot(dev5, title="5", color=blue) 33 | plot(dev6, title="6", color=orange) 34 | -------------------------------------------------------------------------------- /research/momentum.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Momentum script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Momentum") 5 | 6 | src = close 7 | length = 7 8 | 9 | mom = src - src[length] 10 | 11 | mom2 = change(src, length) 12 | 13 | mom3 = mom(src, length) 14 | 15 | sma = sma(src, length) 16 | mom4 = (sma - sma[1]) * length 17 | 18 | plot(mom, title="Simple", color=blue) 19 | plot(mom2, title="2", color=green) 20 | plot(mom3, title="3", color=red) 21 | plot(mom4, title="4", color=purple) 22 | -------------------------------------------------------------------------------- /research/percentrank_bug.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Percentrank Bug script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Percentrank Bug") 5 | 6 | src = volume 7 | length = input(14) 8 | 9 | pr = percentrank(src, length) 10 | plot(pr, title="Built-in", color=red) 11 | 12 | _percentrank(src, length) => 13 | count = 0 14 | for i = 1 to length 15 | count := count + (src >= nz(src[i]) ? 1 : 0) 16 | pr = 100 * count / length 17 | 18 | pr2 = _percentrank(src, length) 19 | 20 | plot(pr2, title="Shim", color=green) 21 | -------------------------------------------------------------------------------- /research/point_and_figure_pnf_chart_identifier.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2020-present, Alex Orekhov (everget) 3 | // Point-and-Figure (P&F) Chart Identifier script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Point-and-Figure (P&F) Chart Identifier", overlay=true) 5 | 6 | var int ocCount = -1 7 | ocCount := open[1] == close or close[1] == open ? ocCount + 1 : ocCount 8 | 9 | var int sum = 0 10 | sum := close > close[1] ? sum + 1 : close < close[1] ? sum - 1 : sum 11 | 12 | isPnF = (sum == 1 or sum == 0 or sum == -1) and ocCount < bar_index - 1 13 | matchedCandles = cum(isPnF ? 1 : 0) 14 | 15 | labelText = isPnF ? "This is P&F Chart" : "This is not P&F Chart" 16 | stats = "\n------------------------------" + 17 | "\nBar Index: " + tostring(int(bar_index)) + 18 | "\nMatched Candles: " + tostring(matchedCandles) + 19 | "\nO==C: " + tostring(ocCount) + 20 | "\nSum: " + tostring(sum) 21 | labelColor = #1e90ff 22 | whiteColor = color.white 23 | 24 | var label pnfLabel = label.new( 25 | x=bar_index, 26 | y=na, 27 | text="", 28 | color=labelColor, 29 | textcolor=whiteColor, 30 | style=label.style_label_down, 31 | size=size.normal 32 | ) 33 | 34 | label.set_text(pnfLabel, labelText + stats) 35 | label.set_xy(pnfLabel, bar_index, highest(close, 10)) 36 | -------------------------------------------------------------------------------- /research/rate_of_change.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Rate of Change script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Rate of Change", shorttitle="ROC") 5 | 6 | src = close 7 | length = 7 8 | 9 | roc = roc(src, length) 10 | 11 | roc2 = change(src, length) 12 | 13 | roc3 = change(src, length) / src[length] 14 | 15 | roc4 = 100 * change(src, length) / src[length] 16 | 17 | plot(roc, title="Built-in", color=blue) 18 | plot(roc2, title="2", color=green) 19 | plot(roc3, title="3", color=red) 20 | plot(roc4, title="4", color=purple) 21 | -------------------------------------------------------------------------------- /research/renko_chart_identifier.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Renko Chart Identifier script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Renko Chart Identifier", overlay=true) 5 | 6 | _isRenko() => 7 | var int gapsCount = -1 8 | if low[1] > high or high[1] < low 9 | gapsCount := gapsCount + 1 10 | body = abs(close - open) 11 | bodySum = cum(body) 12 | avg = bodySum / (bar_index + 1) 13 | out = avg == body and gapsCount == -1 14 | out 15 | 16 | labelText = _isRenko() ? "This is Renko Chart" : "This is not Renko Chart" 17 | labelColor = #1e90ff 18 | whiteColor = color.white 19 | 20 | var label l = label.new( 21 | x=bar_index, 22 | y=na, 23 | text="", 24 | color=labelColor, 25 | textcolor=whiteColor, 26 | style=label.style_labeldown, 27 | size=size.normal 28 | ) 29 | 30 | label.set_text(l, labelText) 31 | label.set_xy(l, bar_index, highest(close, 50)) 32 | -------------------------------------------------------------------------------- /research/script_with_expiration_time.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | study("Script With Expiration Time") 4 | 5 | expired = timenow >= timestamp("GMT", 2018, 12, 1, 13, 0) and (barstate.ishistory or barstate.isrealtime) 6 | 7 | plot(expired ? na : close, color=purple) 8 | -------------------------------------------------------------------------------- /research/symbol_info_helper.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2020-present, Alex Orekhov (everget) 3 | // Symbol Info Helper script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Symbol Info Helper", overlay=true) 5 | 6 | labelText = 7 | "Symbol Name: " + syminfo.tickerid + 8 | "\nSymbol Description: " + syminfo.description + 9 | "\nSymbol Type: " + syminfo.type + 10 | "\nPoint Value: " + tostring(syminfo.pointvalue) + 11 | "\nExchange: " + syminfo.prefix + 12 | "\nListed Exchange: " + "-" + 13 | "\nCurrency: " + syminfo.currency + 14 | "\nTick Size: " + tostring(syminfo.mintick) + 15 | "\nSector: " + "-" + 16 | "\nIndustry: " + "-" + 17 | "\nTimezone: " + syminfo.timezone + 18 | "\nSession: " + "-" 19 | 20 | var label l = label.new( 21 | x=bar_index, 22 | y=na, 23 | text="", 24 | textalign=text.align_left, 25 | textcolor=color.white, 26 | color=color.blue, 27 | style=label.style_label_left, 28 | size=size.normal 29 | ) 30 | 31 | label.set_text(l, labelText) 32 | label.set_xy(l, bar_index, ohlc4) 33 | -------------------------------------------------------------------------------- /research/utc_clock.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // UTC Clock script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("UTC Clock", overlay=true) 5 | 6 | secondsRaw = floor(timenow / 1000) 7 | minutesRaw = floor(secondsRaw / 60) 8 | hoursRaw = floor(minutesRaw / 60) 9 | 10 | seconds = secondsRaw % 60 11 | minutes = minutesRaw % 60 12 | hours = hoursRaw % 24 13 | 14 | f_format(_val) => 15 | (0 < _val and _val < 10 ? "0" : "") + tostring(_val, "##") + (_val == 0 ? "0" : "") 16 | 17 | labelText = f_format(hours) + ":" + f_format(minutes) + ":" + f_format(seconds) 18 | 19 | var label l = label.new( 20 | x=bar_index, 21 | y=na, 22 | text="", 23 | textcolor=color.black, 24 | style=label.style_none, 25 | size=size.huge 26 | ) 27 | 28 | label.set_text(l, labelText) 29 | label.set_xy(l, bar_index, highest(high, 50)) 30 | -------------------------------------------------------------------------------- /statistics/all_time_high_days.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // All-Time High Days script may be freely distributed under the terms of GPL-3.0 license. 4 | study("All-Time High Days", shorttitle="ATH Days", precision=0) 5 | 6 | highlightATH = input(title="Highlight ATH ?", defval=false) 7 | 8 | ath = high 9 | ath := na(ath[1]) ? ath : (high > ath[1] ? high : ath[1]) 10 | 11 | cond = high == ath 12 | transparent = color(white, 100) 13 | 14 | bars = barssince(cond) 15 | plot(bars, title="ATH Days", color=#674ea7) 16 | 17 | bgcolor(cond and highlightATH ? orange : transparent) 18 | -------------------------------------------------------------------------------- /statistics/all_time_high_percent_drop.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // All-Time High % Drop script may be freely distributed under the terms of GPL-3.0 license. 4 | study("All-Time High % Drop", shorttitle="ATH % Drop", precision=2) 5 | 6 | ath = high 7 | ath := na(ath[1]) ? ath : (high > ath[1] ? high : ath[1]) 8 | 9 | percent = 100 * (close - ath) / ath 10 | 11 | plot(percent, title="ATH %", color=#351c75, transp=0) 12 | 13 | plot(0, title="", style=circles, linewidth=0, color=gray) 14 | hline(0, linestyle=dotted, color=gray) 15 | 16 | plot(-10, title="", style=circles, linewidth=0, color=#F9CE02) 17 | hline(-10, linestyle=dotted, color=#F9CE02) 18 | 19 | plot(-20, title="", style=circles, linewidth=0, color=#F7BA05) 20 | hline(-20, linestyle=dotted, color=#F7BA05) 21 | 22 | plot(-30, title="", style=circles, linewidth=0, color=#F4A608) 23 | hline(-30, linestyle=dotted, color=#F4A608) 24 | 25 | plot(-40, title="", style=circles, linewidth=0, color=#F2920B) 26 | hline(-40, linestyle=dotted, color=#F2920B) 27 | 28 | plot(-50, title="", style=circles, linewidth=0, color=#F07E0E) 29 | hline(-50, linestyle=dotted, color=#F07E0E) 30 | 31 | plot(-60, title="", style=circles, linewidth=0, color=#ED6A10) 32 | hline(-60, linestyle=dotted, color=#ED6A10) 33 | 34 | plot(-70, title="", style=circles, linewidth=0, color=#EB5613) 35 | hline(-70, linestyle=dotted, color=#EB5613) 36 | 37 | plot(-80, title="", style=circles, linewidth=0, color=#E84216) 38 | hline(-80, linestyle=dotted, color=#E84216) 39 | 40 | plot(-90, title="", style=circles, linewidth=0, color=#E62E19) 41 | hline(-90, linestyle=dotted, color=#E62E19) 42 | 43 | plot(-100, title="", style=circles, linewidth=0, color=#E41A1C) 44 | hline(-100, linestyle=dotted, color=#E41A1C) 45 | -------------------------------------------------------------------------------- /statistics/bitcoin_ath_hash_rate_level.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Bitcoin ATH Hash Rate Level script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Bitcoin ATH Hash Rate Level", shorttitle="ATH HR", overlay=true) 5 | 6 | highlightMovements = input(title="Highlight Price Movements ?", type=bool, defval=false) 7 | 8 | _ath(src) => 9 | ath = src 10 | ath := na(ath[1]) ? ath : (ath > ath[1] ? ath : ath[1]) 11 | 12 | hashRate = security("QUANDL:BCHAIN/HRATE", "D", close) 13 | 14 | hrATH = _ath(hashRate) 15 | 16 | hrathLevel = close 17 | hrathLevel := hrATH > hrATH[1] ? close : nz(hrathLevel[1], close) // and close > close[1] 18 | 19 | levelColor = highlightMovements ? (close > hrathLevel ? green : close < hrathLevel ? red : #6d1e7f) : black 20 | plot(hrathLevel, title="Hash Rate", linewidth=2, color=levelColor, transp=0) 21 | 22 | hrathCond = hrATH != hrATH[1] 23 | alertcondition(hrathCond, title="Alert on New Bitcoin ATH Hash Rate", message="New Bitcoin ATH Hash Rate !") 24 | -------------------------------------------------------------------------------- /statistics/kendall_rank_correlation_coefficient.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Kendall Rank Correlation Coefficient script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Kendall Rank Correlation Coefficient", shorttitle="Kendall Correlation") 5 | 6 | length = input(title="Length", type=integer, defval=20) 7 | sym1 = input(title="1st Symbol", type=symbol, defval="FX:AUDUSD") 8 | sym2 = input(title="2nd Symbol", type=symbol, defval="FOREXCOM:XAUUSD") 9 | src = input(title="Source", type=source, defval=close) 10 | 11 | data1 = security(sym1, period, src) 12 | data2 = security(sym2, period, src) 13 | 14 | getKendall(data1, data2, length) => 15 | totalPairs = length * (length - 1) / 2 16 | numerator = 0.0 17 | 18 | for i = 0 to length - 1 19 | for j = 0 to i 20 | numerator := numerator + sign(data1[i] - data1[j]) * sign(data2[i] - data2[j]) 21 | 22 | numerator / totalPairs 23 | 24 | kendallCorr = sym1 == sym2 ? 1 : getKendall(data1, data2, length) 25 | pearsonCorr = correlation(data1, data2, length) 26 | 27 | plot(kendallCorr, title="Kendall", color=orange, transp=0) 28 | plot(pearsonCorr, title="Pearson", color=purple, transp=0) 29 | -------------------------------------------------------------------------------- /statistics/kurtosis_indicator.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Kurtosis Indicator script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Kurtosis Indicator", shorttitle="Kurtosis") 5 | 6 | momentumLength = input(title="Momentum Length", type=integer, defval=3, minval=1) 7 | fastMAInput = input(title="Fast MA", defval="EMA", options=["EMA", "SMA", "VWMA", "WMA"]) 8 | fastLength = input(title="Fast Length", type=integer, defval=66, minval=1) 9 | fastSlowMAInput = input(title="Fast/Slow MA", defval="SMA", options=["EMA", "SMA", "VWMA", "WMA"]) 10 | fastSlowLength = input(title="Fast/Slow Length", type=integer, defval=3, minval=1) 11 | src = input(title="Source", type=source, defval=close) 12 | 13 | // Kurtosis 14 | K = change(src, momentumLength) - change(src[1], momentumLength) 15 | 16 | // Fast Kurtosis 17 | FK = iff(fastMAInput == "EMA", ema(K, fastLength), 18 | iff(fastMAInput == "SMA", sma(K, fastLength), 19 | iff(fastMAInput == "VWMA", vwma(K, fastLength), 20 | iff(fastMAInput == "WMA", wma(K, fastLength), 21 | na)))) 22 | 23 | // Fast / Slow Kurtosis 24 | FSK = iff(fastSlowMAInput == "EMA", ema(FK, fastSlowLength), 25 | iff(fastSlowMAInput == "SMA", sma(FK, fastSlowLength), 26 | iff(fastSlowMAInput == "VWMA", vwma(FK, fastSlowLength), 27 | iff(fastSlowMAInput == "WMA", wma(FK, fastSlowLength), 28 | na)))) 29 | 30 | hline(title="Zero Level", price=0, linestyle=dotted, color=gray) 31 | 32 | plot(FK, title="Fast", linewidth=2, color=#ff9370, transp=0) 33 | plot(FSK, title="Fast / Slow", linewidth=2, color=#6d1e7f, transp=0) 34 | -------------------------------------------------------------------------------- /statistics/z_score.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Z-Score script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Z-Score", shorttitle="ZSC") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | stdevInput = input(title="Standard Deviation", defval="Sample", options=["Population", "Sample"]) 8 | src = input(title="Source", type=source, defval=close) 9 | 10 | sampleStdev(src, length) => 11 | dev = src - sma(src, length) 12 | variance = sum(dev * dev, length) / (length - 1) 13 | sqrt(variance) 14 | 15 | selectedStdev = stdevInput == "Sample" 16 | ? sampleStdev(src, length) 17 | : stdev(src, length) 18 | 19 | zsc = (src - sma(src, length)) / selectedStdev 20 | 21 | zscColor = zsc > 2.0 ? #0ebb23 : zsc < -2.0 ? #ff0000 : #8e7cc3 22 | 23 | plot(zsc, title="Z-Score", linewidth=2, color=zscColor, transp=0, style=line) 24 | 25 | hline(title="Upper Band", price=2.0, linestyle=dotted, color=#e69138) 26 | hline(0, title="Zero Level", linestyle=dotted, color=#989898) 27 | hline(title="Lower Band", price=-2.0, linestyle=dotted, color=#e69138) 28 | -------------------------------------------------------------------------------- /trailing_stops/parabolic_sar.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Parabolic SAR script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Parabolic SAR", shorttitle="PSAR", overlay=true) 5 | 6 | start = input(title="Start", type=input.float, step=0.001, defval=0.02) 7 | increment = input(title="Increment", type=input.float, step=0.001, defval=0.02) 8 | maximum = input(title="Maximum", type=input.float, step=0.01, defval=0.2) 9 | width = input(title="Point Width", type=input.integer, minval=1, defval=2) 10 | highlightStartPoints = input(title="Highlight Start Points ?", type=input.bool, defval=true) 11 | showLabels = input(title="Show Buy/Sell Labels ?", type=input.bool, defval=true) 12 | highlightState = input(title="Highlight State ?", type=input.bool, defval=true) 13 | 14 | psar = sar(start, increment, maximum) 15 | dir = psar < close ? 1 : -1 16 | 17 | psarColor = dir == 1 ? #3388bb : #fdcc02 18 | psarPlot = plot(psar, title="PSAR", style=plot.style_circles, linewidth=width, color=psarColor, transp=0) 19 | 20 | var color longColor = color.green 21 | var color shortColor = color.red 22 | 23 | buySignal = dir == 1 and dir[1] == -1 24 | plotshape(buySignal and highlightStartPoints ? psar : na, title="Long Start", location=location.absolute, style=shape.circle, size=size.tiny, color=longColor, transp=0) 25 | plotshape(buySignal and showLabels ? psar : na, title="Buy Label", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=longColor, textcolor=color.white, transp=0) 26 | 27 | sellSignal = dir == -1 and dir[1] == 1 28 | plotshape(sellSignal and highlightStartPoints ? psar : na, title="Short Start", location=location.absolute, style=shape.circle, size=size.tiny, color=shortColor, transp=0) 29 | plotshape(sellSignal and showLabels ? psar : na, title="Sell Label", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=shortColor, textcolor=color.white, transp=0) 30 | 31 | midPricePlot = plot(ohlc4, title="", display=display.none) 32 | 33 | fillColor = highlightState ? (dir == 1 ? longColor : shortColor) : na 34 | fill(midPricePlot, psarPlot, title="Trade State Filling", color=fillColor) 35 | 36 | changeCond = dir != dir[1] 37 | alertcondition(changeCond, title="Alert: PSAR Direction Change", message="PSAR has changed direction!") 38 | alertcondition(buySignal, title="Alert: PSAR Long", message="PSAR Long") 39 | alertcondition(sellSignal, title="Alert: PSAR Short", message="PSAR Sell") 40 | -------------------------------------------------------------------------------- /volatility/damping_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Damping Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Damping Index", shorttitle="DI") 5 | 6 | smaLength = input(title="SMA Length", type=integer, defval=5) 7 | threshold = input(title="Threshold", type=float, step=0.1, defval=1.5) 8 | 9 | sma = sma(high - low, smaLength) 10 | 11 | di = sma[1] / sma[6] 12 | 13 | diColor = di >= threshold ? #ff9800 : #3c78d8 14 | plot(di, color=diColor, transp=0) 15 | 16 | hline(threshold, title="Threshold", linestyle=dotted) 17 | 18 | breakoutFillColor = di >= threshold ? #ff9800 : color(white, 100) 19 | bgcolor(breakoutFillColor, transp=90) 20 | -------------------------------------------------------------------------------- /volatility/gopalakrishnan_range_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Gopalakrishnan Range Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Gopalakrishnan Range Index", shorttitle="GAPO") 5 | 6 | length = input(title="Length", type=integer, defval=5) 7 | 8 | gapo = log(highest(length) - lowest(length)) / log(length) 9 | 10 | gapoColor = gapo >= gapo[1] ? #0ebb23 : red 11 | plot(gapo, title="GAPO", linewidth=2, color=gapoColor, transp=0) 12 | -------------------------------------------------------------------------------- /volatility/mayer_multiple.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Mayer Multiple script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Mayer Multiple", shorttitle="MM") 5 | 6 | smaLength = input(title="SMA Length", type=integer, defval=200) 7 | threshold = input(title="Threshold", type=float, step=0.1, defval=2.4) 8 | 9 | price = nz(security("BTCUSD", period, close)) 10 | 11 | mm = price / sma(price, smaLength) 12 | 13 | mmColor = mm > threshold ? #ff9800 : #3c78d8 14 | plot(mm, color=mmColor, transp=0) 15 | 16 | hline(threshold, title="Threshold", linestyle=dotted) 17 | 18 | breakoutFillColor = mm > threshold ? #ff9800 : color(white, 100) 19 | bgcolor(breakoutFillColor, transp=90) 20 | -------------------------------------------------------------------------------- /volatility/normalized_average_true_range.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Normalized Average True Range script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Normalized Average True Range", shorttitle="NATR") 5 | 6 | length = input(title="Length", type=integer, defval=14) 7 | 8 | natr = 100 * atr(length) / close 9 | 10 | plot(natr, color=#ff9800, transp=0) 11 | -------------------------------------------------------------------------------- /volatility/ulcer_index.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Ulcer Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Ulcer Index") 5 | 6 | length = input(title="Length", type=input.integer, defval=14) 7 | smoothLength = input(title="Smoothing Length", type=input.integer, defval=14) 8 | breakout = input(title="Breakout Level", type=input.float, step=0.1, defval=1.5) 9 | signalType = input(title="Signal Smoothing Type", defval="SMA", options=["EMA", "SMA"]) 10 | signalLength = input(title="Signal Smoothing Length", type=input.integer, defval=52) 11 | src = input(title="Source", type=input.source, defval=close) 12 | showSignal = input(title="Show Signal ?", type=input.bool, defval=true) 13 | highlightCrossovers = input(title="Highlight Signal Crossovers ?", type=input.bool, defval=true) 14 | applyRibbonFilling = input(title="Apply Ribbon Filling ?", type=input.bool, defval=true) 15 | 16 | highest = highest(src, length) 17 | drawdown = 100 * (src - highest) / highest 18 | ulcer = sqrt(sma(pow(drawdown, 2), smoothLength)) 19 | signal = signalType == "SMA" ? sma(ulcer, signalLength) : ema(ulcer, signalLength) 20 | 21 | trendColor = ulcer > signal ? #0ebb23 : color.red 22 | ulcerColor = applyRibbonFilling ? trendColor : (ulcer >= ulcer[1] ? #0ebb23 : color.red) 23 | signalColor = applyRibbonFilling ? trendColor : #1155cc 24 | 25 | ulcerPlot = plot(ulcer, title="Ulcer", linewidth=2, color=ulcerColor, transp=0) 26 | signalPlot = plot(showSignal ? signal : na, title="Signal", color=signalColor, transp=0) 27 | 28 | ribbonFillColor = applyRibbonFilling ? trendColor : na 29 | fill(ulcerPlot, signalPlot, title="Ribbon", color=ribbonFillColor, transp=70) 30 | 31 | plotshape(crossover(ulcer, signal) and highlightCrossovers ? signal : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) 32 | plotshape(crossunder(ulcer, signal) and highlightCrossovers ? signal : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) 33 | 34 | hline(breakout, title="Breakout Level", linestyle=hline.style_dotted, linewidth=2) 35 | breakoutFillColor = ulcer > breakout ? #ff9800 : na 36 | bgcolor(breakoutFillColor, transp=90) 37 | -------------------------------------------------------------------------------- /volatility/volatility_ratio.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Volatility Ratio script may be freely distributed under the terms of the GPL-3.0 license. 4 | study("Volatility Ratio", shorttitle="VR") 5 | 6 | length = input(title="Length", type=integer, minval=1, defval=14) 7 | breakoutLevel = input(title="Breakout Level", type=float, step=0.1, defval=0.5) 8 | 9 | max = max(highest(high, length), close[length + 1]) 10 | min = min(lowest(low, length), close[length + 1]) 11 | 12 | vr = tr(true) / (max - min) 13 | 14 | vrColor = vr >= breakoutLevel ? #39b361 : #cc4125 15 | 16 | plot(vr, title="VR", linewidth=2, color=vrColor, transp=0) 17 | 18 | hline(title="Breakout Level", price=breakoutLevel, linestyle=dotted, color=gray) 19 | -------------------------------------------------------------------------------- /volume/accumulation_distribution_line.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Accumulation/Distribution Line script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Accumulation/Distribution Line", shorttitle="Accum/Dist", precision=0) 5 | 6 | showSignal = input(title="Show Signal ?", type=bool, defval=true) 7 | signalType = input(title="Signal Smoothing Type", defval="SMA", options=["EMA", "SMA"]) 8 | signalLength = input(title="Signal Smoothing Length", type=integer, defval=21) 9 | highlightCrossovers = input(title="Highlight Crossovers ?", type=bool, defval=false) 10 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=true) 11 | 12 | signal = signalType == "EMA" ? ema(accdist, signalLength) : sma(accdist, signalLength) 13 | 14 | trendColor = accdist > signal ? #0ebb23 : red 15 | 16 | adColor = applyFilling ? trendColor : #0094ff 17 | signalColor = applyFilling ? trendColor : #ff6a00 18 | 19 | adPlot = plot(accdist, title="Accum/Dist", linewidth=2, color=adColor, transp=0) 20 | signalPlot = plot(showSignal ? signal : na, title="Signal", color=signalColor, transp=0) 21 | 22 | transparent = color(white, 100) 23 | 24 | fillColor = applyFilling ? trendColor : transparent 25 | fill(adPlot, signalPlot, color=fillColor, transp=70) 26 | 27 | plotshape(crossover(accdist, signal) and highlightCrossovers ? accdist : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 28 | plotshape(crossunder(accdist, signal) and highlightCrossovers ? accdist : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 29 | -------------------------------------------------------------------------------- /volume/negative_volume_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Negative Volume Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Negative Volume Index", shorttitle="NVI") 5 | 6 | initial = input(title="Initial Value", type=integer, defval=100) 7 | signalType = input(title="Signal Smoothing Type", defval="EMA", options=["EMA", "SMA"]) 8 | signalLength = input(title="Signal Length", type=integer, defval=255) 9 | highlightCrossovers = input(title="Highlight Crossovers", type=bool, defval=false) 10 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=true) 11 | 12 | nvi = 0.0 13 | nvi := na(nvi[1]) ? initial : (change(volume) < 0 ? nvi[1] * close / close[1] : nvi[1]) 14 | signal = signalType == "EMA" ? ema(nvi, signalLength) : sma(nvi, signalLength) 15 | 16 | trendColor = nvi > signal ? #0ebb23 : red 17 | 18 | nviColor = applyFilling ? trendColor : #0094ff 19 | signalColor = applyFilling ? trendColor : #ff6a00 20 | 21 | nviPlot = plot(nvi, title="NVI", color=nviColor, transp=0) 22 | signalPlot = plot(signal, title="Signal", color=signalColor, transp=0) 23 | 24 | transparent = color(white, 100) 25 | 26 | fillColor = applyFilling ? trendColor : transparent 27 | fill(nviPlot, signalPlot, color=fillColor, transp=70) 28 | 29 | plotshape(crossover(nvi, signal) and highlightCrossovers ? nvi : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 30 | plotshape(crossunder(nvi, signal) and highlightCrossovers ? nvi : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 31 | -------------------------------------------------------------------------------- /volume/net_volume.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // Net Volume script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Net Volume", precision=0) 5 | 6 | src = input(title="Source", type=source, defval=close) 7 | 8 | nv = sign(change(src)) * volume 9 | 10 | nvColor = nv >= 0 ? (nv[1] < nv ? #26A69A : #B2DFDB) : (nv[1] < nv ? #FFCDD2 : #EF5350) 11 | 12 | plot(nv, title="Net Volume", style=columns, linewidth=2, color=nvColor, transp=0) 13 | -------------------------------------------------------------------------------- /volume/on_balance_volume.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // On Balance Volume script may be freely distributed under the terms of GPL-3.0 license. 4 | study("On Balance Volume", shorttitle="OBV", precision=0) 5 | 6 | showSignal = input(title="Show Signal ?", type=bool, defval=true) 7 | signalType = input(title="Signal Smoothing Type", defval="SMA", options=["EMA", "SMA"]) 8 | signalLength = input(title="Signal Smoothing Length", type=integer, defval=21) 9 | highlightCrossovers = input(title="Highlight Crossovers ?", type=bool, defval=false) 10 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=true) 11 | src = input(title="Source", type=source, defval=close) 12 | 13 | obv = cum(sign(change(src)) * volume) 14 | signal = signalType == "EMA" ? ema(obv, signalLength) : sma(obv, signalLength) 15 | 16 | trendColor = obv > signal ? #0ebb23 : red 17 | 18 | obvColor = applyFilling ? trendColor : #0094ff 19 | signalColor = applyFilling ? trendColor : #ff6a00 20 | 21 | obvPlot = plot(obv, title="OBV", linewidth=2, color=obvColor, transp=0) 22 | signalPlot = plot(showSignal ? signal : na, title="Signal", color=signalColor, transp=0) 23 | 24 | transparent = color(white, 100) 25 | 26 | fillColor = applyFilling ? trendColor : transparent 27 | fill(obvPlot, signalPlot, color=fillColor, transp=70) 28 | 29 | plotshape(crossover(obv, signal) and highlightCrossovers ? obv : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 30 | plotshape(crossunder(obv, signal) and highlightCrossovers ? obv : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 31 | -------------------------------------------------------------------------------- /volume/percent_volume.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2019-present, Alex Orekhov (everget) 3 | // % Volume script may be freely distributed under the terms of GPL-3.0 license. 4 | study("% Volume", precision=2) 5 | 6 | length = input(title="SMA Length", type=integer, defval=21) 7 | 8 | pv = 100 * volume / sma(volume, length) 9 | 10 | pvColor = close > open ? #92df8bff : #fe9695ff 11 | plot(pv, title="%V", style=columns, linewidth=2, color=pvColor, transp=0) 12 | 13 | // purple = #674ea7 14 | // yellow = #f9ce02 15 | 16 | labelColor = #f9ce02 17 | levelColor = #674ea7 18 | 19 | plot(50, title="", style=circles, linewidth=0, color=labelColor) 20 | hline(50, title="50% Level", linestyle=dotted, color=levelColor) 21 | 22 | plot(100, title="", style=circles, linewidth=0, color=labelColor) 23 | hline(100, title="100% Level", linestyle=dotted, color=levelColor) 24 | 25 | plot(150, title="", style=circles, linewidth=0, color=labelColor) 26 | hline(150, title="150% Level", linestyle=dotted, color=levelColor) 27 | 28 | plot(200, title="", style=circles, linewidth=0, color=labelColor) 29 | hline(200, title="200% Level", linestyle=dotted, color=levelColor) 30 | 31 | plot(250, title="", style=circles, linewidth=0, color=labelColor) 32 | hline(250, title="250% Level", linestyle=dotted, color=levelColor) 33 | 34 | plot(300, title="", style=circles, linewidth=0, color=labelColor) 35 | hline(300, title="300% Level", linestyle=dotted, color=levelColor) 36 | 37 | // show300 = input(title="Show 300% Level ?", type=bool, defval=false) 38 | // plot(show300 ? 300 : na, title="", style=circles, linewidth=0, color=#F9CE02) 39 | // hline(show300 ? 300 : na, title="300% Level", linestyle=dotted, color=#F9CE02) 40 | -------------------------------------------------------------------------------- /volume/positive_volume_index.pine: -------------------------------------------------------------------------------- 1 | //@version=3 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Positive Volume Index script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Positive Volume Index", shorttitle="PVI") 5 | 6 | initial = input(title="Initial Value", type=integer, defval=100) 7 | signalType = input(title="Signal Smoothing Type", defval="EMA", options=["EMA", "SMA"]) 8 | signalLength = input(title="Signal Length", type=integer, defval=255) 9 | highlightCrossovers = input(title="Highlight Crossovers ?", type=bool, defval=false) 10 | applyFilling = input(title="Apply Ribbon Filling ?", type=bool, defval=true) 11 | 12 | pvi = 0.0 13 | pvi := na(pvi[1]) ? initial : (change(volume) > 0 ? pvi[1] * close / close[1] : pvi[1]) 14 | signal = signalType == "EMA" ? ema(pvi, signalLength) : sma(pvi, signalLength) 15 | 16 | trendColor = pvi > signal ? #0ebb23 : red 17 | 18 | pviColor = applyFilling ? trendColor : #0094ff 19 | signalColor = applyFilling ? trendColor : #ff6a00 20 | 21 | pviPlot = plot(pvi, title="PVI", color=pviColor, transp=0) 22 | signalPlot = plot(signal, title="Signal", color=signalColor, transp=0) 23 | 24 | transparent = color(white, 100) 25 | 26 | fillColor = applyFilling ? trendColor : transparent 27 | fill(pviPlot, signalPlot, color=fillColor, transp=70) 28 | 29 | plotshape(crossover(pvi, signal) and highlightCrossovers ? pvi : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=green, transp=0) 30 | plotshape(crossunder(pvi, signal) and highlightCrossovers ? pvi : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=red, transp=0) 31 | -------------------------------------------------------------------------------- /volume/price_volume_trend.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2018-present, Alex Orekhov (everget) 3 | // Price Volume Trend script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Price Volume Trend", shorttitle="PVT", format=format.volume) 5 | 6 | showSignal = input(title="Show Signal ?", type=input.bool, defval=true) 7 | signalType = input(title="Signal Smoothing Type", defval="SMA", options=["EMA", "SMA"]) 8 | signalLength = input(title="Signal Smoothing Length", type=input.integer, defval=21) 9 | src = input(title="Source", type=input.source, defval=close) 10 | highlightCrossovers = input(title="Highlight Crossovers ?", type=input.bool, defval=false) 11 | applyFilling = input(title="Apply Ribbon Filling ?", type=input.bool, defval=true) 12 | 13 | signal = signalType == "EMA" ? ema(pvt, signalLength) : sma(pvt, signalLength) 14 | 15 | trendColor = pvt > signal ? #0ebb23 : color.red 16 | pvtColor = applyFilling ? trendColor : #0094ff 17 | signalColor = applyFilling ? trendColor : #ff6a00 18 | 19 | pvtPlot = plot(pvt, title="PVT", linewidth=2, color=pvtColor, transp=0) 20 | signalPlot = plot(showSignal ? signal : na, title="Signal", color=signalColor, transp=0) 21 | 22 | transparent = color.new(color.white, 100) 23 | 24 | fillColor = applyFilling ? trendColor : transparent 25 | fill(pvtPlot, signalPlot, color=fillColor, transp=70) 26 | 27 | buyAlert = crossover(pvt, signal) 28 | sellAlert = crossunder(pvt, signal) 29 | 30 | plotshape(buyAlert and highlightCrossovers ? pvt : na, title="Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) 31 | plotshape(sellAlert and highlightCrossovers ? pvt : na, title="Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) 32 | 33 | alertcondition(buyAlert, title="Alert: Buy", message="Buy\nSymbol: {{exchange}}:{{ticker}}\nPrice: {{close}}") 34 | alertcondition(sellAlert, title="Alert: Sell", message="Sell\nSymbol: {{exchange}}:{{ticker}}\nPrice: {{close}}") 35 | -------------------------------------------------------------------------------- /volume/volume_accumulation.pine: -------------------------------------------------------------------------------- 1 | //@version=4 2 | // Copyright (c) 2020-present, Alex Orekhov (everget) 3 | // Volume Accumulation script may be freely distributed under the terms of GPL-3.0 license. 4 | study("Volume Accumulation", format=format.volume) 5 | 6 | type = input(title="Type", defval="Daily", options=["Minutely", "Hourly", "Session", "Daily", "Monthly", "Quarterly", "Yearly"]) 7 | sessionInput = input(title="Session (only for 'Session' type)", type=input.session, defval="0900-1530") 8 | includeWeekends = input(title="Include Weekends ?", defval=true) 9 | 10 | _inSession(res, sess) => 11 | t = time(res, sess) 12 | na(t[1]) and not na(t) or t[1] < t 13 | 14 | min = minute(time) 15 | h = hour(time) 16 | d = dayofmonth(time) 17 | m = month(time) 18 | y = year(time) 19 | 20 | q1 = m == 1 or m == 2 or m == 3 21 | q2 = m == 4 or m == 5 or m == 6 22 | q3 = m == 7 or m == 8 or m == 9 23 | q4 = m == 10 or m == 11 or m == 12 24 | 25 | q = 26 | q1 ? 1 : 27 | q2 ? 2 : 28 | q3 ? 3 : 29 | 4 30 | 31 | session = includeWeekends ? sessionInput + ":1234567" : sessionInput 32 | s = _inSession(timeframe.period, session) ? 1 : 0 33 | 34 | int p = 35 | type == "Minutely" ? min : 36 | type == "Hourly" ? h : 37 | type == "Session" ? s : 38 | type == "Daily" ? d : 39 | type == "Monthly" ? m : 40 | type == "Quarterly" ? q : 41 | type == "Yearly" ? y : 42 | na 43 | 44 | var acc = 0.0 45 | acc := p != p[1] ? volume : nz(acc[1]) + volume 46 | 47 | var accPrev = 0.0 48 | accPrev := p != p[1] ? acc[1] : accPrev 49 | 50 | accColor = acc > accPrev ? #92df8bff : #fe9695ff 51 | plot(acc, title="Accumulation", style=plot.style_columns, color=accColor) 52 | 53 | transparent = color.new(color.white, 100) 54 | bgcolor(p != p[1] ? #ffcc80 : transparent, title="Separator", transp=60) 55 | 56 | higherAlert = acc > accPrev 57 | alertcondition(higherAlert, title="Higher Accumulation", message="Higher Accumulation") 58 | --------------------------------------------------------------------------------