mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-08 22:17: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.
29 lines
971 B
Plaintext
29 lines
971 B
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Midpoint (MIDPOINT)", "MIDPOINT", overlay=true)
|
|
|
|
//@function Calculates the midpoint of the highest high and lowest low over a specified period
|
|
//@param src Source series to calculate midpoint for
|
|
//@param len Lookback period for finding highest and lowest values
|
|
//@returns float The midpoint value (highest + lowest) * 0.5 over the period
|
|
//@optimized Uses multiplication instead of division for performance
|
|
midpoint(series float src, simple int len) =>
|
|
if len <= 0
|
|
runtime.error("Length must be greater than 0")
|
|
float highest_val = ta.highest(src, len)
|
|
float lowest_val = ta.lowest(src, len)
|
|
(highest_val + lowest_val) * 0.5
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input.source(close, "Source")
|
|
i_length = input.int(14, "Length", minval=1)
|
|
|
|
// Calculation
|
|
result = midpoint(i_source, i_length)
|
|
|
|
// Plot
|
|
plot(result, "Midpoint", color=color.yellow, linewidth=2)
|