OPEN-SOURCE SCRIPT

KST Strategy [Skyrexio]

499
Overview

KST Strategy [Skyrexio] leverages Know Sure Thing (KST) indicator in conjunction with the Williams Alligator and Moving average to obtain the high probability setups. KST is used for for having the high probability to enter in the direction of a current trend when momentum is rising, Alligator is used as a short term trend filter, while Moving average approximates the long term trend and allows trades only in its direction. Also strategy has the additional optional filter on Choppiness Index which does not allow trades if market is choppy, above the user-specified threshold. Strategy has the user specified take profit and stop-loss numbers, but multiplied by Average True Range (ATR) value on the moment when trade is open. The strategy opens only long trades.

Unique Features
  1. ATR based stop-loss and take profit. Instead of fixed take profit and stop-loss percentage strategy utilizes user chosen numbers multiplied by ATR for its calculation.
  2. Configurable Trading Periods. Users can tailor the strategy to specific market windows, adapting to different market conditions.
  3. Optional Choppiness Index filter. Strategy allows to choose if it will use the filter trades with Choppiness Index and set up its threshold.


Methodology
The strategy opens long trade when the following price met the conditions:

  1. Close price is above the Alligator's jaw line
  2. Close price is above the filtering Moving average
  3. KST line of Know Sure Thing indicator shall cross over its signal line (details in justification of methodology)
  4. If the Choppiness Index filter is enabled its value shall be less than user defined threshold


When the long trade is executed algorithm defines the stop-loss level as the low minus user defined number, multiplied by ATR at the trade open candle. Also it defines take profit with close price plus user defined number, multiplied by ATR at the trade open candle. While trade is in progress, if high price on any candle above the calculated take profit level or low price is below the calculated stop loss level, trade is closed.

Strategy settings
In the inputs window user can setup the following strategy settings:

  1. ATR Stop Loss (by default = 1.5, number of ATRs to calculate stop-loss level)
  2. ATR Take Profit (by default = 3.5, number of ATRs to calculate take profit level)
  3. Filter MA Type (by default = Least Squares MA, type of moving average which is used for filter MA)
  4. Filter MA Length (by default = 200, length for filter MA calculation)
  5. Enable Choppiness Index Filter (by default = true, setting to choose the optional filtering using Choppiness index)
  6. Choppiness Index Threshold (by default = 50, Choppiness Index threshold, its value shall be below it to allow trades execution)
  7. Choppiness Index Length (by default = 14, length used in Choppiness index calculation)
  8. KST ROC Length #1 (by default = 10, value used in KST indicator calculation, more information in Justification of Methodology)
  9. KST ROC Length #2 (by default = 15, value used in KST indicator calculation, more information in Justification of Methodology)
  10. KST ROC Length #3 (by default = 20, value used in KST indicator calculation, more information in Justification of Methodology)
  11. KST ROC Length #4 (by default = 30, value used in KST indicator calculation, more information in Justification of Methodology)
  12. KST SMA Length #1 (by default = 10, value used in KST indicator calculation, more information in Justification of Methodology)
  13. KST SMA Length #2 (by default = 10, value used in KST indicator calculation, more information in Justification of Methodology)
  14. KST SMA Length #3 (by default = 10, value used in KST indicator calculation, more information in Justification of Methodology)
  15. KST SMA Length #4 (by default = 15, value used in KST indicator calculation, more information in Justification of Methodology)
  16. KST Signal Line Length (by default = 10, value used in KST indicator calculation, more information in Justification of Methodology)



User can choose the optimal parameters during backtesting on certain price chart.

Justification of Methodology
Before understanding why this particular combination of indicator has been chosen let's briefly explain what is KST, Williams Alligator, Moving Average, ATR and Choppiness Index.

The KST (Know Sure Thing) is a momentum oscillator developed by Martin Pring. It combines multiple Rate of Change (ROC) values, smoothed over different timeframes, to identify trend direction and momentum strength. First of all, what is ROC? ROC (Rate of Change) is a momentum indicator that measures the percentage change in price between the current price and the price a set number of periods ago.

ROC = 100 * (Current Price - Price N Periods Ago) / Price N Periods Ago

In our case N is the KST ROC Length inputs from settings, here we will calculate 4 different ROCs to obtain KST value:

KST = ROC1_smooth × 1 + ROC2_smooth × 2 + ROC3_smooth × 3 + ROC4_smooth × 4

ROC1 = ROC(close, KST ROC Length #1), smoothed by KST SMA Length #1,
ROC2 = ROC(close, KST ROC Length #2), smoothed by KST SMA Length #2,
ROC3 = ROC(close, KST ROC Length #3), smoothed by KST SMA Length #3,
ROC4 = ROC(close, KST ROC Length #4), smoothed by KST SMA Length #4


Also for this indicator the signal line is calculated:

Signal = SMA(KST, KST Signal Line Length)

When the KST line rises, it indicates increasing momentum and suggests that an upward trend may be developing. Conversely, when the KST line declines, it reflects weakening momentum and a potential downward trend. A crossover of the KST line above its signal line is considered a buy signal, while a crossover below the signal line is viewed as a sell signal. If the KST stays above zero, it indicates overall bullish momentum; if it remains below zero, it points to bearish momentum. The KST indicator smooths momentum across multiple timeframes, helping to reduce noise and provide clearer signals for medium- to long-term trends.

Next, let’s discuss the short-term trend filter, which combines the Williams Alligator and Williams Fractals. Williams Alligator

Developed by Bill Williams, the Alligator is a technical indicator that identifies trends and potential market reversals. It consists of three smoothed moving averages:
  • Jaw (Blue Line): The slowest of the three, based on a 13-period smoothed moving average shifted 8 bars ahead.
  • Teeth (Red Line): The medium-speed line, derived from an 8-period smoothed moving average shifted 5 bars forward.
  • Lips (Green Line): The fastest line, calculated using a 5-period smoothed moving average shifted 3 bars forward.


When the lines diverge and align in order, the "Alligator" is "awake," signaling a strong trend. When the lines overlap or intertwine, the "Alligator" is "asleep," indicating a range-bound or sideways market. This indicator helps traders determine when to enter or avoid trades.

The next indicator is Moving Average. It has a lot of different types which can be chosen to filter trades and the Least Squares MA is used by default settings. Let's briefly explain what is it.
The Least Squares Moving Average (LSMA) — also known as Linear Regression Moving Average — is a trend-following indicator that uses the least squares method to fit a straight line to the price data over a given period, then plots the value of that line at the most recent point. It draws the best-fitting straight line through the past N prices (using linear regression), and then takes the endpoint of that line as the value of the moving average for that bar. The LSMA aims to reduce lag and highlight the current trend more accurately than traditional moving averages like SMA or EMA.
Key Features:
  • It reacts faster to price changes than most moving averages.
  • It is smoother and less noisy than short-term EMAs.
  • It can be used to identify trend direction, momentum, and potential reversal points.


ATR (Average True Range) is a volatility indicator that measures how much an asset typically moves during a given period. It was introduced by J. Welles Wilder and is widely used to assess market volatility, not direction.
To calculate it first of all we need to get True Range (TR), this is the greatest value among:
  • High - Low
  • abs(High - Previous Close)
  • abs(Low - Previous Close)


ATR = MA(TR, n), where n is number of periods for moving average, in our case equals 14.

ATR shows how much an asset moves on average per candle/bar. A higher ATR means more volatility; a lower ATR means a calmer market.

The Choppiness Index is a technical indicator that quantifies whether the market is trending or choppy (sideways). It doesn't indicate trend direction — only the strength or weakness of a trend. Higher Choppiness Index usually approximates the sideways market, while its low value tells us that there is a high probability of a trend.

Choppiness Index = 100 × log10(ΣATR(n) / (MaxHigh(n) - MinLow(n))) / log10(n)

where:
  • ΣATR(n) = sum of the Average True Range over n periods
  • MaxHigh(n) = highest high over n periods
  • MinLow(n) = lowest low over n periods
  • log10 = base-10 logarithm


Now let's understand how these indicators work in conjunction and why they were chosen for this strategy. KST indicator approximates current momentum, when it is rising and KST line crosses over the signal line there is high probability that short term trend is reversing to the upside and strategy allows to take part in this potential move. Alligator's jaw (blue) line is used as an approximation of a short term trend, taking trades only above it we want to avoid trading against trend to increase probability that long trade is going to be winning.

Almost the same for Moving Average, but it approximates the long term trend, this is just the additional filter. If we trade in the direction of the long term trend we increase probability that higher risk to reward trade will hit the take profit. Choppiness index is the optional filter, but if it turned on it is used for approximating if now market is in sideways or in trend. On the range bounded market the potential moves are restricted. We want to decrease probability opening trades in such condition avoiding trades if this index is above threshold value.

When trade is open script sets the stop loss and take profit targets. ATR approximates the current volatility, so we can make a decision when to exit a trade based on current market condition, it can increase the probability that strategy will avoid the excessive stop loss hits, but anyway user can setup how many ATRs to use as a stop loss and take profit target. As was said in the Methodology stop loss level is obtained by subtracting number of ATRs from trade opening candle low, while take profit by adding to this candle's close.

Backtest Results
  • Operating window: Date range of backtests is 2023.01.01 - 2025.05.01. It is chosen to let the strategy to close all opened positions.
  • Commission and Slippage: Includes a standard Binance commission of 0.1% and accounts for possible slippage over 5 ticks.
  • Initial capital: 10000 USDT
  • Percent of capital used in every trade: 60%
  • Maximum Single Position Loss: -5.53%
  • Maximum Single Profit: +8.35%
  • Net Profit: +5175.20 USDT (+51.75%)
  • Total Trades: 120 (56.67% win rate)
  • Profit Factor: 1.747
  • Maximum Accumulated Loss: 1039.89 USDT (-9.1%)
  • Average Profit per Trade: 43.13 USDT (+0.6%)
  • Average Trade Duration: 27 hours


These results are obtained with realistic parameters representing trading conditions observed at major exchanges such as Binance and with realistic trading portfolio usage parameters.

How to Use
Add the script to favorites for easy access.
Apply to the desired timeframe and chart (optimal performance observed on 1h BTC/USDT).
Configure settings using the dropdown choice list in the built-in menu.
Set up alerts to automate strategy positions through web hook with the text: {{strategy.order.alert_message}}

Disclaimer:
Educational and informational tool reflecting Skyrexio commitment to informed trading. Past performance does not guarantee future results. Test strategies in a simulated environment before live implementation.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.