//@version=4
study("For loop")
my_sma(price, length) =>
sum = price
for i = 1 to length-1
sum := sum + price[i]
sum / length
plot(my_sma(close,14))
Overview
For Loop defines a function that iterates through past bar values up to a specified length of 14, sums the closing prices, and calculates the average. The resulting custom moving average line is plotted in a separate indicator pane. This serves as a simple programming example of standard loop iteration rather than a standalone trading system.
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
The Derivative Oscillator calculates a double-exponentially smoothed Relative Strength Index (RSI) and subtracts its Simple Moving Average (SMA) to form the main oscillator line. A secondary signal line is plotted using an SMA of the main oscillator values. Th
This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome
This indicator calculates and plots the standard Moving Average Convergence Divergence oscillator in a separate pane. It computes the difference between a fast and slow moving average, derives a signal line through smoothing, and plots a histogram representing
Calculates and plots moving averages on selected VIX volatility terms (VIX9D, VIX, VIX3M, or VIX6M) in a separate pane. The script computes user-defined short and long moving averages using EMA or SMA. It shades the background red when the short-term moving av
This demonstration script implements a custom FIFO array push function in Pine Script v4. It maintains a fixed-length array of closing prices by popping the oldest value and inserting the newest close at the front index. The script plots the newest price eleme
Donald SPX - Options Trading is an indicator designed to assist SPX index option traders by tracking session benchmarks and multi-timeframe moving average data. It calculates a 200-period weighted moving average (WMA) and requests multi-timeframe bar data from