BK BB Horizontal LinesIndicator Description:
I am incredibly proud and excited to share my second indicator with the TradingView community! This tool has been instrumental in helping me optimize my positioning and maximize my trades.
Bollinger Bands are a critical component of my trading strategy. I designed this indicator to work seamlessly alongside my previously introduced tool, "BK MA Horizontal Lines." This indicator focuses specifically on the Daily Bollinger Bands, applying horizontal lines to the bands which is displayed in all timeframes. The Daily bands in my opinion hold a strong significance when it comes to support and resistance, knowing your current positioning and maximizing your trades. The settings are fully adjustable to suit your preferences and trading style.
If you find success with this indicator, I kindly ask that you give back in some way through acts of philanthropy, helping others in the best way you see fit.
Good luck to everyone, and always remember: God gives us everything. May all the glory go to the Almighty!
Indicators and strategies
Sunil High-Frequency Strategy with Simple MACD & RSISunil High-Frequency Strategy with Simple MACD & RSI
This high-frequency trading strategy uses a combination of MACD and RSI to identify quick market opportunities. By leveraging these indicators, combined with dynamic risk management using ATR, it aims to capture small but frequent price movements while ensuring tight control over risk.
Key Features:
Indicators Used:
MACD (Moving Average Convergence Divergence): The strategy uses a shorter MACD configuration (Fast Length of 6 and Slow Length of 12) to capture quick price momentum shifts. A MACD crossover above the signal line triggers a buy signal, while a crossover below the signal line triggers a sell signal.
RSI (Relative Strength Index): A shorter RSI length of 7 is used to gauge overbought and oversold market conditions. The strategy looks for RSI confirmation, with a long trade initiated when RSI is below the overbought level (70) and a short trade initiated when RSI is above the oversold level (30).
Risk Management:
Dynamic Stop Loss and Take Profit: The strategy uses ATR (Average True Range) to calculate dynamic stop loss and take profit levels based on market volatility.
Stop Loss is set at 0.5x ATR to limit risk.
Take Profit is set at 1.5x ATR to capture reasonable price moves.
Trailing Stop: As the market moves in the strategy’s favor, the position is protected by a trailing stop set at 0.5x ATR, allowing the strategy to lock in profits as the price moves further.
Entry & Exit Signals:
Long Entry: Triggered when the MACD crosses above the signal line (bullish crossover) and RSI is below the overbought level (70).
Short Entry: Triggered when the MACD crosses below the signal line (bearish crossover) and RSI is above the oversold level (30).
Exit Conditions: The strategy exits long or short positions based on the stop loss, take profit, or trailing stop activation.
Frequent Trades:
This strategy is designed for high-frequency trading, with trade signals occurring frequently as the MACD and RSI indicators react quickly to price movements. It works best on lower timeframes such as 1-minute, 5-minute, or 15-minute charts, but can be adjusted for different timeframes based on the asset’s volatility.
Customizable Parameters:
MACD Settings: Adjust the Fast Length, Slow Length, and Signal Length to tune the MACD’s sensitivity.
RSI Settings: Customize the RSI Length, Overbought, and Oversold levels to better match your trading style.
ATR Settings: Modify the ATR Length and multipliers for Stop Loss, Take Profit, and Trailing Stop to optimize risk management according to market volatility.
Important Notes:
Market Conditions: This strategy is designed to capture smaller, quicker moves in trending markets. It may not perform well during choppy or sideways markets.
Optimizing for Asset Volatility: Adjust the ATR multipliers based on the asset’s volatility to suit the risk-reward profile that fits your trading goals.
Backtesting: It's recommended to backtest the strategy on different assets and timeframes to ensure optimal performance.
Summary:
The Sunil High-Frequency Strategy leverages a simple combination of MACD and RSI with dynamic risk management (using ATR) to trade small but frequent price movements. The strategy ensures tight stop losses and reasonable take profits, with trailing stops to lock in profits as the price moves in favor of the trade. It is ideal for scalping or intraday trading on lower timeframes, aiming for quick entries and exits with controlled risk.
[w3ss1] Timeframe SyncThe "Timeframe Sync" indicator provides a comprehensive view of price action across multiple timeframes for a single symbol, allowing traders to analyze market conditions from a multi-timeframe perspective with ease.
Key Features:
Flexible Symbol Selection: Choose between analyzing the symbol of the current chart or select another symbol to monitor.
Customizable Timeframes: Control which timeframes you want to analyze through toggle switches. Choose from 11 different timeframes ranging from 1-minute to Monthly charts, with the ability to customize each one:
1m, 5m, 15m, 30m, 1H, 4H, 8H, 12H, 1D, 1W, 1M
Visual Feedback:
-Candle Close Color: Each timeframe's last closed candle is color-coded. Bullish closes are highlighted in green, bearish in dark shades, and inside candles in orange.
-Bias Indicator: The indicator shows whether the close is "above", "below", or "inside" the previous candle's high/low range, providing insight into the market's momentum.
Table Display: Information is presented in a clear table format:
-The first row shows the symbol being analyzed.
-The second row displays "Candle close" to indicate the relevance of the information below.
-Each subsequent row represents a different timeframe, showing its abbreviation and the bias of the last close.
Conditional Display: Timeframes are only shown if they are relevant to the current chart's timeframe. This ensures that you're not looking at outdated data when on lower timeframes.
Customization:
-Adjust text size, table position, background color, text color, and colors for different candle close scenarios.
Usage:
Ideal for traders who need a quick multi-timeframe analysis without switching charts.
Helps in confirming short-term moves with longer-term trends or spotting divergences across timeframes.
Instructions:
Add the indicator to your chart.
Customize the timeframes you wish to monitor via the toggle switches.
Optionally, select a different symbol if not analyzing the current chart's symbol.
Adjust colors and table settings to your preference.
Observe how price action behaves across different timeframes to make informed trading decisions.
Range Channel by Atilla YurtsevenThis script creates a dynamic channel around a user-selected moving average (MA). It calculates the relative difference between price and the MA, then finds the average of the positive differences and the negative differences separately. Using these averages, it plots upper and lower bands around the MA as well as a histogram-like oscillator to show when price moves above or below the average thresholds.
How It Works
Moving Average Selection
The indicator allows you to choose among multiple MA types (SMA, EMA, WMA, Linear Regression, etc.). Depending on your preference, it calculates the chosen MA for the selected lookback period.
Relative Difference Calculation
It then computes the percentage difference between the source (typically the closing price) and the MA. (diff = (src / ma - 1) * 100)
Positive & Negative Averages
- Positive differences are averaged and represent how far the price typically moves above the MA.
- Negative differences are similarly averaged for when price moves below the MA.
Range Channel & Oscillator
- The channel is plotted around the MA using the average positive and negative differences (Upper Edge and Lower Edge).
- The “Untrended” histogram plots the difference (diff). Green bars occur when price is above the MA on average, and red bars when below. Two additional lines mark the upper and lower average thresholds on this histogram.
How to Use
Identify Overbought/Oversold Zones: The upper edge can serve as a dynamic overbought level, while the lower edge can suggest potential oversold conditions. When the histogram approaches or crosses these levels, it may signal price extremes relative to its average movement.
Trend Confirmation: Compare price action relative to the channel. If price and the histogram consistently remain above the MA and upper threshold, it could indicate a stronger bullish trend. If they remain below, it might signal a prolonged bearish trend.
Entry/Exit Timings:
- Entry: Traders can look for moments when price breaks back inside the channel from an extreme, anticipating a mean reversion.
- Exit: Watching how price interacts with these dynamic edges can help define stop-loss or take-profit points.
Because these thresholds adapt over time based on actual price behavior, they can be more responsive than fixed-percentage bands. However, like all indicators, it’s most effective when used in conjunction with other technical and fundamental tools.
Disclaimer
This script is provided for educational and informational purposes only. It does not guarantee any specific outcome or profit. Use it at your own discretion and risk.
Trade smart, stay safe.
Atilla Yurtseven
BARTU V1 MACD-RSI//@version=6
indicator('MACD ve RSI', overlay = false)
// MACD hesaplama
= ta.macd(close, 12, 26, 9)
macdHist = macdLine - signalLine
// RSI hesaplama
rsiLength = 14
rsiValue = ta.rsi(close, rsiLength)
// MACD çizimleri
hline(0, 'Sıfır Çizgisi', color = color.gray)
plot(macdLine, color = color.blue, title = 'MACD Hattı')
plot(signalLine, color = color.red, title = 'Sinyal Hattı')
plot(macdHist, color = color.green, style = plot.style_histogram, title = 'MACD Histogramı')
// RSI çizimleri
rsiOverbought = 70
rsiOversold = 30
hline(rsiOverbought, 'Aşırı Alım', color = color.red)
hline(rsiOversold, 'Aşırı Satım', color = color.green)
plot(rsiValue, color = color.orange, title = 'RSI')
// Arka Plan Renkleri
bgcolor(rsiValue > rsiOverbought ? color.new(color.red, 90) : na)
bgcolor(rsiValue < rsiOversold ? color.new(color.green, 90) : na)
Central Pivot Range (CPR)Central Pivot Range (CPR) Indicator
The Central Pivot Range (CPR) indicator is designed to help traders identify key levels of support and resistance based on pivot points calculated from the previous day's price action. The CPR levels act as critical areas of price convergence and potential reversal, which can help in anticipating future price movements. This version of the CPR indicator includes customizable features to enhance your trading strategy.
Key Features:
Custom Timeframe Support: The indicator allows you to select a custom timeframe for calculating the CPR levels. By default, it uses the daily timeframe ('D'), but you can adjust it to any other timeframe of your choosing. The indicator calculates the CPR and support/resistance levels based on the data from the selected timeframe.
Central Pivot (CP), Below Central Pivot (BC), and Top Central Pivot (TC):
Pivot (CP): The central pivot point is calculated as the average of the high, low, and close prices of the selected timeframe.
Below Central Pivot (BC): This is the midpoint between the high and low prices of the selected timeframe.
Top Central Pivot (TC): This is calculated based on the central pivot and below central pivot, providing a range between support and resistance levels.
Support and Resistance Levels (S1, S2, S3, R1, R2, R3):
Support Levels (S1, S2, S3): These are calculated based on the central pivot, providing potential areas where price may find support and reverse.
Resistance Levels (R1, R2, R3): These are calculated similarly but indicate potential resistance zones where price may face challenges to move higher.
Dynamic Plotting Based on User Input:
The indicator allows you to choose which levels to display on the chart, including the Central Pivot (CP), Support Levels (S1, S2, S3), and Resistance Levels (R1, R2, R3), all of which can be toggled on or off via checkboxes.
CP is displayed in white, BC and TC in blue, Support levels (S1, S2, S3) in green, and Resistance levels (R1, R2, R3) in red.
Daywise Calculations:
The CPR and levels are based on the previous day’s price action, providing historical support and resistance levels that can be useful for intraday analysis.
The request.security function is used to fetch the pivot data from the custom timeframe, ensuring the levels are calculated based on the last completed period (previous day) without repainting.
Customization Options:
CPR Plot: Toggle the visibility of the central pivot range (CPR) lines.
Support Levels (S1, S2, S3): Choose to show or hide the support levels.
Resistance Levels (R1, R2, R3): Choose to show or hide the resistance levels.
Custom Timeframe: Set a custom timeframe for calculating the CPR, allowing for more flexible and tailored analysis.
MACD,RSI,EM9,WMA45 (Scale -100 đến 100)include: MACD,RSI,EM9,WMA45.
All indicators are fixed from -100 to 100.
Momentum Setup - Ankush Bajaj Momentum Investing SetupMomentum Setup - Ankush Bajaj Momentum Investing Setup
Momentum Setup - Ankush Bajaj Momentum Investing SetupMomentum Setup - Ankush Bajaj Momentum Investing Setup
Lokesh(bank nifty option buying) MA Crossover with RSI use it directly in bank nifty option chart for 5 minute time frame specialy for put buying
EMA Crossover with RSI and DistanceEMA Crossover with RSI and Distance Strategy
This strategy combines Exponential Moving Averages (EMA) with Relative Strength Index (RSI) and distance-based conditions to generate buy, sell, and neutral signals. It is designed to help traders identify entry and exit points based on multiple technical indicators.
Key Components:
Exponential Moving Averages (EMA):
The strategy uses four EMAs: EMA 5, EMA 13, EMA 40, and EMA 55.
A buy signal (long) is triggered when EMA 5 crosses above EMA 13 and EMA 40 crosses above EMA 55.
A sell signal (short) is generated when EMA 55 crosses above EMA 40.
The distance between EMAs (5 and 13) is also important. If the current distance between EMA 5 and EMA 13 is smaller than the average distance over the last 5 candles, a neutral condition is triggered, preventing a signal even if all other conditions are met.
Relative Strength Index (RSI):
The 14-period RSI is used to determine market strength and direction.
The strategy requires RSI to be above 50 and greater than the average RSI (over the past 14 periods) for a buy signal.
If the RSI is above 60, a green signal is given, indicating a strong bullish condition, even if the EMA conditions are not fully met.
If the RSI is below 40, a red signal is given, indicating a strong bearish condition, regardless of the EMA crossover.
Distance Conditions:
The strategy calculates the distance between EMA 5 and EMA 13 on each candle and compares it to the average distance of the last 5 candles.
If the current distance between EMA 5 and EMA 13 is lower than the average of the last 5 candles, a neutral signal is triggered. This helps avoid entering a trade when the market is losing momentum.
Additionally, if the distance between EMA 40 and EMA 13 is greater than the previous distance, the previous signal is kept intact, ensuring that the trend is still strong enough for the signal to remain valid.
Signal Persistence:
Once a buy (green) or sell (red) signal is triggered, it remains intact as long as the price is closing above EMA 5 for long trades or below EMA 55 for short trades.
If the price moves below EMA 5 for long trades or above EMA 55 for short trades, the signal is recalculated based on the most recent conditions.
Signal Display:
Green Signals: Represent a strong buy signal and are shown below the candle when the RSI is above 60.
Red Signals: Represent a strong sell signal and are shown above the candle when the RSI is below 40.
Neutral Signals: Displayed when the conditions for entry are not met, specifically when the EMA distance condition is violated.
Long and Short Signals: Additional signals are shown based on the EMA crossovers and RSI conditions. These signals are plotted below the candle for long positions and above the candle for short positions.
Trade Logic:
Long Entry: Enter a long trade when EMA 5 crosses above EMA 13, EMA 40 crosses above EMA 55, and the RSI is above 50 and greater than the average RSI. Additionally, the current distance between EMA 5 and EMA 13 should be larger than the average distance of the last 5 candles.
Short Entry: Enter a short trade when EMA 55 crosses above EMA 40 and the RSI is below 40.
Neutral Condition: If the distance between EMA 5 and EMA 13 is smaller than the average distance over the last 5 candles, the strategy will not trigger a signal, even if other conditions are met.
BLSH - ShriThe BLSH Price Table indicator (Buy at Low, Sell at High) is designed to help traders identify key price levels for informed decision-making. This indicator calculates:
25-Day Low (LOW25): The lowest price over a user-defined period (default: 25 days).
GTT (Good Till Triggered): A customizable price level, expressed as a percentage above the 25-day low (default: 6.5%).
Target Price: A profit-based price level, calculated as a percentage above the GTT (default: 3.14%).
The BLSH Price Table visually plots these levels and provides a table summarizing them for easy reference.
Use LOW25 to identify strong support zones.
Use GTT as a breakout or re-entry point.
Use Target Price to plan profitable exits.
This indicator is ideal for swing traders seeking to capitalize on low-risk buy opportunities and strategic sell points.
EMA + Stochastic Strategy (day trading)Setup Instructions
Exponential Moving Averages (EMA):
Use two EMAs:
50-period EMA for the overall trend.
20-period EMA for shorter-term movements.
Trend Confirmation:
If the 20 EMA is above the 50 EMA, focus on buy opportunities.
If the 20 EMA is below the 50 EMA, focus on sell opportunities.
Stochastic Oscillator:
Set Stochastic to a 14, 3, 3 period (default).
Overbought level = 80; Oversold level = 20.
Look for crossovers:
Buy: Stochastic %K crosses above %D in the oversold zone (below 20).
Sell: Stochastic %K crosses below %D in the overbought zone (above 80).
Entry and Exit Rules
Buy Signal:
The 20 EMA is above the 50 EMA, confirming an uptrend.
The Stochastic Oscillator is in the oversold zone (below 20), and %K crosses above %D.
Enter when the price retraces to and bounces off the 20 EMA in the direction of the trend.
Sell Signal:
The 20 EMA is below the 50 EMA, confirming a downtrend.
The Stochastic Oscillator is in the overbought zone (above 80), and %K crosses below %D.
Enter when the price retraces to and rejects off the 20 EMA in the direction of the trend.
Stop Loss and Take Profit
Stop Loss:
For buy trades: Place the stop loss below the recent swing low.
For sell trades: Place the stop loss above the recent swing high.
Take Profit:
Use a risk-to-reward ratio of 1:2 or higher.
Alternatively, exit the trade when Stochastic reaches the opposite extreme (80 for buys, 20 for sells).
Example
Scenario: GBP/USD on a 15-minute chart.
The 20 EMA is above the 50 EMA, indicating an uptrend.
The Stochastic Oscillator dips below 20, and %K crosses above %D.
Enter a buy trade when the price bounces off the 20 EMA.
Place a stop loss below the nearest swing low and a take profit at twice the risk.
Tips for Success
Avoid Choppy Markets: Ensure the EMAs are diverging, and there’s a clear trend.
Use Stochastic for Confirmation: Only take trades when the Stochastic Oscillator aligns with the EMA trend.
Combine with Price Action:
Watch for candlestick patterns (e.g., pin bars, engulfing candles) near the 20 EMA for additional confirmation.
Practice Discipline: Stick to your stop-loss and take-profit rules.
Omega_galskyThe strategy uses three Exponential Moving Averages (EMAs) — EMA8, EMA21, and EMA89 — to decide when to open buy or sell trades. It also includes a mechanism to move the Stop Loss (SL) to the Break-Even (BE) point, which is the entry price, once the price reaches a Risk-to-Reward (R2R) ratio of 1:1.
Key Steps:
Calculating EMAs: The script computes the EMA values for the specified periods. These help identify market trends and potential entry points.
Buy Conditions:
EMA8 crosses above EMA21.
The candle that causes the crossover is green (closing price is higher than the opening price).
The closing price is above EMA89.
If all conditions are met, a buy order is executed.
Sell Conditions:
EMA8 crosses below EMA21.
The candle that causes the crossover is red (closing price is lower than the opening price).
The closing price is below EMA89.
If all conditions are met, a sell order is executed.
Stop Loss and Take Profit:
Initial Stop Loss and Take Profit levels are calculated based on the entry price and a percentage defined by the user.
These levels help protect against large losses and lock in profits.
Break-Even Logic:
When the price moves favorably to reach a 1:1 R2R ratio:
For a buy trade, the Stop Loss is moved to the entry price if the price increases sufficiently.
For a sell trade, the Stop Loss is moved to the entry price if the price decreases sufficiently.
This ensures the trade is risk-free after the price reaches the predefined level.
Visual Representation:
The EMAs are plotted on the chart for easy visualization of trends and crossovers.
Entry and exit points are also marked on the chart to track trades.
Purpose:
The strategy is designed to capitalize on EMA crossovers while minimizing risks using Break-Even logic and predefined Stop Loss/Take Profit levels. It automates decision-making for trend-following traders and ensures disciplined risk management.
Bitcoin Reversal PredictorOverview
This indicator displays two lines that, when they cross, signal a potential reversal in Bitcoin's price trend. Historically, the high or low of a bull market cycle often occurs near the moment these lines intersect. The lines consist of an Exponential Moving Average (EMA) and a logarithmic regression line fitted to all of Bitcoin's historical data.
Inspiration
The inspiration for this indicator came from the PI Cycle Top indicator, which has accurately predicted past bull market peaks. However, I believe the PI Cycle Top indicator may not be as effective in the future. In that indicator, two lines cross to mark the top, but the extent of the cross has been diminishing over time. This was especially noticeable in the 2021 cycle, where the lines barely crossed. Because of this, I created a new indicator that I think will continue to provide reliable reversal signals in the future.
How It Works
The logarithmic regression line is fitted to the Bitcoin (BTCUSD) chart using two key factors: the 'a' factor (slope) and the 'b' factor (intercept). This results in a steadily decreasing line. The EMA oscillates above and below this regression line. Each time the two lines cross, a vertical colored bar appears, indicating that Bitcoin's price momentum is likely to reverse.
Use Cases
- Price Bottoming:
Bitcoin often bottoms out when the EMA crosses below the logarithmic regression line.
- Price Topping:
In contrast, Bitcoin often peaks when the EMA crosses above the logarithmic regression line.
- Profitable Strategy:
Trading at the crossovers of these lines can be a profitable strategy, as these moments often signal significant price reversals.
Wickiness IndexWickiness Index - Detect Indecision and Trend Exhaustion
The Wickiness Index is a versatile technical indicator designed to measure the proportion of wicks (upper and lower shadows) relative to the total range of price bars over a specified lookback period. It provides insights into market indecision, reversals, and trend exhaustion by analyzing the structural composition of candlesticks. The indicator calculates the lengths of upper and lower wicks along with the body of each candlestick. Each bar's wick length is expressed as a percentage of the total range (High - Low). The ratio is scaled to 0–100, where 100 represents entirely wicks with no body (indicating pure indecision) and 0 represents no wicks with only body (indicating strong directional movement). These values are then averaged over the lookback period (default = 5 bars) to provide a smoothed representation of wickiness, reducing noise and highlighting trends.
A high value, especially above 70, suggests indecision or potential reversals, as candlesticks dominated by wicks often appear near tops or bottoms. Conversely, low values below 30 indicate trend strength and strong momentum, useful for spotting breakouts and trend continuation. Mid-range values between 30 and 70 often indicate consolidation phases or gradual transitions between trends. Traders can adjust the lookback period to match their trading style, with shorter periods offering faster responses and longer periods providing smoother trends.
This indicator is particularly useful for trend reversal detection, breakout confirmation, and volatility filtering. It scales effectively across all timeframes, making it suitable for both intraday traders and long-term investors. When combined with volume analysis or trend-following indicators, the Wickiness Index can further strengthen trade signals. The visual design includes a blue line for the index and horizontal reference lines at 30 and 70, allowing for quick and intuitive interpretation.
The Wickiness Index offers a unique perspective on market sentiment and price action behavior, providing traders with valuable insights into potential turning points, momentum shifts, and market indecision. It is a powerful tool for improving decision-making in volatile markets and identifying areas where price trends may weaken or reverse.
PseudoPlotLibrary "PseudoPlot"
PseudoPlot: behave like plot and fill using polyline
This library enables line plotting by polyline like plot() and fill().
The core of polyline() is array of chart.point array, polyline() is called in its method.
Moreover, plotarea() makes a box in main chart, plotting data within the box is enabled.
It works so slowy to manage array of chart.point, so limit the target to visible area of the chart.
Due to polyline specifications, na and expression can not be used for colors.
1. pseudoplot
pseudoplot() behaves like plot().
//use plot()
plot(close)
//use pseudoplot()
pseudoplot(close)
Pseudoplot has label. Label is enabled when title argument is set.
In the example bellow, "close value" label is shown with line.
The label is shown at right of the line when recent bar is visible.
It is shown at 15% from the left of visible area when recent bar is not visible.
Just set "" if you don't need label.
//use plot()
plot(close,"close value")
//use pseudoplot
pseudoplot(close, "close value")
Arguments are designed in an order as similar as possible to plot.
plot(series, title, color, linewidth, style, trackprice, histbase, offset, join, editable, show_last, display, format, precision, force_overlay) → plot
pseudoplot(series, title, ,linecolor ,linewidth, linestyle, labelbg, labeltext, labelsize, shorttitle, format, xpos_from_left, overlay) → pseudo_plot
2. pseudofill
pseudofill() behaves like fill().
The label is shown(text only) at right of the line when recent bar is visible.
It is shown at 10% from the left of visible area when recent bar is not visible.
Just set "" if you don't need label.
//use plot() and fill()
p1=plot(open)
p2=plot(close)
fill(p1,p2)
//use pseudofill()
pseudofill(open,close)
Arguments are designed in an order as similar as possible to fill.
fill(hline1, hline2, color, title, editable, fillgaps, display) → void
pseudofill(series1, series2, fillcolor, title, linecolor, linewidth, linestyle, labeltext, labelsize, shorttitle, format, xpos_from_left, overlay) → pseudo_plot
3. plotarea and its methods
plotarea() makes a box in main chart. You can set the box position to top or bottom, and
the box height in percentage of the range of visible high and low prices.
x-coordinate of the box is from chart.left_visible_bar_time to chart.right_visible_bar_time,
y-coordinate is highest and lowest price of visible bars.
pseudoplot() and pseudofill() work as method of plotarea(box).
Usage is almost same as the function version, just set min and max value, y-coodinate is remapped automatically.
hline() is also available. The y-coordinate of hline is specified as a percentage from the bottom.
plotarea() and its associated methods are overlay=true as default.
Depending on the drawing order of the objects, plot may become invisible, so the bgcolor of plotarea should be na or tranceparent.
//1. make a plotarea
// bgcolor should be na or transparent color.
area=plotarea("bottom",30,"plotarea",bgcolor=na)
//2. plot in a plotarea
//(min=0, max=100 is omitted as it is the default.)
area.pseudoplot(ta.rsi(close,14))
//3. draw hlines
area.hline(30,linestyle="dotted",linewidth=2)
area.hline(70,linestyle="dotted",linewidth=2)
4. Data structure and sub methods
Array management is most imporant part of using polyline.
I don't know the proper way to handle array, so it is managed by array and array as intermediate data.
(type xy_arrays to manage bar_time and price as independent arrays.)
method cparray() pack arrays to array, when array includes both chart.left_visible_bar_time and chart.right_visible_bar.time.
Calling polyline is implemented as methods of array of chart.point.
Method creates polyline object if array is not empty.
method polyline(linecolor, linewidth, linestyle, overlay) → series polyline
method polyline_fill(fillcolor, linecolor, linewidth, linestyle, overlay) → series polyline
Also calling label is implemented as methods of array of chart.point.
Method creates label ofject if array is not empty.
Label is located at right edge of the chart when recent bar is visible, located at left side when recent bar is invisible.
label(title, labelbg, labeltext, labelsize, format, shorttitle, xpos_from_left, overlay) → series label
label_for_fill(title, labeltext, labelsize, format, shorttitle, xpos_from_left, overlay) → series label
visible_xyInit(series)
make arrays of visible x(bar_time) and y(price/value).
Parameters:
series (float) : (float) series variable
Returns: (xy_arrays)
method remap(this, bottom, top, min, max)
Namespace types: xy_arrays
Parameters:
this (xy_arrays)
bottom (float) : (float) bottom price to ajust.
top (float) : (float) top price to ajust.
min (float) : (float) min of src value.
max (float) : (float) max of src value.
Returns: (xy_arrays)
method polyline(this, linecolor, linewidth, linestyle, overlay)
Namespace types: array
Parameters:
this (array)
linecolor (color) : (color) color of polyline.
linewidth (int) : (int) width of polyline.
linestyle (string) : (string) linestyle of polyline. default is line.style_solid("solid"), others line.style_dashed("dashed"), line.style_dotted("dotted").
overlay (bool) : (bool) force_overlay of polyline. default is false.
Returns: (polyline)
method polyline_fill(this, fillcolor, linecolor, linewidth, linestyle, overlay)
Namespace types: array
Parameters:
this (array)
fillcolor (color)
linecolor (color) : (color) color of polyline.
linewidth (int) : (int) width of polyline.
linestyle (string) : (string) linestyle of polyline. default is line.style_solid("solid"), others line.style_dashed("dashed"), line.style_dotted("dotted").
overlay (bool) : (bool) force_overlay of polyline. default is false.
Returns: (polyline)
method label(this, title, labelbg, labeltext, labelsize, format, shorttitle, xpos_from_left, overlay)
Namespace types: array
Parameters:
this (array)
title (string) : (string) label text.
labelbg (color) : (color) color of label bg.
labeltext (color) : (color) color of label text.
labelsize (int) : (int) size of label.
format (string) : (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
shorttitle (string) : (string) another label text for recent bar is not visible.
xpos_from_left (int) : (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
overlay (bool) : (bool) force_overlay of label. default is false.
Returns: (label)
method label_for_fill(this, title, labeltext, labelsize, format, shorttitle, xpos_from_left, overlay)
Namespace types: array
Parameters:
this (array)
title (string) : (string) label text.
labeltext (color) : (color) color of label text.
labelsize (int) : (int) size of label.
format (string) : (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
shorttitle (string) : (string) another label text for recent bar is not visible.
xpos_from_left (int) : (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 10%.
overlay (bool) : (bool) force_overlay of label. default is false.
Returns: (label)
pseudoplot(series, title, linecolor, linewidth, linestyle, labelbg, labeltext, labelsize, shorttitle, format, xpos_from_left, overlay)
polyline like plot with label
Parameters:
series (float) : (float) series variable to plot.
title (string) : (string) title if need label. default value is ""(disable label).
linecolor (color) : (color) color of line.
linewidth (int) : (int) width of line.
linestyle (string) : (string) style of plotting line. default is "solid", others "dashed", "dotted".
labelbg (color) : (color) color of label bg.
labeltext (color) : (color) color of label text.
labelsize (int) : (int) size of label text.
shorttitle (string) : (string) another label text for recent bar is not visible.
format (string) : (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
xpos_from_left (int) : (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
overlay (bool) : (bool) force_overlay of polyline and label.
Returns: (pseudo_plot)
method pseudoplot(this, series, title, linecolor, linewidth, linestyle, labelbg, labeltext, labelsize, shorttitle, format, xpos_from_left, min, max, overlay)
Namespace types: series box
Parameters:
this (box)
series (float) : (float) series variable to plot.
title (string) : (string) title if need label. default value is ""(disable label).
linecolor (color) : (color) color of line.
linewidth (int) : (int) width of line.
linestyle (string) : (string) style of plotting line. default is "solid", others "dashed", "dotted".
labelbg (color) : (color) color of label bg.
labeltext (color) : (color) color of label text.
labelsize (int) : (int) size of label text.
shorttitle (string) : (string) another label text for recent bar is not visible.
format (string) : (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
xpos_from_left (int) : (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
min (float)
max (float)
overlay (bool) : (bool) force_overlay of polyline and label.
Returns: (pseudo_plot)
pseudofill(series1, series2, fillcolor, title, linecolor, linewidth, linestyle, labeltext, labelsize, shorttitle, format, xpos_from_left, overlay)
fill by polyline
Parameters:
series1 (float) : (float) series variable to plot.
series2 (float) : (float) series variable to plot.
fillcolor (color) : (color) color of fill.
title (string)
linecolor (color) : (color) color of line.
linewidth (int) : (int) width of line.
linestyle (string) : (string) style of plotting line. default is "solid", others "dashed", "dotted".
labeltext (color)
labelsize (int)
shorttitle (string)
format (string) : (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
xpos_from_left (int) : (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
overlay (bool) : (bool) force_overlay of polyline and label.
Returns: (pseudoplot)
method pseudofill(this, series1, series2, fillcolor, title, linecolor, linewidth, linestyle, labeltext, labelsize, shorttitle, format, xpos_from_left, min, max, overlay)
Namespace types: series box
Parameters:
this (box)
series1 (float) : (float) series variable to plot.
series2 (float) : (float) series variable to plot.
fillcolor (color) : (color) color of fill.
title (string)
linecolor (color) : (color) color of line.
linewidth (int) : (int) width of line.
linestyle (string) : (string) style of plotting line. default is "solid", others "dashed", "dotted".
labeltext (color)
labelsize (int)
shorttitle (string)
format (string) : (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
xpos_from_left (int) : (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
min (float)
max (float)
overlay (bool) : (bool) force_overlay of polyline and label.
Returns: (pseudo_plot)
plotarea(pos, height, title, bordercolor, borderwidth, bgcolor, textsize, textcolor, format, overlay)
subplot area in main chart
Parameters:
pos (string) : (string) position of subplot area, bottom or top.
height (int) : (float) percentage of visible chart heght.
title (string) : (string) text of area box.
bordercolor (color) : (color) color of border.
borderwidth (int) : (int) width of border.
bgcolor (color) : (string) color of area bg.
textsize (int)
textcolor (color)
format (string)
overlay (bool) : (bool) force_overlay of polyline and label.
Returns: (box)
method hline(this, ypos_from_bottom, linecolor, linestyle, linewidth, overlay)
Namespace types: series box
Parameters:
this (box)
ypos_from_bottom (float) : (float) percentage of box height from the bottom of box.(bottom is 0%, top is 100%).
linecolor (color) : (color) color of line.
linestyle (string) : (string) style of line.
linewidth (int) : (int) width of line.
overlay (bool) : (bool) force_overlay of polyline and label.
Returns: (line)
pseudo_plot
polyline and label.
Fields:
p (series polyline)
l (series label)
xy_arrays
x(bartime) and y(price or value) arrays.
Fields:
t (array)
p (array)