PineCodersTASC

TASC 2023.06 Stochastic Distance Oscillator

█ OVERVIEW

This script implements the stochastic distance oscillator (SDO), a momentum indicator introduced by Vitali Apirine in an article featured in TASC's June 2023 edition of Traders' Tips. The SDO is a variation of the classic stochastic oscillator and is designed to identify overbought and oversold levels, as well as detect bull and bear trend changes.

█ CONCEPTS

Unlike the classic stochastic oscillator, which compares an asset's price to its past price range, the SDO measures the size of the current distance relative to the maximum-minimum distance range over a set number of periods. The current distance is defined as the distance between the current price and the price n periods ago.

The readings of the SDO can be used to identify the following states of the asset price:
  • Uptrend state: the oscillator crosses over 50 from a non-uptrend state.
  • Downtrend state: the oscillator crosses under -50 from a non-downtrend state.
  • Overbought state: the oscillator is in an uptrend and crosses -50 for the first time.
  • Oversold state: the oscillator is in a downtrend and crosses 50 for the first time.
  • Trend continuity: the oscillator crosses 0 in the direction of the current trend.
The script indicates these five conditions using on-chart signals and background coloring.


█ CALCULATIONS

The SDO is calculated as follows:

1. Calculate the distance between the current price and the price n periods ago, as well as the maximum and minimum distances for the selected lookback period. The author recommends using one of two values of n, 14 or 40 bars.

2. Calculate the time series %D that represents the relation between the asset's current distance and its distance range over a loockback period:
%D = (Abs(current distance) − Abs(minimum distance)) / (Abs(maximum distance) − Abs(minimum distance)) * 100

3. Use the calculated %D to obtain the SDO:
  • If the closing price is above the close n periods ago, SDO = %D
  • If the closing price is below the close n periods ago, SDO = −%D
  • If the closing price equals the close n periods ago or the current distance equals the minimum distance, SDO = 0
4. Smooth the SDO using an exponential moving average (​EMA). The author recommends using an EMA in the range from 3 to 6.

Adjustable input parameters include the number of periods n, the lookback period for calculating %D, the smoothing EMA length, and the overbought/oversold threshold level.

Tools and ideas for all Pine coders: www.tradingview.com/u/PineCoders/
Pine news broadcasts: t.me/PineCodersSquawkBox or twitter.com/PineCoders
TASC: traders.com/
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?