Distribution shift
Distribution shift is an alert that checks every 1 hour and fires at most once per bar.
statistics and matrices
alert "Distribution shift"check: every 1hrepeat: once per barwarmup: 300r = returns(close)skewness = skew(r, 100)tails = kurtosis(r, 100)memory = autocorrelation(r, 100, lag: 1)when abs(skewness) > 1 and tails > 5:notify "Fat-tailed, skewed returns: skew {skewness:0.00}, kurtosis {tails:0.0}, lag-1 autocorrelation {memory:0.00}"Sample data. Not a result. The real AlgoBarsX engine ran this exact script on made-up bars, and this replays what it drew and did. It shows no profit or loss, and it says nothing about how the script would do in a real market.
Replay of this script on 150 sample bars: 1 alert sent.
Distribution shift is an alert that checks every 1 hour and fires at most once per bar.
It calculates r as the returns of the close, skewness as the skew (source r, length 100), tails as the kurtosis (source r, length 100) and memory as the autocorrelation (source r, length 100, lag 1).
When the absolute value of skewness is above 1 and tails is above 5, it sends the notification "Fat-tailed, skewed returns: skew {skewness:0.00}, kurtosis {tails:0.0}, lag-1 autocorrelation {memory:0.00}".