Indicator · Pine Script v4 · On the chart

CRUDE OIL BUY/SELL

by DaniilOkrug· code credited to nicks1008

This overlay indicator plots a simple moving average on the crude oil chart and colors it according to RSI extremes and whether price sits above or below the average.

View on GitHub

Repaints

GitHub stars2on the repository
Pine versionv4older, still runs
Lines of code55
Settings4inputs
LicenceMIT
Last update4 years ago15 Dec 2021

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

55 lines of Pine Script v4 from [Order] CRUDE OIL BUYSELL.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

[Order] CRUDE OIL BUYSELL.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © nicks1008

//@version=4
study(title="[Order] CRUDE OIL BUY/SELL",shorttitle="CRUDE Scalp |3 Min",precision=2,overlay=true)

Rsi_value=input(14,title="RSI Length",step=1)
hl=input(75,title="Higher Value of RSI",step=1)
ll=input(25,title="Lower value of RSI",step=1)
rs=rsi(close,Rsi_value)

sma_value=input(50,title="SMA Length",step=1)
sma1=sma(close,sma_value)

dist_SMA=1
candle_length=1

mycolor= iff(rs>=hl or rs<=ll,color.yellow,iff(low> sma1,color.lime,iff(high<sma1,color.red,color.yellow)))
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=crossunder(rs,hl)
llrev_b=crossover(rs,ll) and open<close

buycall=open<close and open>sma1 and cross(close[1],sma1) and close>sma1
sellcall=cross(close,sma1) and open>close
BUY=crossover(close[1],sma1) and close[1]>open[1] and high[0]>high[1] and close[0]>open[0]  
SELL=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.red,text="S",textcolor=color.black,transp=30)
plotshape(BUY,title="BUY",style=shape.labelup,color=color.aqua,text="B",textcolor=color.black,transp=30,location=location.belowbar)

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

plot(sma1,title="SMA",color=mycolor,linewidth=2)
alertcondition(llrev_b,title="Reversal Buy", message="Reversal Buy Alert")
alertcondition(hlrev_s,title="Reversal Sell", message="Reversal Sell Alert")
alertcondition(SELL,title="Sell Signal", message="Sell Alert")
alertcondition(BUY,title="Buy Signal", message="Buy Alert")

Overview

CRUDE OIL BUY/SELL marks buy and sell labels when a prior bar crosses the average and the current candle confirms the direction, plus yellow warning markers when RSI crosses its upper or lower threshold. RSI length, high and low RSI levels, and SMA length are the main settings. The short title targets a three-minute scalp. Signals use the live bar and can change before it closes, and there are no exit rules.

Details

Published by

DaniilOkrug on GitHub

Code credit

nicks1008, as written in the script's header

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Oscillators & momentum, Moving averages, Scalping

Markets

Oil & commodities

Timeframes

M1-M5

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

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 RSIint75hl
Lower value of RSIint25ll
SMA Lengthint50sma_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

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

SPY 0DTE Scalper - 1m

by chris-c-thomas
14 stars

This overlay indicator marks CALLS and PUTS labels on the price chart when a strict boolean gate of price structure, momentum, volatility, breadth, and candle confirmation all pass. It plots an EMA ribbon with cloud fill, session-anchored VWAP and standard-dev

Indicator v6 ScalpingMoving averages
Updated 6 months ago · MIT GitHub repository of SPY 0DTE Scalper - 1m
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

XAU Scalp v2

by mrme000m
1 stars

XAU Scalp v2 is an indicator that calculates a composite trading score using multiple components for XAUUSD gold. It stacks four EMAs to determine trend direction and strength, overlays SuperTrend signals derived from ATR(10), adds RSI(14) momentum, detects Bo

Indicator v5 ScalpingMoving averages
Updated 6 weeks ago · None stated GitHub repository of XAU Scalp v2
948 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 10 days ago · GPL-3.0 GitHub repository of Adaptive RSI Moving Average

This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers