Killzones And Macros LibraryKillzones & Macros Library for Trading Sessions
This Pine Script library is designed to help traders identify and act during high-volatility trading windows, commonly referred to as "Killzones." These are specific times during the day when institutional traders are most active, resulting in increased liquidity and price movement. The library provides boolean fields that return true when the current time falls within one of the killzones or macroeconomic event windows, allowing for enhanced trade timing and precision.
Killzones Include:
London Open, New York Open, Midnight Open, London Lunch, New York PM, and more.
Capture high-volume periods like Power Hour, Equities Open, and Asian Range.
Macros:
Identify key moments like London 02:33, New York 08:50, and other significant times aligned with market movements or events.
This library is perfect for integrating into your custom strategies, backtesting, or setting alerts for optimal trade execution during major trading sessions and events.
Cycles
FFTLibraryLibrary "FFTLibrary" contains a function for performing Fast Fourier Transform (FFT) along with a few helper functions. In general, FFT is defined for complex inputs and outputs. The real and imaginary parts of formally complex data are treated as separate arrays (denoted as x and y). For real-valued data, the array of imaginary parts should be filled with zeros.
FFT function
fft(x, y, dir) : Computes the one-dimensional discrete Fourier transform using an in-place complex-to-complex FFT algorithm . Note: The transform also produces a mirror copy of the frequency components, which correspond to the signal's negative frequencies.
Parameters:
x : float array, real part of the data, array size must be a power of 2
y : float array, imaginary part of the data, array size must be the same as x ; for real-valued input, y must be an array of zeros
dir : string, options = , defines the direction of the transform: forward" (time-to-frequency) or inverse (frequency-to-time)
Returns: x, y : tuple (float array, float array), real and imaginary parts of the transformed data (original x and y are changed on output)
Helper functions
fftPower(x, y) : Helper function that computes the power of each frequency component (in other words, Fourier amplitudes squared).
Parameters:
x : float array, real part of the Fourier amplitudes
y : float array, imaginary part of the Fourier amplitudes
Returns: power : float array of the same length as x and y , Fourier amplitudes squared
fftFreq(N) : Helper function that returns the FFT sample frequencies defined in cycles per timeframe unit. For example, if the timeframe is 5m, the frequencies are in cycles/(5 minutes).
Parameters:
N : int, window length (number of points in the transformed dataset)
Returns: freq : float array of N, contains the sample frequencies (with zero at the start).