The Infinite Impulse Response Filter ForLoop indicator is designed for seeking quick and accurate trend identification. Leveraging the Infinite Impulse Response (IIR) filter technique, this indicator provides fast and responsive signals to aid in market timing and trend following.
User Inputs
Start and End Lengths: Define the range of lengths over which the IIRF values are calculated.
Moving Average Type: Choose from EMA, SMA, WMA, VWMA, or TMA for trend smoothing.
Moving Average Length: Specify the length for the chosen MA type.
Calculation Source: Select the price data used for calculations (default is close price).
Signal Calculation
Signal Mode (sigmode): Determines the type of signal generated by the indicator. Options are "Fast", "Slow", "Thresholds Crossing", and "Fast Threshold". 1. Slow: is a simple crossing of the midline (0). 2. Fast: positive signal depends if the current MA > MA or MA is above 0.99, negative signals comes if MA < MA or MA is below -0.99. 3. Thresholds Crossing: simple ta.crossover and ta.crossunder of the user defined threshold for Long and Short. 4. Fast Threshold: signal changes if the value of MA changes by more than user defined threshold against the current signal
// Function to calculate an array of IIRF values over a range of lengths IIRFforLoop(a,b,c,s)=> // Initialize an array to store IIRF values varArray=array.new_float(b-a+1,0.0) // Loop over the range from 'a' to 'b' forx=0to(b-a) // Calculate the length for the current iteration len=a+x // Calculate the IIRF alpha parameter iirfAlpha=2/(len+1) // Calculate the lag for the IIRF calculation iirfLag=math.round(1/iirfAlpha-1) // Initialize the IIRF value iirf=0.0 // Update the IIRF value using the IIR filter formula iirf:=iirfAlpha*(s+ta.change(s,iirfLag))+(1-iirfAlpha)*nz(iirf[1]) // Determine the trend based on the current and previous IIRF values trend=iirf>iirf[1]?1:-1 // Store the trend value in the array array.set(Array,x,trend) // Calculate the average of the IIRF values in the array Avg=array.avg(Array) // Calculate the moving average of the average IIRF values based on the selected MA type floatMA=switchmaType "EMA"=>ta.ema(Avg,c)// Exponential Moving Average "SMA"=>ta.sma(Avg,c)// Simple Moving Average "WMA"=>ta.wma(Avg,c)// Weighted Moving Average "VWMA"=>ta.vwma(Avg,c)// Volume Weighted Moving Average "TMA"=>ta.trima(Avg,c)// Triangular Moving Average => runtime.error("No matching MA type found.")// Error handling for invalid MA type float(na) // Return the array of IIRF values, their average, and the moving average [Array,Avg,MA]
Important Considerations
Rapid Signal Response: The IIRF ForLoop is designed to provide very fast trend signals, making it suitable for short-term trading and quick decision-making. Complementary Tool: While powerful, the IIRF ForLoop should be used in conjunction with other indicators and market analysis techniques to confirm signals and improve trading accuracy.
Conclusion
The Infinite Impulse Response Filter ForLoop indicator is a highly responsive and flexible tool that can significantly enhance your trading strategy. Its ability to quickly identify trends and generate signals based on various moving average types and customizable thresholds makes it invaluable for active traders. For the best results, use this indicator alongside other technical analysis tools to confirm signals and ensure robust trading decisions.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
차트에서 빠르게 액세스하려면 이 스크립트를 즐겨찾기에 추가하세요 — 여기에서 자세히 알아보기.