RSI Difference (Fast and Slow)Introduction
Oscillators like the RSI are fundamental tools for identifying trends in financial markets. Their ability to measure price momentum allows traders to detect overbought, oversold levels, and divergences, anticipating trend changes. Are there ways to improve the use of traditional RSI? How can we obtain more detailed information about current trends? This indicator answers these questions by expanding the functionalities of the traditional RSI and offering an additional tool for analysis.
How does it work?
This indicator provides a framework for trend analysis based on the following setup:
Fast RSI
Slow RSI
SMA of the fast RSI
SMA of the slow RSI
Histogram
Custom Indicator Settings
My preferred configuration is based on the 13 and 55 moving averages. The rest of the setup is as follows:
I typically use the 13 and 55 moving averages to configure both the RSI and short- and long-term moving averages.
Interpretation and Signals: Including a Long-Period RSI
Including a long-period RSI helps identify key patterns in market behavior. Crossovers between the two can be used to establish entry patterns:
If the fast RSI crosses above the slow RSI, this could indicate a long-entry pattern.
If the fast RSI crosses below the slow RSI, this could indicate a short-entry pattern.
Interpretation and Signals: Including Moving Averages
Including moving averages for both the short- and long-period RSI can help identify the base trend of the movement and, consequently:
Avoid false signals.
Trade in favor of the trend.
A simple way to start working with these is to use the crossover of the moving averages to identify the current trend:
If the short-period SMA is above the long-period SMA, the trend is bullish.
If the short-period SMA is below the long-period SMA, the trend is bearish.
Interpretation and Signals: The Histogram
The histogram represents the difference between the moving averages. If the histogram is positive, the short average is above the long average. If the histogram is below zero, the short average is below the long average. Divergences with price provide signals of potential exhaustion in the movement, indicating a possible reversal.
Indicator Details
This indicator builds upon the traditional RSI by integrating additional features that enhance its utility for traders. Here’s how each component is calculated and how they contribute to the originality of the script:
Fast RSI and Slow RSI: The fast RSI is calculated using a shorter lookback period, allowing it to capture rapid changes in momentum. The slow RSI uses a longer period to smooth out fluctuations and provide a broader view of the trend. These two RSIs work together to identify significant momentum shifts.
SMA of RSI values: The simple moving averages (SMA) of the fast and slow RSI help filter out noise and provide clear crossover signals. The SMAs are calculated using standard formulas but applied to the RSI values rather than price data, which adds a layer of insight into momentum trends.
Histogram calculation: The histogram represents the difference between the SMA of the fast RSI and the SMA of the slow RSI. This value gives a visual representation of the convergence or divergence of momentum. When the histogram crosses zero, it signifies a potential shift in the underlying trend.
This indicator combines multiple layers of analysis: fast and slow momentum, trend confirmation through SMAs, and divergence detection via the histogram. This multi-dimensional approach provides traders with a more comprehensive tool for trend analysis and decision-making.
Conclusion
This article has explored how to use this indicator to identify trends, leverage entry patterns, and analyze divergences by combining the fast RSI, slow RSI, their moving averages, and a histogram. Additionally, I’ve detailed how I usually interpret this indicator:
Identifying RSI patterns to anticipate momentum changes.
Using SMAs to confirm base trends.
Leveraging the histogram to detect divergences and potential price reversals.
Indicators and strategies
ROI Levels IndicatorROI Levels Indicator 📈💰
Description: The "ROI Levels Indicator" helps you visualize key Return on Investment (ROI) levels directly on your chart, making it easier to track your profit milestones! 🚀 This tool allows you to enter your entry price, and it calculates levels from 100% up to 1000% ROI, each with a spread to represent potential support and resistance zones. The levels are visually represented by red rectangles to help identify zones where the market might react. This is a great way for traders to easily understand profit-taking points and psychological price levels!
Features:
🛠️ Custom Entry Price: Set your own entry price to start calculating ROI levels.
📊 Multiple ROI Levels: Levels from 100% to 1000%, with a customizable spread for visual clarity.
🔴 Visual Representation: Each level is marked with a full-screen-width rectangle and label, making it easy to track.
🚨 Entry Price Plot: A red dashed line marks your entry price for easy reference.
How to Use:
Enter Your Price: Use the "Entry Price" input field to specify the entry price of your trade.
Spread Adjustment: Adjust the spread percentage if you want more or less tolerance around each ROI level.
View the Levels: The script automatically plots 100% to 1000% ROI levels. Each level is represented by a red rectangle and labeled on the right side for quick identification.
Track Profit Zones: Use the plotted ROI levels to identify key profit-taking areas or potential zones of support and resistance.
Pro Tip: Use these levels as reference points to decide when to scale out of positions or manage risk effectively! 🎯
Happy trading, and may your ROI always be on the rise! 📈🔥
Buy/Sell [WynTrader]This Indicator "Buy/Sell " has been built to suggest Buy/Sell points on a chart, using the standard TradingView SMI (Stochastic Momentum Index).
These Buy/Sell signals should not be used as like it for your own trading, without effective technical and fundamental analysis to guide your trading decision.
VWAP and MA Mean Reversion Strategy with ATR Stop Loss//@version=5
strategy("VWAP and MA Mean Reversion Strategy with ATR Stop Loss", overlay=true)
// Inputs
length = input(14, "MA Length")
atrLength = input(14, "ATR Length")
atrMultiplier = input(1.5, title="ATR Multiplier for Stop Loss")
// Calculate VWAP, Moving Average, and ATR
vwap = ta.vwap(hlc3)
ma = ta.sma(close, length)
atr = ta.atr(atrLength)
// Buy condition: Price is below VWAP but above MA
longCondition = close < vwap and close > ma
if (longCondition)
strategy.entry("Buy", strategy.long)
stopPrice = close - atrMultiplier * atr
strategy.exit("Long Stop Loss", "Buy", stop=stopPrice)
// Sell condition: Price is above VWAP but below MA
shortCondition = close > vwap and close < ma
if (shortCondition)
strategy.entry("Sell", strategy.short)
stopPrice = close + atrMultiplier * atr
strategy.exit("Short Stop Loss", "Sell", stop=stopPrice)
// Plotting
plot(vwap, title="VWAP", color=color.blue)
plot(ma, title="MA", color=color.orange)
Análisis de Rango y Predicción con Bloques de Orden y EMA LogaríEste script combina medias móviles exponenciales logarítmicas (EMA) ajustadas dinámicamente con la detección de bloques de orden en el gráfico diario de Bitcoin (BTC). Calcula niveles clave basados en volumen y precio, identifica zonas de alta actividad institucional por debajo y por encima de las EMAs, y proyecta tendencias futuras mediante regresión lineal y ajustes dinámicos de RSI. Ideal para traders que buscan un análisis técnico preciso y adaptativo para optimizar su estrategia en el mercado.
SMA (5,20,50)This script adds three Simple Moving Averages (SMA) to your chart with periods of 5, 20, and 50. It visually highlights the trends by shading the areas between these lines:
- Green shading: Indicates an upward trend, where the shorter SMA is above the longer SMA.
- Red shading: Indicates a downward trend, where the shorter SMA is below the longer SMA.
The shading uses different opacities to show the strength of the trend. This helps you quickly identify potential buying or selling opportunities.
Quantum Transform - AynetQuantum Transform Trading Indicator: Explanation
This script is called a "Quantum Transform Trading Indicator" and aims to enhance market analysis by applying complex mathematical models. Written in Pine Script, the indicator includes the following elements:
1. General Structure
Quantum Parameters: Inspired by physical and mathematical concepts (Planck constant ℏ, wave function Ψ, time τ, etc.), it uses specific parameters.
Transformation Functions: Applies various mathematical operations to transform price data in different ways.
Signal Generation: Produces signals for long and short positions.
Visualization: Displays different price transformations and signals on the chart.
2. Core Parameters
The parameters allow users to control various transformations:
Planck Constant (ℏ): A scaling factor for wave modulation.
Wave (Ψ): Controls oscillation in price data.
Time (τ): The length of the lookback period for calculations.
Relativity (γ): Power factor in the Lorentz transformation.
Phase Shift (β): Manages phase shift in transformations.
Frequency (ω): Represents the frequency of price movements.
Dimensions (∇): Enables multi-dimensional field analysis.
3. Functions
a) Relativistic Transform
Inspired by the theory of relativity.
Calculates the Lorentz factor using the rate of price change.
Transforms price data to amplify the relativity effect.
b) Phase Transform
Calculates the phase of price data and applies wave modulation.
Creates phase and amplitude modulation based on the bar index.
c) Resonance Transform
Calculates resonance effects using natural frequency and oscillations.
Highlights periodic behaviors of price movements.
d) Field Transform
Applies multi-dimensional field calculations.
Combines strength, wave, and coherence aspects of price data.
e) Chaos Transform
Implements a chaos effect based on sensitivity analysis.
Simulates chaotic behaviors of price movements.
4. Main Calculations
Quantum Price: The average of all transformation functions.
Bands:
Upper Band: The highest level of quantum price.
Lower Band: The lowest level of quantum price.
Mid Band: The average of upper and lower bands.
Momentum: Calculates the rate of change in quantum price.
5. Signal Generation
Long Signal:
Triggered when the phase price crosses above the field price.
Momentum must be positive, and the price above the mid-band.
Short Signal:
Triggered when the phase price crosses below the field price.
Momentum must be negative, and the price below the mid-band.
Signal strength is calculated relative to the momentum moving average.
6. Visualization
Each transformation is displayed in a unique color.
Bands and Momentum: Visualize price behavior.
Signal Icons: Show buy/sell signals using up/down arrows on the chart.
7. Information Panel
A table in the top-right corner of the chart displays:
The current values of each transformation.
Signal strength (as a percentage).
The type of signal (⬆: Long, ⬇: Short).
Applications
Trend Following: Analyze trends with complex transformations.
Resonance and Chaos Analysis: Understand dynamic behaviors of price.
Signal Strategies: Create strong and reliable buy/sell signals.
If you have any additional questions or customization requests regarding this indicator, feel free to ask!
Nifty 50 Buy/Sell IndicatorThe Nifty 50 Buy/Sell Indicator is a technical analysis tool designed to help traders make informed decisions regarding buying and selling stocks within the Nifty 50 index, which represents the top 50 companies listed on the National Stock Exchange of India. This indicator utilizes various methodologies to assess market conditions, identify trends, and generate actionable signals.
Moving Averages 5in1 - RajShahI created an indicator via coding which provides you 5 moving averages in 1 indicator (as TradingView does not allow to use more than 2 indicators). Paste the below in pine editor and run the same.
Raccoon SupremeStrategy that shows signal for long and short when the RSI goes above a certain level
Indice IA Crypto étenduCréation d'un tracket crypto sur la thématique IA approximatif. Première version.
Prise en compte de différentes crypto dans le top 15, surtour de la nouvelle génération.
Mise à jour soon
Adapted RSI w/ Multi-Crypto Regime Detection v1.1Description:
This adapted RSI (Relative Strength Index) indicator combines multi-timeframe analysis with multi-cryptocurrency monitoring, offering traders a comprehensive view of market conditions across different assets and time horizons.
Key Features:
Multi-Timeframe Analysis: Monitors Daily, Weekly, and Monthly RSI values simultaneously
Multi-Crypto Tracking: Compare RSI readings across 4 different cryptocurrencies (this can be increased if requested)
Regime Detection: Automatically identifies market regimes (Bullish/Bearish)
Smart Signal Generation: Provides trading signals based on customizable RSI levels
Dynamic Color Coding: Visual color indicators for different market conditions
Dual Table Display: Separate tables for timeframe analysis and comparison between tickers
Customisation
RSI Settings: Adjustable length and overbought/oversold levels
Crypto Selection: Choose any 4 cryptocurrency pairs to monitor
Visual Settings: Customize colors, line styles, and table positions
Table Display: Flexible positioning and formatting options
Regime Detection:
Strong Buy: RSI below 15
Buy: RSI below 30
Neutral: RSI between 30-70
Sell: RSI above 70
Strong Sell: RSI above 85
Perfect for traders who want to :
Monitor multiple cryptocurrencies simultaneously
Analyze market conditions across different timeframes
Identify potential trend changes and market regimes
Get clear trading signals based on RSI levels
Compare market strength across different crypto assets
The indicator helps identify potential entry and exit points while providing a broader market context through its multi-timeframe and multi-crypto RSI analysis.
Coming soon...
RSI Divergence plotting
[CM][I] 4-hour based on ANY lowest candle of the TF indicatorThis indicator shows a 4 hour candle on any timeframe below it. You can check how the price behaved within the 4 hour candle and see how your trading system would behave more accurately in real trading.
Scalping Strategy with Visible TP/SL Lines By Call_Me_PROred dashed line = stop loss
green dashed line = target profit
green line = entry line
If it is going under 50 ema line or over you can set trailing stop loss to make more profit.
And try to make entries in more volatile markets like gold in London session or NY.
Created by Call_Me_PRO
Volume TrendCombines volume histogram with a 21 day moving average to make it easier to see if volume is increasing or decreasing. simple.
It helps me - Hope it helps you! :)
btckaninkolo: supertrendbtckaninkolo: supertrend on trendiperusteinen indikaattori, joka hyödyntää kolmea erillistä SuperTrend-laskentaa vahvistamaan markkinoiden nousevia ja laskevia trendejä. Trendi määritellään selkeäksi, kun kaikki kolme viivaa osoittavat samaan suuntaan. Tämä indikaattori soveltuu erityisesti trendaaville markkinoille, joissa se auttaa tunnistamaan tukitasot, vastustasot sekä potentiaaliset trendin käännökset.
Ominaisuudet:
Kolme erillistä SuperTrend-viivaa (säädettävät pituudet ja multiplaattorit).
Kynttilöiden värjäys trendin mukaan:
Punainen: Nouseva vahva trendi.
Vihreä: Laskeva vahva trendi.
Ei väriä: Ei selkeää trendiä.
Soveltuu erityisesti pitkien trendien vahvistamiseen ja niiden seuraamiseen.
Miten käyttää:
Odota, että kaikki kolme SuperTrend-viivaa muuttuvat samaan suuntaan:
Kaikki vihreinä = nouseva trendi.
Kaikki punaisina = laskeva trendi.
Käytä yhdessä muiden indikaattorien, kuten RSI:n tai MACD:n, kanssa vahvistamaan signaaleja.
Huomioi, että sivuttaisliikkeissä (range) voi esiintyä virhesignaaleja.
Indikaattorin avulla voit tunnistaa keskeiset tukitasot ja vastustasot sekä vahvistaa kauppojen suuntaa tehokkaasti trendaavilla markkinoilla.
CPR-EMA-VWAPThe Indicator Plot as Below.
1) CPR
2) Support
3) Resistance
4) Tomorrow CPR and S1 Support and R1 Resistance
5) Previous Day High and Low
6) 5, 13, 26, 50, 200 EMAs
7) Daily, Weekly and Monthly VWAPs
Option to enable and Disable various components are available in Setting
Colour change is also possible in Settings
All the Best !!
Indicator DashboardThis script creates an 'Indicator Dashboard' designed to assist you in analyzing financial markets and making informed decisions. The indicator provides a summary of current market conditions by presenting various technical analysis indicators in a table format. The dashboard evaluates popular indicators such as Moving Averages, RSI, MACD, and Stochastic RSI. Below, we'll explain each part of this script in detail and its purpose:
### Overview of Indicators
1. **Moving Averages (MA)**:
- This indicator calculates Simple Moving Averages (“SMA”) for 5, 14, 20, 50, 100, and 200 periods. These averages provide a visual summary of price movements. Depending on whether the price is above or below the moving average, it determines the market direction as either “Bullish” or “Bearish.”
2. **RSI (Relative Strength Index)**:
- The RSI helps identify overbought or oversold market conditions. Here, the RSI is calculated for a 14-period window, and this value is displayed in the table. Additionally, the 14-period moving average of the RSI is also included.
3. **MACD (Moving Average Convergence Divergence)**:
- The MACD indicator is used to determine trend strength and potential reversals. This script calculates the MACD line, signal line, and histogram. The MACD condition (“Bullish,” “Bearish,” or “Neutral”) is displayed alongside the MACD and signal line values.
4. **Stochastic RSI**:
- Stochastic RSI is used to identify momentum changes in the market. The %K and %D lines are calculated to determine the market condition (“Bullish” or “Bearish”), which is displayed along with the calculated values for %K and %D.
### Table Layout and Presentation
The dashboard is presented in a vertical table format in the top-right corner of the chart. The table contains two columns: “Indicator” and “Status,” summarizing the condition of each technical indicator.
- **Indicator Column**: Lists each of the indicators being tracked, such as SMA values, RSI, MACD, etc.
- **Status Column**: Displays the current status of each indicator, such as “Bullish,” “Bearish,” or specific values like the RSI or MACD.
The table also includes rounded indicator values for easier interpretation. This helps traders quickly assess market conditions and make informed decisions based on multiple indicators presented in a single location.
### Detailed Indicator Status Calculations
1. **SMA Status**: For each moving average (5, 14, 20, 50, 100, 200), the script checks if the current price is above or below the SMA. The status is determined as “Bullish” if the price is above the SMA and “Bearish” if below, with the value of the SMA also displayed.
2. **RSI and RSI Average**: The RSI value for a 14-period is displayed along with its 14-period SMA, which provides an average reading of the RSI to smooth out volatility.
3. **MACD Indicator**: The MACD line, signal line, and histogram are calculated using standard parameters (12, 26, 9). The status is shown as “Bullish” when the MACD line is above the signal line, and “Bearish” when it is below. The exact values for the MACD line, signal line, and histogram are also included.
4. **Stochastic RSI**: The %K and %D lines of the Stochastic RSI are used to determine the trend condition. If %K is greater than %D, the condition is “Bullish,” otherwise it is “Bearish.” The actual values of %K and %D are also displayed.
### Conclusion
The 'Indicator Dashboard' provides a comprehensive overview of multiple technical indicators in a single, easy-to-read table. This allows traders to quickly gauge market conditions and make more informed decisions. By consolidating key indicators like Moving Averages, RSI, MACD, and Stochastic RSI into one dashboard, it saves time and enhances the efficiency of technical analysis.
This script is particularly useful for traders who prefer a clean and organized overview of their favorite indicators without needing to plot each one individually on the chart. Instead, all the crucial information is available at a glance in a consolidated format.
TechniTrend: CandleMetrics🟦 Overview
The TechniTrend: CandleMetrics Indicator is a powerful tool designed to give traders an in-depth analysis of candlestick structures. This indicator allows users to identify potential reversal points, trend continuations, and other crucial market behaviors by examining key ratios between candle components—such as body, shadow, and overall range—alongside volume conditions. The advanced filtering options offer flexibility for both novice and experienced traders, enabling tailored setups to suit different trading strategies.
🟦 Key Features
🔸Customizable Ratios: Set thresholds for Body-to-Range, Shadow-to-Range, Upper Shadow-to-Range, and Lower Shadow-to-Range ratios.
🔸Volume-Based Filters: Integrate volume conditions to strengthen the reliability of signals.
🔸Flexible Conditions: Choose whether filters should work independently or in combination, allowing for precise pattern identification.
🔸Visual Markers: Mark potential signals with a distinct background color and symbols on the chart.
🔸Alerts: Receive notifications for each selected condition, ensuring you never miss an opportunity.
🟦 How It Works
The CandleMetrics Indicator operates by analyzing the relationship between different components of each candlestick, combined with volume data to determine the strength of signals. Here’s a detailed breakdown of each feature:
🔸 Body to Range Ratio:
This filter compares the size of the candle's body to its total range (from high to low).
Example Setting: If you’re interested in spotting candles with small bodies relative to their total range, you might set the Body-to-Range Ratio to “Less than 0.3.”
🔸 Shadow to Range Ratio:
This examines the combined size of both shadows (upper and lower) relative to the entire candle range.
Example Setting: Use a Shadow-to-Range Ratio set to “More than 0.8” to find candles with significant wick lengths, suggesting market indecision.
🔸 Upper Shadow to Range Ratio:
This filter assesses the proportion of the upper shadow (wick) in relation to the candle’s full range.
Example Setting: “Less than 0.05” can help identify situations where the upper shadow is minimal, indicating strong downward pressure.
🔸 Lower Shadow to Range Ratio:
It measures the lower shadow compared to the entire candle range.
Example Setting: “More than 0.7” is useful for detecting potential rejection patterns at lower prices, hinting at a possible bullish reversal.
🔸 Volume Filter:
Integrates volume data to verify the reliability of each candle pattern.
Example Setting: Apply a Volume Filter Length of 100 with an SMA type to smooth volume data over a longer period, filtering out short-term noise and focusing on significant volume shifts.
🟦 Combining Filters
The indicator offers an option to Combine Filters. When this setting is enabled, all selected conditions must be met simultaneously for a candle to be marked. If disabled, each condition functions independently, allowing more flexibility in detecting diverse patterns.
🟦 Examples & Use Cases
🔸Example 1: Spotting Reversal Opportunities
I used the following configuration to find potential bullish reversals:
Upper Shadow to Range Ratio: “Less than 0.05” – Looking for candles with almost no upper shadow.
Lower Shadow to Range Ratio: “More than 0.7” – Highlighting candles with a significant lower shadow.
Volume Filter Length: 100 with SMA.
This setup effectively highlights candles where price rejection is happening at lower levels, suggesting a potential trend reversal to the upside.
🔸Example 2: Detecting Market Uncertainty
If you want to focus on candles showing market hesitation, try:
Shadow to Range Ratio: “More than 0.85” – Emphasizing long-wick candles that could indicate indecision.
Disable Combine Filters to allow flexibility, marking any candle meeting the above criteria.
🟦 Detailed Explanation of Each Option
Here’s a clear and concise breakdown of each option for a better understanding:
1. Body to Range Ratio
Purpose: This ratio shows how significant the candle's body is compared to its overall range. A smaller body-to-range ratio can indicate a potential reversal if the market appears indecisive.
How to Use: Increase the ratio to filter for stronger trend candles; decrease it to identify reversal or indecision candles.
2. Shadow to Range Ratio
Purpose: This filter captures the size of both shadows relative to the candle's total range. A larger ratio often points to market hesitation, while a smaller ratio suggests a decisive move.
How to Use: Adjust this filter to focus on candles with long wicks (indecision) or short wicks (decisiveness).
3. Upper Shadow to Range Ratio
Purpose: Helps to identify candles with strong downward moves by focusing on the upper wick length. A small upper shadow can imply sellers' dominance.
How to Use: Lower the ratio to detect candles with minimal upward rejection.
4. Lower Shadow to Range Ratio
Purpose: Targets candles with strong buying pressure by analyzing the lower shadow. A larger lower shadow may indicate a bullish reversal.
How to Use: Increase the ratio to spot rejection candles with significant lower shadows.
5. Volume Filter
Purpose: Adds a volume component to verify the validity of each candlestick pattern. Higher-than-average volume often signifies the strength of a move.
How to Use: Adjust the filter length and type to smooth out volume fluctuations based on your trading timeframe.
🟦 Indicator Alerts
Each filter has its own alert configuration, enabling traders to stay updated on market conditions that meet their selected criteria. You can customize alerts to trigger whenever a condition is met, helping to manage trades even when away from the screen.
1H- 280, 2.7 (bollinger breakout)This Pine Script strategy is designed for use on the 1-hour (1H) timeframe and incorporates multiple indicators across different timeframes to generate entry and exit signals for long and short positions. The core logic includes:
Indicators: The strategy uses weighted moving averages (VWMA) and Hull Moving Averages (HMA) from the 5-minute, hourly, and 3-hour timeframes to assess market conditions.
For long positions, the price must be above these indicators on all timeframes.
For short positions, the price must be below these indicators.
Signal Line: A signal line is drawn above or below the current price based on entry conditions. Green indicates a long signal, while red indicates a short signal.
Position Sizing & Leverage: The position size is calculated based on equity and leverage settings.
Entry Conditions:
Long entry occurs when there's a breakout above a defined upper threshold.
Short entry occurs when there's a breakdown below a defined lower threshold.
Exit Conditions:
Three methods are available to close positions:
Take Profit/Stop Loss: Positions are closed when price hits predefined take profit or stop loss levels.
Downbreak/Outbreak: Positions are closed if the price crosses below the lower threshold (downbreak) or above the upper threshold (outbreak).
M7F Signal: Positions are closed based on the signal line's relationship to the price.
Visual Indicators: The strategy includes visual markers for breakouts, breakdowns, and high volatility events, with arrows on the chart for easy identification.
This strategy is useful for trading on the 1-hour chart, with automated entries and exits based on indicator crossovers, volatility, and price movements, providing a clear framework for position management.
Customizable EMA Crossover with ADXA caustomized indicator, based on the cross ema averages, filtering false Cross in areas by calculating the amount of ADX crossing.
Liquidation Level Screener//@version=5
indicator('Liquidation Level Screener', shorttitle = 'LLS', overlay=true, max_lines_count=500, max_boxes_count=120, max_labels_count=1)
// Libraries
import gotbeatz26107/ma_/2 as ma
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// General Parameters //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Input
show_line = input(true, title="Show lines", group = 'Plotting Parameters', inline = 'l1')
show_hist = input(true, title="Show histogram", group = 'Plotting Parameters', inline = 'l1')
tip = 'In order for indicator to work, you need to keep at least one of the level groups on the chart'
showl1 = input(true, title="Show Liquidations Level 1", tooltip = tip, group = 'Plotting Parameters')
showl2 = input(true, title="Show Liquidations Level 2", tooltip = tip, group = 'Plotting Parameters')
showl3 = input(true, title="Show Liquidations Level 3", tooltip = tip, group = 'Plotting Parameters')
show_params = input(false, title="Show OI delta parameters", tooltip = tip, group = 'Plotting Parameters')
// Moving Average
ma_length = input(80, title="Length", group = 'Moving average')
averageType = input.string("VWMA", options = , title = "Type", group = 'Moving Averages')
// Input Source
src = input(ohlc4, title = 'Source', group = 'Indicator Source')
// Histogram Settings
hist_amnt = input(30, 'Number of histograms (density)', group = 'Histogram settings')
bars_amnt = input(1000, 'Number of bars to lookback', group = 'Histogram settings')
dist_from_candle = input(5, 'Histgram distance from last candle', group = 'Histogram settings')
// Liquidation levels
lines_amnt = input(1000, title="Number of lines to plot", group = 'Line settings')
h3 = input.float(3.4, step = 0.1, title="Large Liquidation Level", group = 'Line settings')
h2 = input.float(2.2, step = 0.1, title="Middle Liquidation Level", group = 'Line settings')
h1 = input.float(1.8, step = 0.1, title="Small Liquidation Level", group = 'Line settings')
// Colors
color_5x = input.color(color.rgb(179, 181, 190, 70), '5x Leverage color', group='Colors')
color_10x = input.color(color.rgb(0, 137, 123, 70), '10x Leverage color', group='Colors')
color_25x = input.color(color.rgb(255, 235, 59, 70), '25x Leverage color', group='Colors')
color_50x = input.color(color.rgb(255, 82, 82, 70), '50x Leverage color', group='Colors')
color_100x = input.color(color.rgb(136, 14, 79, 70), '100x Leverage color', group='Colors')
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Data Collection //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OI data
currency = syminfo.basecurrency
xbt = currency =='BTC' ? 'XBT' : string(currency)
delta = close - close
= request.security('BINANCE' + ":" + string(currency) + 'USDT.P_OI',
timeframe.period, , ignore_invalid_symbol = true)
= request.security('BINANCE' + ":" + string(currency) + 'USD.P_OI',
timeframe.period, , ignore_invalid_symbol = true)
= request.security('BINANCE' + ":" + string(currency) + 'BUSD.P_OI',
timeframe.period, , ignore_invalid_symbol = true)
= request.security('BITMEX' + ":" + xbt + 'USD.P_OI',
timeframe.period, , ignore_invalid_symbol = true)
= request.security('BITMEX' + ":" + xbt + 'USDT.P_OI',
timeframe.period, , ignore_invalid_symbol = true)
= request.security('KRAKEN' + ":" + string(currency) + 'USD.P_OI',
timeframe.period, , ignore_invalid_symbol = true)
oid7 = request.security('BITFINEX:BTCUSDLONGS', timeframe.period, delta) +
request.security('BITFINEX:BTCUSDSHORTS', timeframe.period, delta) +
request.security('BITFINEX:BTCUSTLONGS', timeframe.period, delta) +
request.security('BITFINEX:BTCUSTSHORTS', timeframe.period, delta)
oio7 = request.security('BITFINEX:BTCUSDLONGS', timeframe.period, open) +
request.security('BITFINEX:BTCUSDSHORTS', timeframe.period, open) +
request.security('BITFINEX:BTCUSTLONGS', timeframe.period, open) +
request.security('BITFINEX:BTCUSTSHORTS', timeframe.period, open)
oic7 = request.security('BITFINEX:BTCUSDLONGS', timeframe.period, close) +
request.security('BITFINEX:BTCUSDSHORTS', timeframe.period, close) +
request.security('BITFINEX:BTCUSTLONGS', timeframe.period, close) +
request.security('BITFINEX:BTCUSTSHORTS', timeframe.period, close)
oih7 = request.security('BITFINEX:BTCUSDLONGS', timeframe.period, high) +
request.security('BITFINEX:BTCUSDSHORTS', timeframe.period, high) +
request.security('BITFINEX:BTCUSTLONGS', timeframe.period, high) +
request.security('BITFINEX:BTCUSTSHORTS', timeframe.period, high)
oil7 = request.security('BITFINEX:BTCUSDLONGS', timeframe.period, low) +
request.security('BITFINEX:BTCUSDSHORTS', timeframe.period, low) +
request.security('BITFINEX:BTCUSTLONGS', timeframe.period, low) +
request.security('BITFINEX:BTCUSTSHORTS', timeframe.period, low)
// Caclualtion
OI_delta = currency == 'BTC' ? (nz(oid1,0) + nz(oid2,0)/close + nz(oid3,0) + nz(oid4,0)/close +
nz(oid5,0)/close + nz(oid6,0)/close) + nz(oid7,0) :
(nz(oid1,0) + nz(oid2,0)/close + nz(oid3,0) + nz(oid4,0)/close +
nz(oid5,0)/close + nz(oid6,0)/close)
OI_delta_abs = math.abs(OI_delta)
OI_delta_MA = ma.selector(OI_delta, ma_length, averageType)
OI_delta_abs_MA = ma.selector(OI_delta_abs, ma_length, averageType)
OI_delta_open_h3 = (OI_delta_abs >= OI_delta_abs_MA * h3) and OI_delta > 0
OI_delta_open_h2 = (OI_delta_abs >= OI_delta_abs_MA * h2 and OI_delta_abs < OI_delta_abs_MA * h3) and OI_delta > 0
OI_delta_open_h1 = (OI_delta_abs >= OI_delta_abs_MA * h1 and OI_delta_abs < OI_delta_abs_MA * h2) and OI_delta > 0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Level Calculations And Plotting //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Histogram
local_high = ta.highest(high, bars_amnt)
local_low = ta.lowest(low, bars_amnt)
range_high = local_high * (1 + local_high / local_low / 10)
range_low = local_low * (1 - local_high / local_low / 10)
range_height = range_high - range_low
hist_height = range_height / hist_amnt
hist_lower_list = array.new_float(hist_amnt, na)
hist_higher_list = array.new_float(hist_amnt, na)
hist_data = array.new_float()
hist_targets = array.new_float(hist_amnt, 0.0)
var h3_array = array.new_line()
var h2_array = array.new_line()
var h1_array = array.new_line()
var bars_array = array.new_box(hist_amnt, na)
// Clean up drawings every tick
for i = 0 to hist_amnt - 1
box.delete(array.get(bars_array, i))
// Indicators funcitons
f_drawLine(x1, x2, y_value, line_color, style, width) =>
line.new(x1, y_value, x2, y_value, color = line_color, style = style, width = width)
f_extendArray(line_array, extend_lines) =>
if array.size(line_array) > 0
for _i = array.size(line_array) - 1 to 0 by 1
x2 = line.get_x2(array.get(line_array, _i))
y_value = line.get_y1(array.get(line_array, _i))
if extend_lines or bar_index - 1 == x2 - 1 and not(high > y_value and low < y_value)
line.set_x2(array.get(line_array, _i), bar_index + 1)
if bar_index == last_bar_index
array.push(hist_data, y_value)
calculate_leverage(pivot_value, leverage, short_sell) =>
short_sell ? pivot_value * (1 - leverage) : pivot_value * (1 + leverage)
float y_value = na
int x1 = na
int x2 = na
line l = na
x1 := bar_index
x2 := bar_index
f_append(Array, l) =>
if array.size(Array) == lines_amnt
line.delete(array.shift(Array))
array.push(Array, l)
if OI_delta_open_h3 and showl3
y_value := calculate_leverage(src, 0.01, true)
l := f_drawLine(x1, x2, y_value, color_100x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.01, false)
l := f_drawLine(x1, x2, y_value, color_100x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.02, true)
l := f_drawLine(x1, x2, y_value, color_50x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.02, false)
l := f_drawLine(x1, x2, y_value, color_50x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.04, true)
l := f_drawLine(x1, x2, y_value, color_25x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.04, false)
l := f_drawLine(x1, x2, y_value, color_25x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.1, true)
l := f_drawLine(x1, x2, y_value, color_10x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.1, false)
l := f_drawLine(x1, x2, y_value, color_10x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.2, true)
l := f_drawLine(x1, x2, y_value, color_5x, line.style_solid, 3)
f_append(h3_array, l)
y_value := calculate_leverage(src, 0.2, false)
l := f_drawLine(x1, x2, y_value, color_5x, line.style_solid, 3)
f_append(h3_array, l)
if OI_delta_open_h2 and not OI_delta_open_h3 and showl2
y_value := calculate_leverage(src, 0.01, true)
l := f_drawLine(x1, x2, y_value, color_100x, line.style_solid, 2)
f_append(h2_array, l)
y_value := calculate_leverage(src, 0.01, false)
l := f_drawLine(x1, x2, y_value, color_100x, line.style_solid, 2)
f_append(h2_array, l)
y_value := calculate_leverage(src, 0.02, true)
l := f_drawLine(x1, x2, y_value, color_50x, line.style_solid, 2)
f_append(h2_array, l)
y_value := calculate_leverage(src, 0.02, false)
l := f_drawLine(x1, x2, y_value, color_50x, line.style_solid, 2)
f_append(h2_array, l)
y_value := calculate_leverage(src, 0.04, true)
l := f_drawLine(x1, x2, y_value, color_25x, line.style_solid, 2)
f_append(h2_array, l)
y_value := calculate_leverage(src, 0.04, false)
l := f_drawLine(x1, x2, y_value, color_25x, line.style_solid, 2)
f_append(h2_array, l)
y_value := calculate_leverage(src, 0.1, true)
l := f_drawLine(x1, x2, y_value, color_10x, line.style_solid, 2)
f_append(h2_array, l)
y_value := calculate_leverage(src, 0.1, false)
l := f_drawLine(x1, x2, y_value, color_10x, line.style_solid, 2)
f_append(h2_array, l)
if OI_delta_open_h1 and not OI_delta_open_h2 and not OI_delta_open_h3 and showl1
y_value := calculate_leverage(src, 0.01, true)
l := f_drawLine(x1, x2, y_value, color_100x, line.style_dotted, 1)
f_append(h1_array, l)
y_value := calculate_leverage(src, 0.01, false)
l := f_drawLine(x1, x2, y_value, color_100x, line.style_dotted, 1)
f_append(h1_array, l)
y_value := calculate_leverage(src, 0.02, true)
l := f_drawLine(x1, x2, y_value, color_50x, line.style_dotted, 1)
f_append(h1_array, l)
y_value := calculate_leverage(src, 0.02, false)
l := f_drawLine(x1, x2, y_value, color_50x, line.style_dotted, 1)
f_append(h1_array, l)
y_value := calculate_leverage(src, 0.04, true)
l := f_drawLine(x1, x2, y_value, color_25x, line.style_dotted, 1)
f_append(h1_array, l)
y_value := calculate_leverage(src, 0.04, false)
l := f_drawLine(x1, x2, y_value, color_25x, line.style_dotted, 1)
f_append(h1_array, l)
f_extendArray(h3_array, false)
f_extendArray(h2_array, false)
f_extendArray(h1_array, false)
// Draw Histogram
if barstate.islast and show_hist
// Define lows and highs of the histograms
for i = 0 to hist_amnt - 1
histogramLow = range_low + hist_height * i
histogramHigh = range_low + hist_height * (i + 1)
array.set(hist_lower_list, i, histogramLow)
array.set(hist_higher_list, i, histogramHigh)
for i = 0 to array.size(hist_data) - 1
y = array.get(hist_data, i)
for j = 0 to hist_amnt - 1
histogramLow = array.get(hist_lower_list, j)
histogramHigh = array.get(hist_higher_list, j)
if y >= histogramLow and y <= histogramHigh
array.set(hist_targets, j, array.get(hist_targets, j) + 1)
maxHistogramtarget = array.max(hist_targets) // add this line to get the max target value
for i = 0 to hist_amnt - 1
histogramLow = array.get(hist_lower_list, i)
histogramHigh = array.get(hist_higher_list, i)
histogramtarget = array.get(hist_targets, i)
histogramWidth = math.floor((histogramtarget + 0.49) * 2)
// Compute alpha based on the size of the histogram, max alpha is 100
alpha = 100 - math.floor(histogramtarget / maxHistogramtarget * 100)
// Define color based on comparison with close price
barColor = histogramHigh > close ? color.new(color.red, alpha) : color.new(color.teal, alpha)
// Draw histograms
array.set(bars_array, i, box.new(left=bar_index + dist_from_candle, top=histogramHigh, right=bar_index + dist_from_candle + histogramWidth, bottom=histogramLow, bgcolor=barColor, border_color=barColor))
// Update Positions
if barstate.islast and not show_line
for i=0 to array.size(h3_array) - 1
line.delete(array.get(h3_array, i))
for i=0 to array.size(h2_array) - 1
line.delete(array.get(h2_array, i))
for i=0 to array.size(h1_array) - 1
line.delete(array.get(h1_array, i))
// Parameters for settings
plot(show_params ? OI_delta_abs : na, color = color.red)
plot(show_params ? OI_delta_abs_MA * h3 : na, color = color.white)
plot(show_params ? OI_delta_abs_MA * h2 : na, color = color.yellow)
plot(show_params ? OI_delta_abs_MA * h1 : na, color = color.orange)