Indicator · Pine Script v4 · On the chart

Poison Rat v2.1 - DataCrypto Analytics

by datacrypto-analytics

This indicator tracks multi-timeframe moving average crosses directly on the price chart.

View on GitHub

Repaints

GitHub stars3on the repository
Pine versionv4older, still runs
Lines of code94
Settings4inputs
LicenceApache-2.0
Last update3 years ago15 Oct 2023

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

94 lines of Pine Script v4 from poison_rat_v2.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

poison_rat_v2.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DataCrypto Analytics 
//
// https://datacryptoanalytics.com/
//
// Twitter: @dc_analytics
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////
//@version=4
study("Poison Rat v2.1 - DataCrypto Analytics", "", true)
////////////////////////////////////////////////////////////////////////////////////////////////////////////
///        COLETA DE DADOS
///////////////////////////////////////////////////////////////////////////////////////////////////////////
tempo     = input("30", title = "🕗 Timeframe", group   = "Configurações ⚙️", type = input.resolution, options = ["1","5","15","30","60", "120", "240","360","720", "D", "W"])
showcross = input(true, "Mostrar Sinais")
lime      = color.new(#17a302, 0)
verde     = color.new(#1b5e20, 0)
verm      = color.new(#811c1c, 0)
red       = color.new(#a30202, 0)
bran      = color.new(#ffffff, 65)

up        = close > open 
down      = open > close

vol       = volume
silver    = color.silver
gray      = color.new(#4a4a49, 0)
azu       = color.new(#ff8c05, 0)
// RMA = Média móvel usada no RSI. É a média móvel ponderada exponencialmente com alfa = 1/comprimento.
s         = rma(close, 16)
v         = rma(close, 4)
k         = rma(close, 9)
sma1      = sma(close,100)
sma2      = sma(close,200)
////////////////////////////////////////////////////////////////////////////////////////////////////////////
///    PERCEBE CRUZAMENTO DAS MÉDIAS MÓVEIS
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// 200 sma fica acima da 100sma "SMA X ⇡" 200 sma fica abaixo da 100sma "SMA X ⇣"
xUp       = crossover(sma2, sma1)
xDw       = crossunder(sma2, sma1)
a         = security(syminfo.tickerid, tempo, s)
b         = security(syminfo.tickerid, tempo, v)
r         = security(syminfo.tickerid, tempo, k)
c         = b > a ? lime : red
crossdn   = a > b and a[1] < b[1]
crossup   = b > a and b[1] < a[1]
crossx    = b > r and b[1] < r[1]

plotshape(showcross and crossdn ? a : na, location=location.abovebar, style=shape.labeldown, color=verm, title="Mostrar Venda",size=size.tiny, text = "⇣", textcolor=color.red, offset=0)
plotshape(showcross and crossup ? a : na, location=location.belowbar, style=shape.labelup, color=verde, title="Mostrar Compra",size=size.tiny, text = "⇡", textcolor=color.green, offset=0)
plotshape(xDw, location=location.belowbar, style=shape.labelup, color=color.black, title="Tendência ⇡",size=size.small, text = "T ⇡", textcolor=color.green, offset=0)
plotshape(xUp, location=location.abovebar, style=shape.labeldown, color=color.black, title="Tendência ⇣",size=size.small, text = "T ⇣", textcolor=color.red, offset=0)

//fill(P1, P2, color=#e07800, transp=92)

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//   PLOT COLOR CANDLES
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
barcolor((showcross and crossup)? lime:(showcross and crossdn)?red:up?silver:gray)


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//   PLOT TABELA
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var table perfTable = table.new(position.top_right, 3, 2, border_width = 3)

LIGHTTRANSP = 90
AVGTRANSP   = 80
HEAVYTRANSP = 70

i_posColor = input(color.rgb(38, 166, 154), title="Positive Color")
i_negColor = input(color.rgb(240, 83, 80), title="Negative Color")

f_rateOfreturn(_v1, _v2) => (_v1 - _v2) * 100 / abs(_v2)

f_performance(_barsBack) =>
    _performance = security(syminfo.tickerid, "1D", f_rateOfreturn(close, close[_barsBack]))
    _performance
   
lastYearClose = security(syminfo.tickerid, "12M", close[1], lookahead=barmerge.lookahead_on)

f_fillCell(_table, _column, _row, _value, _timeframe) =>
    _c_color = _value >= 0 ? i_posColor : i_negColor
    _transp = abs(_value) > 10 ? HEAVYTRANSP : abs(_value) > 5 ? AVGTRANSP : LIGHTTRANSP
    _cellText = tostring(_value, "#.##") + "%\n" + _timeframe
    table.cell(_table, _column, _row, _cellText, bgcolor = color.new(_c_color, _transp), text_color = _c_color, width = 6)

if barstate.islast
    f_fillCell(perfTable, 0, 0, f_performance(5), "1W")
    f_fillCell(perfTable, 1, 0, f_performance(21), "1M")
    f_fillCell(perfTable, 2, 0, f_performance(63), "3M")
    f_fillCell(perfTable, 0, 1, f_performance(126), "6M")
    f_fillCell(perfTable, 1, 1, f_rateOfreturn(close, lastYearClose), "YTD")
    f_fillCell(perfTable, 2, 1, f_performance(251), "1Y")

Overview

Poison Rat v2.1 - DataCrypto Analytics evaluates three Running Moving Averages (RMA lengths 4, 9, and 16) fetched from a user-selected secondary timeframe alongside 100-period and 200-period Simple Moving Averages from the current chart. Signals are displayed as directional labels for RMA crosses and SMA trend changes, while candles are color-coded to highlight active buy or sell conditions. Cross signals can repaint on unconfirmed higher-timeframe bars.

Details

Published by

datacrypto-analytics on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Moving averages, Trend

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

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

Topics

cryptotradingtradingviewtradingview-pine-scripts

Settings

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

SettingTypeDefaultVariable
🕗 Timeframetimeframe30tempo
Mostrar Sinaisbooltrueshowcross
Positive Colorcolorcolor.rgb(38, 166, 154)i_posColor
Negative Colorcolorcolor.rgb(240, 83, 80)i_negColor
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

948 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 10 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter
330 stars

This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab

Indicator v4 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of 3 EMA/SMA + Cross [Alorse]
318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon
257 stars

Donald SPX - Options Trading is an overlay indicator designed for intraday SPX analysis. It plots a 200-period Weighted Moving Average (WMA) on the price chart while evaluating multi-timeframe market structure across Daily, 15-minute, 5-minute, and 2-minute ba

Indicator v5 Moving averagesTrend Repaints
Updated 6 weeks ago · None stated GitHub repository of Donald SPX - Options Trading

60K均線

by TaichiS
219 stars

This multi-timeframe indicator calculates and plots 20-period and 60-period simple moving averages from the 60-minute timeframe directly onto the price chart. The 20-period average displays as a green line, while the 60-period average appears in blue. It serve

Indicator v4 Moving averagesTrend Repaints
Updated 5 years ago · None stated GitHub repository of 60K均線

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