mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-06 04:57:44 +00:00
24e86d762a
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links. - Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
53 lines
1.9 KiB
Plaintext
53 lines
1.9 KiB
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Archer Moving Averages Trends (AMAT)", "AMAT", overlay=false)
|
|
|
|
//@function Calculates AMAT using multiple EMAs to identify trend direction
|
|
//@param source Series to calculate AMAT from
|
|
//@param fast Fast EMA period
|
|
//@param slow Slow EMA period
|
|
//@returns Tuple [bullish_count, bearish_count, trend_strength]
|
|
amat(series float source, simple int fast = 10, simple int slow = 50) =>
|
|
if fast <= 0 or slow <= 0
|
|
runtime.error("Periods must be greater than 0")
|
|
if fast >= slow
|
|
runtime.error("Fast period must be less than slow period")
|
|
|
|
float alpha_fast = 2.0 / (fast + 1)
|
|
float alpha_slow = 2.0 / (slow + 1)
|
|
|
|
var float ema_fast = source
|
|
var float ema_slow = source
|
|
var float ema_fast_prev = source
|
|
var float ema_slow_prev = source
|
|
|
|
ema_fast := alpha_fast * (source - ema_fast) + ema_fast
|
|
ema_slow := alpha_slow * (source - ema_slow) + ema_slow
|
|
|
|
float long_trend = ema_fast > ema_slow and ema_fast > ema_fast_prev and ema_slow > ema_slow_prev ? 1.0 : 0.0
|
|
float short_trend = ema_fast < ema_slow and ema_fast < ema_fast_prev and ema_slow < ema_slow_prev ? -1.0 : 0.0
|
|
|
|
ema_fast_prev := ema_fast
|
|
ema_slow_prev := ema_slow
|
|
|
|
float trend = long_trend + short_trend
|
|
float strength = math.abs(ema_fast - ema_slow) / ema_slow * 100
|
|
|
|
[trend, strength, ema_fast, ema_slow]
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_fast = input.int(10, "Fast Period", minval=1)
|
|
i_slow = input.int(50, "Slow Period", minval=2)
|
|
i_source = input.source(close, "Source")
|
|
|
|
// Calculation
|
|
[trend, strength, ema_fast, ema_slow] = amat(i_source, i_fast, i_slow)
|
|
|
|
// Plot
|
|
plot(trend, "AMAT Trend", color=trend > 0 ? color.green : trend < 0 ? color.red : color.gray, style=plot.style_columns, linewidth=3)
|
|
plot(strength, "Trend Strength %", color=color.yellow, linewidth=2)
|
|
hline(0, "Zero", color=color.gray, linestyle=hline.style_dashed)
|