Indicator · Pine Script v5 · On the chart

Crude Oil Buy/Sell

by theonetrade· code credited to nicks1008

This indicator calculates a Relative Strength Index (RSI) and a Simple Moving Average (SMA) to identify scalp trading opportunities.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code60
Settings4inputs
LicenceMIT
Last update2 weeks ago8 Nov 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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

60 lines of Pine Script v5 from assets/indicator/bit-exact/intraday_buy_sell_BqkzYNrk.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

intraday_buy_sell_BqkzYNrk.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nicks1008

//@version=5
indicator(title='CRUDE OIL BUY/SELL', shorttitle='CRUDE Scalp |3 Min', precision=2, overlay=true)

Rsi_value = input.int(14, title='RSI Length', step=1)
hl = input.int(80, title='Higher Value of RSI', step=1)
ll = input.int(20, title='Lower value of RSI', step=1)
rs = ta.rsi(close, Rsi_value)

sma_value = input.int(70, title='SMA Length', step=1)
sma1 = ta.sma(close, sma_value)

dist_SMA = 1
candle_length = 1

iff_1 = high < sma1 ? color.new(color.red,30) : color.new(color.yellow,30)
iff_2 = low > sma1 ? color.new(color.lime,30) : iff_1
mycolor = rs >= hl or rs <= ll ? color.new(color.yellow,30) : iff_2
gaps = sma1 + dist_SMA  //Gap between price and SMA for Sell
gapb = sma1 - dist_SMA  //Gap between price and SMA for Buy
chartgap = gaps or gapb  //for both below or above the SMA 
gap1 = sma1 + 5
gapvalue = open / 100 * candle_length  //setting % with its Share price
gapp = high - low > gapvalue  //or rs<50     // Condition for Min candle size to be eligible for giving signal - Buy Calls
gapp2 = high - low > gapvalue  //or rs>55    // Condition for Min candle size to be eligible for giving signal - Sell Calls
bull = open < close and high - low > 2 * gapvalue and close > (high + open) / 2
bear = open > close and high - low > 2 * gapvalue and close < (low + open) / 2


rev1 = rs > 68 and open > close and open > gaps and high - low > gapvalue + 0.5 and low != close  //over red candles  "S" - uptrend
rev1a = rs > 90 and open < close and close > gaps and high != close and open != low  // over green candles"S" - uptrend
sellrev = rev1 or rev1a

rev2 = rs < 50 and open < close and open < gapb and open == low  //over green candles"B"
rev3 = rs < 30 and open > close and high > gapb and open != high and barstate.isconfirmed != bear  //over red candles"B"
rev4 = rs < 85 and close == high and high - low > gapvalue and open < close  //over green candle in both trends
hlrev_s = ta.crossunder(rs, hl)
llrev_b = ta.crossover(rs, ll) and open < close

buycall = open < close and open > sma1 and ta.cross(close[1], sma1) and close > sma1
sellcall = ta.cross(close, sma1) and open > close
BUY = ta.crossover(close[1], sma1) and close[1] > open[1] and high[0] > high[1] and close[0] > open[0]
SELL = ta.crossunder(low[1], sma1) and close[1] < open[1] and low[0] < low[1] and close[0] < open[0]

plotshape(SELL, title='SELL', style=shape.labeldown, color=color.new(color.red, 30), text='S', textcolor=color.new(color.black, 30))
plotshape(BUY, title='BUY', style=shape.labelup, color=color.new(color.aqua, 30), text='B', textcolor=color.new(color.black, 30), location=location.belowbar)

plotshape(hlrev_s, title='Reversal1', style=shape.labeldown, color=color.new(color.yellow, 20), text='!', textcolor=color.new(color.black, 20))
plotshape(llrev_b, title='Reversal2', style=shape.labelup, color=color.new(color.yellow, 20), text='!', textcolor=color.new(color.black, 20), location=location.belowbar)

barcolor(BUY ? color.new(color.green, 0) : SELL ? color.new(color.maroon, 30) : hlrev_s or llrev_b ? color.new(color.yellow, 0) : na)
plot(sma1, title='SMA', color=mycolor, linewidth=1)
alertcondition(hlrev_s or llrev_b, title='Both Reversal Signal', message='Reversal Alert')
alertcondition(SELL or BUY, title='Buy & Sell Signal Both', message='Buy/Sell Alert')
alertcondition(BUY, title='Only Buy Signal', message='Buy Alert')
alertcondition(SELL, title='Only Sell Signal', message='Sell Alert')
alertcondition(hlrev_s , title='Reversal from Top', message='Down Reversal Alert')
alertcondition(llrev_b, title='Reversal from Down', message='Up Reversal Alert')

Overview

Crude Oil Buy/Sell plots the colored SMA line directly on the price chart alongside buy and sell labels when price confirms relative to the moving average. Reversal alert shapes trigger when the RSI crosses specified upper or lower boundary thresholds. Main settings allow customization of the RSI period, RSI threshold levels, and the SMA period.

Details

Published by

theonetrade on GitHub

Code credit

nicks1008, as written in the script's header

Draws

On the price chart

Markets

Oil & commodities

Timeframes

M1-M5, M15-H1

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

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI Lengthint14Rsi_value
Higher Value of RSIint80hl
Lower value of RSIint20ll
SMA Lengthint70sma_value
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

3 stars

This indicator plots a fast and a slow exponential moving average on the price chart and marks buy and sell signals for Bitcoin scalping. A buy appears when the fast EMA crosses above the slow EMA, RSI is above its buy threshold, the MACD line is above its sig

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · MIT GitHub repository of BTC 1–5 min Scalping Signals
947 stars

The Adaptive RSI Moving Average (ARSIMA) is an overlay indicator that dynamically adjusts its smoothing factor based on the Relative Strength Index (RSI). When the RSI moves toward extreme overbought or oversold conditions, the smoothing factor increases to ma

Indicator v4 Moving averagesOscillators & momentum
Updated 5 weeks ago · GPL-3.0 GitHub repository of Adaptive RSI Moving Average

This indicator scans NSE-listed stocks for momentum signals using Supertrend, multiple EMAs, MACD, and stochastic oscillator. It supports continuous or flip signal modes and displays matching setups in a customizable table at the bottom left of the chart. The

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup: Vijay Thakare Option Buying Scalping Setup Scanner
228 stars

TradersPost Trading Checklist is an overlay indicator that evaluates a suite of popular technical conditions for long and short trade setups. It checks session-anchored VWAP, fast and slow EMA alignments and crosses, 200 SMA, RSI overbought or oversold conditi

Indicator v6 Screeners & dashboardsTrend
Updated 4 months ago · None stated GitHub repository of TradersPost Trading Checklist

Daily Trend Filter

by agutinbaigo28
147 stars

Calculates market regime conditions by combining RSI, MACD, and ADX/DMI indicators. It evaluates whether the market is in a strong bullish, strong bearish, neutral, or non-trending regime. The script plots a colored line overlaying the close price to reflect t

Indicator v5 TrendOscillators & momentum
Updated 2 months ago · MIT GitHub repository of Daily Trend Filter

AAPP

by capissimo
114 stars

This indicator plots an adaptive moving average or scaled RSI divergence line directly on the price chart. It calculates dual RSI series to measure momentum divergence, scales the values to the chart's price range, and constructs an adaptive average filtered b

Indicator v4 Moving averagesTrend
Updated 2 years ago · None stated GitHub repository of AAPP

More Trend scripts

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