Library · Pine Script v6 · Library

SaudiTA

by bader61888· code credited to Bader

SaudiTA is a Pine Script v6 library providing technical analysis utility functions tailored for the Saudi market (Tadawul) and general price analysis.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code53
Settings0inputs
LicenceMIT
Last update4 weeks ago22 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new library, select all of the template text and paste. Press Save and give it a name.
  4. 4Publish or import itA library draws nothing. Publish it from the editor, then import its functions in your own scripts.

Source Code

53 lines of Pine Script v6 from SaudiTA.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

SaudiTA.pine
//@version=6
// SPDX-License-Identifier: MIT
// © 2026 Bader Alrashdi — https://github.com/bader61888/saudi-pine-toolkit
// @description Open-source TA helpers for the Saudi market (Tadawul): Cardwell RSI ranges, RSI reversals, volume/spread, Wyckoff spring/upthrust, session.
library("SaudiTA", overlay=true)

//@function Cardwell RSI range regime: 1 = bull range (RSI holds 40-80), -1 = bear range (RSI holds 20-60), 0 = neutral
export cardwellRsiRange(series float src, simple int rsiLen, simple int lookback) =>
    float r = ta.rsi(src, rsiLen)
    float lo = ta.lowest(r, lookback)
    float hi = ta.highest(r, lookback)
    int regime = lo >= 40 ? 1 : hi <= 60 ? -1 : 0
    [r, regime]

//@function Cardwell reversals (confirmed pivotLen bars late). Positive: price higher low + RSI lower low. Negative: price lower high + RSI higher high.
export rsiReversals(series float src, simple int rsiLen, simple int pivotLen) =>
    float r = ta.rsi(src, rsiLen)
    bool pl = not na(ta.pivotlow(r, pivotLen, pivotLen))
    bool ph = not na(ta.pivothigh(r, pivotLen, pivotLen))
    float prevRl = ta.valuewhen(pl, r[pivotLen], 1)
    float prevPl = ta.valuewhen(pl, low[pivotLen], 1)
    float prevRh = ta.valuewhen(ph, r[pivotLen], 1)
    float prevPh = ta.valuewhen(ph, high[pivotLen], 1)
    bool pos = pl and r[pivotLen] < prevRl and low[pivotLen] > prevPl
    bool neg = ph and r[pivotLen] > prevRh and high[pivotLen] < prevPh
    [pos, neg]

//@function Relative volume and relative bar spread vs their SMA
export volumeSpread(simple int len) =>
    float spread = high - low
    float avgV = ta.sma(volume, len)
    float avgS = ta.sma(spread, len)
    float relVol = avgV > 0 ? volume / avgV : na
    float relSpread = avgS > 0 ? spread / avgS : na
    [relVol, relSpread]

//@function Simple Wyckoff spring / upthrust detector
export wyckoffSpringUpthrust(simple int rangeLen, simple int volLen, simple float volMult) =>
    float rl = ta.lowest(low, rangeLen)[1]
    float rh = ta.highest(high, rangeLen)[1]
    float avgV = ta.sma(volume, volLen)
    bool hiVol = volume > avgV * volMult
    bool spring = low < rl and close > rl and hiVol
    bool upthrust = high > rh and close < rh and hiVol
    [spring, upthrust]

//@function True during Tadawul main session: Sun-Thu 10:00-15:00 Asia/Riyadh
export inTadawulSession() =>
    int d = dayofweek(time, "Asia/Riyadh")
    int mins = hour(time, "Asia/Riyadh") * 60 + minute(time, "Asia/Riyadh")
    bool tradingDay = d == dayofweek.sunday or d == dayofweek.monday or d == dayofweek.tuesday or d == dayofweek.wednesday or d == dayofweek.thursday
    bool inHours = timeframe.isintraday ? (mins >= 600 and mins < 900) : true
    tradingDay and inHours

Overview

SaudiTA calculates Cardwell RSI range regimes and delayed pivot-based RSI reversals, evaluates relative volume and bar spread ratios against moving averages, identifies basic Wyckoff spring and upthrust patterns, and checks active trading hours for the Tadawul market. As a reusable code library, it exports standard functions for custom script development rather than plotting directly.

Details

Published by

bader61888 on GitHub

Code credit

Bader, as written in the script's header

Draws

Library (no plots)

Markets

Stocks

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

pinescriptsauditadawultechnical-analysistradingviewwyckoff

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

FunctionLinearRegression

by ricardosantos79
261 stars

This Pine Script v5 library provides functions to calculate and plot linear regression channels using sample point arrays. It evaluates paired X and Y arrays to calculate the regression slope, intercept, fitted values, maximum deviation, minimum deviation, and

Library v5 Trend
Updated 5 years ago · None stated GitHub repository of FunctionLinearRegression

PositionSizing

by iamrichardD
57 stars

This Pine Script v6 library calculates trade position sizes and provides risk management functions for external scripts. It computes position sizes from account equity, percentage risk, and stop-loss distance, and offers dynamic sizing adjustments based on vol

Library v6
Updated 1 year ago · Apache-2.0 GitHub repository of PositionSizing

PineDraw

by 345-strategies
30 stars

PineDraw is a Pine Script v6 library that provides object primitives for drawing and updating price levels on the chart. It enables indicators and strategies to maintain lines, boxes, and labels in place by updating existing objects instead of deleting and rec

Library v6 Support & resistance
Updated 2 weeks ago · MPL-2.0 GitHub repository of PineDraw

TSBStyle

by TradingSignalBot
19 stars

TSBStyle is a helper library designed to provide standardized visual formatting and signal drawing functions across trading strategy indicators. It provides unified color schemes for trade elements such as entries, stop losses, take profits, session ranges, an

Library v6
Updated 3 weeks ago · MIT GitHub repository of TSBStyle

Chart Patterns

by deepentropy
13 stars

Chart Patterns is a Pine Script v6 library designed to scan for and render technical chart patterns directly on the price chart. It defines custom user-defined types to configure scanning parameters, such as Zigzag pivot offsets, error ratios, flat ratios, and

Library v6 Repaints
Updated 6 months ago · MIT GitHub repository of Chart Patterns

AuthLib

by alboogycOdR
6 stars

AuthLib is a Pine Script utility library providing access control and state management structures for technical indicators. It checks callers against a hardcoded array of authorized TradingView usernames before executing operations. The library exports user-de

Library v5 SMC / ICT / price actionSessions & time
Updated 8 months ago · None stated GitHub repository of AuthLib

More libraries

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers