Indicators and strategies
Шорт или ЛонгЕсли до конца не уверены лонговать или шортить индикатор подскажет. (не финансовый совет)
Cambio de Volumen (%)Descripción del Indicador: Cambio de Volumen (%) con Delta y Coloreo de Velas
¡Bienvenido al indicador avanzado de Cambio de Volumen con Delta! Este indicador está diseñado para ayudarte a identificar de manera visual las velas que presentan cambios significativos en el volumen con respecto a la vela anterior, lo que puede ser una señal importante de movimientos potencialmente fuertes en el mercado. A través de un sistema de colores dinámicos, este indicador no solo te alerta sobre el cambio de volumen, sino que también te proporciona información adicional sobre el delta (la diferencia entre el cierre actual y el anterior), lo que te permite tomar decisiones de trading más informadas.
¿Cómo usar este indicador?
Configura el umbral de volumen:
Puedes elegir entre una serie de umbrales predefinidos para determinar qué constituye un "gran" cambio de volumen. Estas opciones incluyen 38.2%, 50%, 61.8%, 78.6%, 100%, 250%, 350% y 500%. Al seleccionar uno de estos, el indicador coloreará las velas que superen ese umbral.
Coloreado de velas:
Las velas se colorean automáticamente en verde si el cambio de volumen es positivo y en rojo si es negativo, lo que te ayuda a visualizar rápidamente qué velas presentan un cambio significativo en volumen y cómo se comporta el precio.
Visualiza el porcentaje de cambio:
En la parte superior de las velas seleccionadas, podrás ver el porcentaje de cambio de volumen, proporcionándote un dato clave que puede servirte para decidir si una vela tiene el suficiente volumen como para justificar una operación.
Tamaño personalizable de las etiquetas:
Puedes ajustar el tamaño de las etiquetas con el porcentaje de cambio de volumen directamente desde las opciones del indicador, permitiendo mayor flexibilidad en la visualización según tus preferencias.
Ejemplos de Funcionamiento
Ejemplo 1: Si seleccionas un umbral de 50%, y el volumen de una vela supera este porcentaje en comparación con la vela anterior, esa vela se coloreará de acuerdo a si su delta es positivo (verde) o negativo (rojo). Esto te da una alerta visual clara sobre el comportamiento del mercado y te permite evaluar si es un buen momento para entrar o salir del mercado.
Ejemplo 2: Si el volumen de una vela excede el umbral de 100%, y el delta es negativo, la vela se coloreará de rojo, indicándote que aunque el volumen fue grande, el precio está cayendo, lo que puede ser una señal de debilidad en el mercado.
Ventajas del Indicador
Visualización clara y sencilla: El cambio de volumen se refleja de manera intuitiva con colores de velas, facilitando la comprensión del comportamiento del mercado.
Detección de movimientos significativos: Puedes detectar rápidamente velas con volumen anómalo, lo que puede ayudarte a identificar oportunidades de trading en base a cambios significativos de volumen y precio.
Personalización de umbrales y tamaños: Puedes ajustar los valores de umbral de volumen y personalizar el tamaño de las etiquetas según tu estilo y preferencia de visualización, haciéndolo flexible para cada tipo de trader.
Comodidad en el análisis técnico: Al integrar el cambio de volumen con la información sobre el delta de cada vela, este indicador te ofrece una herramienta poderosa para evaluar la fuerza de los movimientos del mercado y hacer análisis más profundos.
Facilita decisiones rápidas: Con las velas coloreadas y el porcentaje de cambio visible, podrás tomar decisiones más informadas sin tener que hacer cálculos complejos mientras realizas tus análisis.
¡Contáctame para más información!
Si tienes alguna pregunta sobre cómo usar este indicador o si deseas sugerir mejoras o personalizaciones adicionales, no dudes en contactarme. Estoy disponible para ayudarte a sacarle el máximo provecho a este indicador y hacer que se ajuste mejor a tus necesidades de trading.
¡No olvides probar el indicador y ver cómo puede mejorar tu análisis de mercado!
Awesome Oscillator Twin Peaks Strategy
1. The indicator identifies both bullish and bearish twin peaks:
- Bullish: Two consecutive valleys below zero, where the second valley is higher than the first
- Bearish: Two consecutive peaks above zero, where the second peak is lower than the first
2. Visual elements:
- AO histogram with color-coding for increasing/decreasing values
- Triangle markers for confirmed twin peak signals
- Zero line for reference
- Customizable colors through inputs
3. Built-in safeguards:
- Minimum separation between peaks to avoid false signals
- Maximum time window for pattern completion
- Clear signal reset conditions
4. Alert conditions for both bullish and bearish signals
To use this indicator:
1. Add it to your TradingView chart
2. Customize the input parameters if needed
3. Look for triangle markers that indicate confirmed twin peak patterns
4. Optional: Set up alerts based on the signal conditions
XSRM Support and Resistant LevelXSRMulti is an advanced indicator designed to help traders analyze various price levels and identify potential trading opportunities. This indicator primarily focuses on tracking price movements based on high, low, and mid levels. Users have the flexibility to analyze these levels across different timeframes and price sources (open, close, high, low).
Features and Settings:
General Settings:
Bar Back: Determines how many bars back in time the price movements should be analyzed.
Offset: Defines the offset value used in calculations.
H/L Depth: The depth used for analyzing the highest and lowest price levels.
Mid: The ratio used to calculate the mid-level between the highest and lowest prices.
Optional Settings:
Source: Defines the price source used for calculating high and low levels (open, close, average, etc.).
Use HeikinAshi for range: Option to use HeikinAshi candles for price range analysis.
Logarithmic: Option to apply logarithmic calculations to price levels.
Break at first swing: Determines whether to break at the first price swing.
Visual Features:
Colors: The user can choose three different colors for the analyzed levels.
Extend left/right: Allows the extension of analyzed levels to the past or future.
How It Works:
XSRMulti operates based on three main analysis zones:
Zone 1: The highest, lowest, and mid levels are calculated and plotted.
Zone 2: A second analysis zone is created with similar calculations.
Zone 3: A third analysis zone is formed using the same methods.
Each zone is based on specific bar analysis, which determines the price levels. These levels can be used to make trading decisions. The user can also choose to extend the levels further to the right or left.
Table Information:
The indicator includes a table displaying daily price rate of change. This provides the user with insights into daily price movements.
Usage:
XSRMulti is a powerful analysis tool for traders. It is particularly useful for short-term traders, as it provides detailed insights into price movements. Users can make trading decisions based on the identified levels, especially when the price reaches certain thresholds.
Note:
The indicator uses current timeframe price data for calculations.
HeikinAshi-based analysis presents smoother price movements, making trend-following easier.
Double RS StrengthThis indicator is showing the strength of RS for 3 and 6 month.
You can compare the stock with the benchmark as well to any sector.
You can modify the length of RS.
Whenever both line crosses above zero It become green and below zero line color will be red.
Santa's Secrets | FractalystSanta’s Secrets is a visually engaging trading tool that infuses holiday cheer into your charts. Inspired by the enchanting, mysterious vibes of the holiday season, this indicator overlays price charts with dynamic, multi-colored glitches that sync with market data, delivering a festive and whimsical visual experience.
The indicator brings a magical touch to your charts, featuring characters from classic holiday themes (e.g., Santa, reindeer, snowflakes, gift boxes) to create a fun and festive “glitch effect.” Users can select a theme for their matrix characters, adding a holiday twist to their trading visuals. As the market data moves, these themed characters are randomly picked and displayed on the chart in a colorful cascade.
Underlying Calculations and Logic
1.Character Management:
The indicator uses arrays to manage different sets of holiday-themed characters, such as Santa’s sleigh, snowflakes, and reindeer. These arrays allow dynamic selection and update of characters as the market moves, mimicking a festive glitch effect.
2. Current and Previous States:
Arrays track the current and previous states of characters, ensuring smooth transitions between visual updates. This dual-state management enables the effects to look like a magical, continuous movement, just like Santa’s sleigh cruising through the winter night.
3. Transparency Control:
Transparency levels are controlled through arrays, adjusting opacity to create subtle fading effects or more intense visual appearances. The result is a festive glow that can fade or intensify depending on the market’s volatility.
4. Rain Effect Simulation:
To create the “snowfall” or “glitching lights” effect, the indicator manages arrays that simulate falling characters, like snowflakes or candy canes, continuously updating their position and visibility. As new characters enter the top of the screen, older ones disappear from the bottom, with fading transparency to simulate a seamless flow.
5. Operational Flow:
• Initialization: Arrays initialize the characters and transparency controls, readying the script for smooth and continuous updates during trading.
• Updates: During each cycle, new characters are selected and the old ones shift, with updates in both content and appearance ensuring the matrix effect is visually appealing.
• Rendering: The arrays control how the characters are rendered, ensuring the magical holiday effect stays lively and eye-catching without interrupting the trading flow.
How to Use Santa’s Secrets Indicator
1. Apply the Indicator to Your Charts:
Add the Santa’s Secrets indicator to your chart, activating the holiday-themed visual effect on your selected trading instrument or time frame.
2. Select Your Holiday Theme:
In the settings, choose the holiday theme or character set. Whether it’s Santa’s sleigh, reindeer, snowflakes, or gift boxes, pick the one that brings the most festive cheer to your charts.
3. Choose Your Visual Effect (Snowfall or Glitch Burst):
Select between the “Snowfall” effect, where characters gently drift down the chart like snowflakes, or the “Glitch Burst” effect, where characters explode outward in a burst of holiday cheer, representing bursts of market volatility.
4. Adjust the Color for Holiday Vibes:
Customize the color of the characters to match your chart’s aesthetic or reflect different market conditions. Choose from red for a downtrend, green for an uptrend, or opt for a gradient of colors to capture a true holiday spirit.
5. Fit the Matrix to Your Display:
Adjust the width and height of the matrix display to make sure it fits perfectly with your chart layout. Ensure it doesn’t obscure your view while still providing the holiday-themed magic.
What Makes Santa’s Secrets Indicator Unique?
Holiday Theme Selection:
Santa’s Secrets allows traders to choose from a variety of holiday-themed characters. Whether you prefer the traditional Santa’s sleigh, snowflakes, reindeer, or gift boxes, you can bring the festive spirit into your trading. This personalized touch adds a fun, holiday twist to your charts and keeps you engaged during the festive season.
Dynamic Effects:
Choose between two exciting visual modes – Snowfall Mode or Glitch Burst Mode. The Snowfall Mode brings a gentle, peaceful effect with characters cascading down the chart like snowflakes, while Glitch Burst Mode creates a more intense effect, radiating characters outward in an explosive, holiday-themed display.
Customizable Holiday Colors:
Traders can fully customize the color of the matrix characters to match their trading environment. Whether you want a traditional red and green for a Christmas mood or a blue and white snow effect, Santa’s Secrets allows you to create the perfect holiday atmosphere while you trade.
Universal Display Compatibility:
No matter what screen or device you’re using – whether it’s a large monitor, laptop, or mobile – Santa’s Secrets is fully adjustable to fit your screen size. The holiday effect remains visually striking without compromising the integrity of your chart data.
Wishing you a happy year filled with success, growth, and profitable trades.🎅🎁
Let's kick off the new year strong with Santa's Secrets! 🚀🎄
Scalping BTC Ottimizzato - Grafica Chiara---
Scalping BTC Optimized Strategy – Clear Visualization and Dynamic Risk Management
Overview:
The Scalping BTC Optimized Strategy is designed for high-frequency trading on Bitcoin using a 15-minute timeframe. It combines key technical indicators to maximize trading efficiency while maintaining clear visual cues and dynamic risk management.
Key Indicators Used:
1. EMA (Exponential Moving Averages)
- EMA Fast (9 periods): Tracks short-term price momentum.
- EMA Slow (21 periods): Identifies long-term trend direction.
- Purpose: EMA crossovers generate Long and Short signals.
2. RSI (Relative Strength Index)
- Length: 14 periods
- Overbought Level: 70
- Oversold Level: 30
- Purpose: Filters trades in extreme price conditions.
3. ADX (Average Directional Index)
- Length: 14 periods
- Smoothing: 14 periods
- Threshold: 20
- Purpose: Confirms if the market is trending strongly to avoid false signals.
4. ATR (Average True Range)
- Length: 14 periods
- Stop Loss Multiplier: 1.5x ATR
- Take Profit Multiplier: 2.0x ATR
- Purpose: Dynamically adjusts Stop Loss and Take Profit levels based on market volatility.
How the Strategy Works:
1. Long Entry:
- Condition: EMA Fast crosses above EMA Slow.
- Filter: RSI is below 70, ADX is above 20.
- Execution: Place Long order with ATR-based Stop Loss and Take Profit.
2. Short Entry:
- Condition: EMA Fast crosses below EMA Slow.
- Filter: RSI is above 30, ADX is above 20.
- Execution: Place Short order with ATR-based Stop Loss and Take Profit.
3. Exit Rules:
- Positions are automatically closed based on ATR thresholds.
- Manual Exit Trigger: RSI exceeding overbought or oversold levels.
Visual Representation on the Chart:
- EMA Lines: Clearly plotted and anchored to the candles.
- Trade Signals:
- Green Triangles (Long Entry).
- Red Triangles (Short Entry).
- Indicator Panels (Separate):
- RSI Panel: Tracks overbought or oversold zones.
- ADX Panel: Highlights trend strength.
- ATR Panel: Displays market volatility.
Advantages of the Strategy:
- Trend Alignment: EMA crossovers identify trend changes accurately.
- Dynamic Risk Management: ATR adjusts Stop Loss and Take Profit levels based on volatility.
- Momentum Validation: RSI prevents entering overbought or oversold zones.
- Trend Strength Filter: ADX ensures trades are executed in strong trending markets.
- Clear Visualization: Organized layout with distinct panels and chart signals.
Alerts:
Automatic alerts for Long and Short signals ensure you never miss a trading opportunity.
Recommended Settings:
- Timeframe: 15-minute chart
- ATR Multiplier: 1.0–2.5
- ADX Threshold: 20–25
- RSI Length: 7–14
This strategy provides a balanced approach to scalping, combining trend-following signals, momentum filtering, and dynamic risk management. Its clean and intuitive visualization makes it ideal for both manual traders and automated setups.
---
XYZ
1. Elder Impulse System
The Elder Impulse System uses two indicators:
EMA (to determine trend direction)
MACD Histogram (to measure momentum)
Application:
Green bar: Trend is upward, and momentum is increasing (buy signal).
Red bar: Trend is downward, and momentum is decreasing (sell signal).
Blue bar: Indecision or range-bound movement.
2. VWAP (Volume Weighted Average Price)
VWAP is used to assess whether the price is overvalued or undervalued relative to volume.
Swing Strategy - XAUUSD (50-Point Stop Loss)a strategy in which you enter in change in trend with a stoploss of 50 points and targets of 200-400 points. that means 4:1 to 8:1 strategy.
[TST] ALGOSuper Trend RSi BB Moving Awerange ATR Base Trailling . Support And Resistance Technical Indicator
Purple SMA Strategythe final indicator
trade for only 1 hour , find your entry and hold
get out when no x
us xed candedls as stop loss
protect your trade , hold your runners
luusang//@version=5
indicator('Swing', shorttitle='GoodLuck', overlay=true, max_lines_count=500)
//-----Input-------
customTF = input.timeframe(defval="",title = "Show Other TimeFrame")
GroupGann = "Gann"
showGann = input.bool(false, 'Show Gann/Color/Width', group = GroupGann, inline = "Gann1")
colorGann = input.color(color.aqua, '', group = GroupGann,inline = "Gann1")
widthGann = input.int(defval=1,title = "",minval=1,step=1, group = GroupGann,inline = "Gann1")
GroupSGann = "Swing of Gann"
showSGann = input.bool(true, 'Show Swing/Color/Width', group = GroupSGann,inline = "Swing1")
colorSGann = input.color(color.blue, '', group = GroupSGann,inline = "Swing1")
widthSGann = input.int(defval=1,title = "",minval=1,step=1, group = GroupSGann,inline = "Swing1")
showChoCh = input.bool(false, 'Show ChoCh/Color/Width', group = GroupSGann,inline = "Choch")
colorChoch = input.color(color.red, '', group = GroupSGann,inline = "Choch")
widthChoch = input.int(defval=1,title = "",minval=1,step=1, group = GroupSGann,inline = "Choch")
show2ChoCh = input.bool(false, 'Show 2Choch/Color/Width', group = GroupSGann,inline = "2Choch")
color2Choch = input.color(color.purple, '', group = GroupSGann,inline = "2Choch")
width2Choch = input.int(defval=1,title = "",minval=1,step=1, group = GroupSGann,inline = "2Choch")
showtargetOTL = input.bool(true, 'Show Target OTL/Color/Width',group = GroupSGann, inline = "target")
colortargetOTL = input.color(color.purple, '', group = GroupSGann, inline = "target")
widthtargetOTL = input.int(defval=1,title = "",minval=1,step=1, group = GroupSGann,inline = "target")
showLabel = input.bool(false, 'Show Label TimeFrame',group = GroupSGann)
//showLinePrice = input.bool(true, 'Show LinePrice/Color/Width', group = GroupSGann,inline = "LinePrice")
//colorLinePrice = input.color(color.blue, '', group = GroupSGann,inline = "LinePrice")
//widthLinePrice = input.int(defval=1,title = "",minval=1,step=1, group = GroupSGann,inline = "LinePrice")
///tùy chọn line//
lineGann = input.string(title="",options= ,defval='(╌)', group = GroupGann, inline = "Gann1")
lineStyleGann = lineGann == "(┈)" ? line.style_dotted : lineGann == "(╌)" ? line.style_dashed : line.style_solid
lineSGann = input.string(title="",options= ,defval="(─)", group = GroupSGann, inline = "Swing1")
lineStyleSGann = lineSGann == "(┈)" ? line.style_dotted : lineSGann == "(╌)" ? line.style_dashed : line.style_solid
line2Choch = input.string(title="",options= ,defval="(╌)", group = GroupSGann, inline = "2Choch")
lineStyle2Choch = line2Choch == "(┈)" ? line.style_dotted : line2Choch == "(╌)" ? line.style_dashed : line.style_dashed
lineChoch = input.string(title="",options= ,defval="(─)", group = GroupSGann, inline = "Choch")
lineStyleChoch = lineChoch == "(┈)" ? line.style_dotted : lineChoch == "(╌)" ? line.style_dashed : lineChoch == "(←)" ? line.style_arrow_left : lineChoch == "(→)" ? line.style_arrow_right : lineChoch == "(↔)" ? line.style_arrow_both : line.style_solid
linetargetOTL = input.string(title="",options= ,defval="(→)", group = GroupSGann, inline = "target")
lineStyletargetOTL = linetargetOTL == "(┈)" ? line.style_dotted : linetargetOTL == "(╌)" ? line.style_dashed : linetargetOTL == "(←)" ? line.style_arrow_left : linetargetOTL == "(→)" ? line.style_arrow_right : linetargetOTL == "(↔)" ? line.style_arrow_both : line.style_arrow_both
//in out side bar//
OSB_up_down ="Ousidebar up down"
//////////////////////////Global//////////////////////////
var arrayLineTemp = array.new_line()
// Funtion
f_resInMinutes() =>
_resInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60. :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 1440. :
timeframe.isweekly ? 10080. :
timeframe.ismonthly ? 43800. : na)
// Converts a resolution expressed in minutes into a string usable by "security()"
f_resFromMinutes(_minutes) =>
_minutes < 1 ? str.tostring(math.round(_minutes*60)) + "S" :
_minutes < 60 ? str.tostring(math.round(_minutes)) + "m" :
_minutes < 1440 ? str.tostring(math.round(_minutes/60)) + "H" :
_minutes < 10080 ? str.tostring(math.round(math.min(_minutes / 1440, 7))) + "D" :
_minutes < 43800 ? str.tostring(math.round(math.min(_minutes / 10080, 4))) + "W" :
str.tostring(math.round(math.min(_minutes / 43800, 12))) + "M"
f_tfRes(_res,_exp) =>
request.security(syminfo.tickerid,_res,_exp,lookahead=barmerge.lookahead_on)
var arrayLineChoCh = array.new_line()
var label labelTF = label.new(time, close, text = "",color = color.new(showSGann ? colorSGann : colorGann,95), textcolor = showSGann ? colorSGann : colorGann,xloc = xloc.bar_time, textalign = text.align_left)
var line lineChoChOTLTarget = line.new(x1= time , y1=close,x2=time, y2= close,color = showSGann ? colortargetOTL : colorGann,xloc = xloc.bar_time,style = lineStyletargetOTL,width = widthtargetOTL)
var line lineBosOTLTarget = line.new(x1= time , y1=close,x2=time, y2= close,color = showSGann ? colortargetOTL : colorGann,xloc = xloc.bar_time,style = lineStyletargetOTL, width = widthtargetOTL)
//var line line_Price = line.new(x1= time , y1=close,x2=time, y2= close,color = showSGann ? colorLinePrice : colorGann,xloc = xloc.bar_time,style = lineStyleLinePrice, width = widthLinePrice)
styleGann = showSGann ? line.style_dashed : line.style_solid
var arrayXGann = array.new_int(5,time)
var arrayYGann = array.new_float(5,close)
var arrayLineGann = array.new_line()
int drawLineGann = 0
_high = high
_low = low
_close = close
_open = open
if(customTF != timeframe.period)
_high := f_tfRes(customTF,high)
_low := f_tfRes(customTF,low)
_close := f_tfRes(customTF,close)
_open := f_tfRes(customTF,open)
highPrev = _high
lowPrev = _low
// drawLineGann => 2:Tiếp tục 1:Đảo chiều; // Outsidebar 2:Tiếp tục 3:Tiếp tục và Đảo chiều 4 : Đảo chiều 2 lần
drawLineGann := 0
if(_high > highPrev and _low > lowPrev )
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(_high <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high )
drawLineGann := 2
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high )
drawLineGann := 1
else if(_high < highPrev and _low < lowPrev )
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low )
drawLineGann := 1
else
if(_low >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low )
drawLineGann := 2
else if(_high >= highPrev and _low < lowPrev or _high > highPrev and _low <= lowPrev )
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(_high >= array.get(arrayYGann,0) and array.get(arrayYGann,1) < _low )
if(_high <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high )
drawLineGann := 2
else if(_high >= array.get(arrayYGann,0) and array.get(arrayYGann,1) > _low )
if(_close < _open)
if(_high <= high)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _high )
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low )
drawLineGann := 3
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low )
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high )
drawLineGann := 4
else if(array.get(arrayYGann,0) < array.get(arrayYGann,1))
if(_low <= array.get(arrayYGann,0) and _high < array.get(arrayYGann,1))
if(_low >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low )
drawLineGann := 2
else if(_low <= array.get(arrayYGann,0) and _high > array.get(arrayYGann,1))
if(_close > _open)
if(_low >= low)
array.set(arrayXGann, 0, time)
array.set(arrayYGann, 0, _low )
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high )
drawLineGann := 3
else
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_high )
array.unshift(arrayXGann,time)
array.unshift(arrayYGann,_low )
drawLineGann := 4
else if((_high <= highPrev and _low >= lowPrev ))
highPrev := highPrev
lowPrev := lowPrev
if(f_resInMinutes() < f_tfRes(customTF,f_resInMinutes()) and drawLineGann == 0)
if(array.get(arrayYGann,0) > array.get(arrayYGann,1))
if(array.get(arrayYGann,0) <= high)
array.set(arrayXGann, 0, time)
drawLineGann := 2
else
if(array.get(arrayYGann,0) >= low)
array.set(arrayXGann, 0, time)
drawLineGann := 2
if(showGann and f_resInMinutes() <= f_tfRes(customTF,f_resInMinutes()))
if(drawLineGann == 2)
if(array.size(arrayLineGann) >0)
line.set_xy2(array.get(arrayLineGann,0),array.get(arrayXGann,0),array.get(arrayYGann,0))
else
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc = xloc.bar_time, style = lineStyleGann,width = widthGann))
else if(drawLineGann == 1)
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc = xloc.bar_time, style = lineStyleGann,width = widthGann))
else if(drawLineGann == 3)
if(array.size(arrayLineGann) >0)
line.set_xy2(array.get(arrayLineGann,0),array.get(arrayXGann,1),array.get(arrayYGann,1))
else
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,2),array.get(arrayYGann,2),array.get(arrayXGann,1),array.get(arrayYGann,1), color = colorGann,xloc = xloc.bar_time, style = lineStyleGann,width = widthGann))
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc = xloc.bar_time, style = lineStyleGann,width = widthGann))
else if(drawLineGann == 4)
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,2),array.get(arrayYGann,2),array.get(arrayXGann,1),array.get(arrayYGann,1), color = colorGann,xloc = xloc.bar_time, style = lineStyleGann,width = widthGann))
array.unshift(arrayLineGann,line.new(array.get(arrayXGann,1),array.get(arrayYGann,1),array.get(arrayXGann,0),array.get(arrayYGann,0), color = colorGann,xloc = xloc.bar_time, style = lineStyleGann,width = widthGann))
//////////////////////////Swing Gann//////////////////////////
var arrayXSGann = array.new_int(5,time)
var arrayYSGann = array.new_float(5,close)
var arrayLineSGann = array.new_line()
int drawLineSGann = 0
int drawLineSGann1 = 0
bool runCheckChoChSGann = false
runCheckChoChSGann := runCheckChoChSGann
if(showSGann)
if(math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1)) < math.min(array.get(arrayYGann,0),array.get(arrayYGann,1)) or math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1)) > math.max(array.get(arrayYGann,0),array.get(arrayYGann,1)))
//Khởi tạo bắt đầu
drawLineSGann1 := 5
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
array.set(arrayYSGann, 0, array.get(arrayYGann,1))
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
// drawLineSGann kiểm tra điểm 1 => 13:Tiếp tục có sóng hồi // 12|19(reDraw):Tiếp tục không có sóng hồi // 14:Đảo chiều
if(array.get(arrayXGann,0) == array.get(arrayXGann,1))
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,2) and array.get(arrayYSGann,0) != array.get(arrayYGann,1) and ((array.get(arrayYGann,1) > array.get(arrayYGann,2) and array.get(arrayYSGann,0) > array.get(arrayYSGann,1)) or (array.get(arrayYGann,1) < array.get(arrayYGann,2) and array.get(arrayYSGann,0) < array.get(arrayYSGann,1))))
drawLineSGann1 := 12
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
array.set(arrayYSGann, 0, array.get(arrayYGann,1))
else if(array.get(arrayXSGann,0) <= array.get(arrayXGann,2))
if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and array.get(arrayYGann,1) < array.get(arrayYSGann,1)) or (array.get(arrayYSGann,0) < array.get(arrayYSGann,1) and array.get(arrayYGann,1) > array.get(arrayYSGann,1)))
drawLineSGann1 := 14
runCheckChoChSGann := true
array.unshift(arrayXSGann,array.get(arrayXGann,1))
array.unshift(arrayYSGann,array.get(arrayYGann,1))
else if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and array.get(arrayYGann,1) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) < array.get(arrayYSGann,1) and array.get(arrayYGann,1) < array.get(arrayYSGann,0)))
drawLineSGann1 := 13
_max = math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_min = math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_max_idx = 0
_min_idx = 0
for i = 2 to array.size(arrayXGann)
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,i))
break
if(_min > array.get(arrayYGann,i))
_min := array.get(arrayYGann,i)
_min_idx := array.get(arrayXGann,i)
if(_max < array.get(arrayYGann,i))
_max := array.get(arrayYGann,i)
_max_idx := array.get(arrayXGann,i)
if(array.get(arrayYSGann,0) > array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_min_idx)
array.unshift(arrayYSGann,_min)
else if(array.get(arrayYSGann,0) < array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_max_idx)
array.unshift(arrayYSGann,_max)
array.unshift(arrayXSGann,array.get(arrayXGann,1))
array.unshift(arrayYSGann,array.get(arrayYGann,1))
if(f_resInMinutes() < f_tfRes(customTF,f_resInMinutes()))
if(array.get(arrayYSGann,0) == array.get(arrayYGann,1) and array.get(arrayXSGann,0) != array.get(arrayXGann,1))
array.set(arrayXSGann, 0, array.get(arrayXGann,1))
drawLineSGann1 := 19
if(f_resInMinutes() <= f_tfRes(customTF,f_resInMinutes()))
if(drawLineSGann1 == 12 or drawLineSGann1 == 19)
if(array.size(arrayLineSGann) >0)
line.set_xy2(array.get(arrayLineSGann,0),array.get(arrayXSGann,0),array.get(arrayYSGann,0))
else
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthSGann, style = lineStyleSGann))
else if(drawLineSGann1 == 14)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
else if(drawLineSGann1 == 13)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,2),array.get(arrayYSGann,2),array.get(arrayXSGann,1),array.get(arrayYSGann,1), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
else if(drawLineSGann1 == 15)
if(array.size(arrayLineSGann) >0)
line.set_xy2(array.get(arrayLineSGann,0),array.get(arrayXSGann,1),array.get(arrayYSGann,1))
else
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,2),array.get(arrayYSGann,2),array.get(arrayXSGann,1),array.get(arrayYSGann,1), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
if(runCheckChoChSGann)
runCheckChoChSGann := false
// ChoCh Trường hợp chữ N ngược, chữ N
if((array.get(arrayYSGann,3) > array.get(arrayYSGann,2) and array.get(arrayYSGann,3) < array.get(arrayYSGann,1) and array.get(arrayYSGann,0) < array.get(arrayYSGann,2)) or (array.get(arrayYSGann,3) < array.get(arrayYSGann,2) and array.get(arrayYSGann,3) > array.get(arrayYSGann,1) and array.get(arrayYSGann,0) > array.get(arrayYSGann,2)))
alert(syminfo.ticker + " : " + timeframe.period + " => Swing of Gann ChoCh" + (array.get(arrayYSGann,0) > array.get(arrayYSGann,1) ? "+ ⇑" : "- ⇓"))
if(showChoCh)
array.unshift(arrayLineChoCh,line.new(x1= array.get(arrayXSGann,2) , y1=array.get(arrayYSGann,2),x2=array.get(arrayXSGann,0), y2=array.get(arrayYSGann,2),color = colorChoch,xloc = xloc.bar_time,style = lineStyleChoch,width = widthChoch))
// ChoCh 2 Đầu Trường hợp chữ N ngược, chữ N
if(show2ChoCh and ((array.get(arrayYSGann,1) > array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,4) and array.get(arrayYSGann,4) > array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) > array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,4) and array.get(arrayYSGann,4) > array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,1))))
line.set_width(array.get(arrayLineSGann,1),width2Choch)
line.set_style(array.get(arrayLineSGann,1), lineStyle2Choch)
line.set_color(array.get(arrayLineSGann,1),color2Choch)
// drawLineSGann kiểm tra điểm 0 => 3:Tiếp tục có sóng hồi // 2|9(reDraw):Tiếp tục không có sóng hồi // 4:Đảo chiều
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,1) and array.get(arrayYSGann,0) != array.get(arrayYGann,0) and ((array.get(arrayYGann,0) > array.get(arrayYGann,1) and array.get(arrayYSGann,0) > array.get(arrayYSGann,1)) or (array.get(arrayYGann,0) < array.get(arrayYGann,1) and array.get(arrayYSGann,0) < array.get(arrayYSGann,1))))
drawLineSGann := 2
array.set(arrayXSGann, 0, array.get(arrayXGann,0))
array.set(arrayYSGann, 0, array.get(arrayYGann,0))
else if(array.get(arrayXSGann,0) <= array.get(arrayXGann,1))
if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and array.get(arrayYGann,0) < array.get(arrayYSGann,1)) or (array.get(arrayYSGann,0) < array.get(arrayYSGann,1) and array.get(arrayYGann,0) > array.get(arrayYSGann,1)))
drawLineSGann := 4
runCheckChoChSGann := true
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
else if((array.get(arrayYSGann,0) > array.get(arrayYSGann,1) and array.get(arrayYGann,0) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) < array.get(arrayYSGann,1) and array.get(arrayYGann,0) < array.get(arrayYSGann,0)))
drawLineSGann := 3
_max = math.min(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_min = math.max(array.get(arrayYSGann,0),array.get(arrayYSGann,1))
_max_idx = 0
_min_idx = 0
for i = 1 to array.size(arrayXGann)
if(array.get(arrayXSGann,0) >= array.get(arrayXGann,i))
break
if(_min > array.get(arrayYGann,i))
_min := array.get(arrayYGann,i)
_min_idx := array.get(arrayXGann,i)
if(_max < array.get(arrayYGann,i))
_max := array.get(arrayYGann,i)
_max_idx := array.get(arrayXGann,i)
if(array.get(arrayYSGann,0) > array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_min_idx)
array.unshift(arrayYSGann,_min)
else if(array.get(arrayYSGann,0) < array.get(arrayYSGann,1))
array.unshift(arrayXSGann,_max_idx)
array.unshift(arrayYSGann,_max)
array.unshift(arrayXSGann,array.get(arrayXGann,0))
array.unshift(arrayYSGann,array.get(arrayYGann,0))
if(f_resInMinutes() < f_tfRes(customTF,f_resInMinutes()))
if(array.get(arrayYSGann,0) == array.get(arrayYGann,0) and array.get(arrayXSGann,0) != array.get(arrayXGann,0))
array.set(arrayXSGann, 0, array.get(arrayXGann,0))
drawLineSGann := 9
if(f_resInMinutes() <= f_tfRes(customTF,f_resInMinutes()))
if(drawLineSGann == 2 or drawLineSGann == 9)
if(array.size(arrayLineSGann) >0)
line.set_xy2(array.get(arrayLineSGann,0),array.get(arrayXSGann,0),array.get(arrayYSGann,0))
else
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
else if(drawLineSGann == 4)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
else if(drawLineSGann == 3)
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,2),array.get(arrayYSGann,2),array.get(arrayXSGann,1),array.get(arrayYSGann,1), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
else if(drawLineSGann == 5)
if(array.size(arrayLineSGann) >0)
line.set_xy2(array.get(arrayLineSGann,0),array.get(arrayXSGann,1),array.get(arrayYSGann,1))
else
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,2),array.get(arrayYSGann,2),array.get(arrayXSGann,1),array.get(arrayYSGann,1), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
array.unshift(arrayLineSGann,line.new(array.get(arrayXSGann,1),array.get(arrayYSGann,1),array.get(arrayXSGann,0),array.get(arrayYSGann,0), color = colorSGann,xloc = xloc.bar_time,width = widthSGann,style = lineStyleSGann))
if(runCheckChoChSGann)
runCheckChoChSGann := false
// ChoCh Trường hợp chữ N ngược, chữ N
if((array.get(arrayYSGann,3) > array.get(arrayYSGann,2) and array.get(arrayYSGann,3) < array.get(arrayYSGann,1) and array.get(arrayYSGann,0) < array.get(arrayYSGann,2)) or (array.get(arrayYSGann,3) < array.get(arrayYSGann,2) and array.get(arrayYSGann,3) > array.get(arrayYSGann,1) and array.get(arrayYSGann,0) > array.get(arrayYSGann,2)))
alert(syminfo.ticker + " : " + timeframe.period + " => Swing of Gann ChoCh" + (array.get(arrayYSGann,0) > array.get(arrayYSGann,1) ? "+ ⇑" : "- ⇓"))
if(showChoCh)
array.unshift(arrayLineChoCh,line.new(x1= array.get(arrayXSGann,2) , y1=array.get(arrayYSGann,2),x2=array.get(arrayXSGann,0), y2=array.get(arrayYSGann,2),color = colorChoch,xloc = xloc.bar_time,style = lineStyleChoch,width = widthChoch))
// ChoCh 2 Đầu Trường hợp chữ N ngược, chữ N
if(show2ChoCh and ((array.get(arrayYSGann,1) > array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,4) and array.get(arrayYSGann,4) > array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,0)) or (array.get(arrayYSGann,0) > array.get(arrayYSGann,2) and array.get(arrayYSGann,2) > array.get(arrayYSGann,4) and array.get(arrayYSGann,4) > array.get(arrayYSGann,3) and array.get(arrayYSGann,3) > array.get(arrayYSGann,1))))
line.set_width(array.get(arrayLineSGann,1),width2Choch)
line.set_style(array.get(arrayLineSGann,1),lineStyle2Choch)
line.set_color(array.get(arrayLineSGann,1),color2Choch)
///////////////////////Other//////////////////////////////////
if(f_resInMinutes() <= f_tfRes(customTF,f_resInMinutes()))
if(showSGann)
if(showtargetOTL)
if(drawLineSGann1 == 14)
line.set_xy1(lineChoChOTLTarget,array.get(arrayXSGann,3),array.get(arrayYSGann,3))
line.set_xy2(lineChoChOTLTarget,array.get(arrayXSGann,3),array.get(arrayYSGann,3)*2 - array.get(arrayYSGann,2))
else if(drawLineSGann1 == 13)
line.set_xy1(lineBosOTLTarget,array.get(arrayXSGann,3),array.get(arrayYSGann,3))
line.set_xy2(lineBosOTLTarget,array.get(arrayXSGann,3),array.get(arrayYSGann,3)*2 - array.get(arrayYSGann,2))
if(drawLineSGann == 4)
line.set_xy1(lineChoChOTLTarget,array.get(arrayXSGann,2),array.get(arrayYSGann,2))
line.set_xy2(lineChoChOTLTarget,array.get(arrayXSGann,2),array.get(arrayYSGann,2)*2 - array.get(arrayYSGann,1))
else if(drawLineSGann == 3)
line.set_xy1(lineBosOTLTarget,array.get(arrayXSGann,2),array.get(arrayYSGann,2))
line.set_xy2(lineBosOTLTarget,array.get(arrayXSGann,2),array.get(arrayYSGann,2)*2 - array.get(arrayYSGann,1))
if(showLabel and (barstate.islast or barstate.islastconfirmedhistory))
texLabel = f_resInMinutes() == f_tfRes(customTF,f_resInMinutes()) ? f_resFromMinutes(f_resInMinutes()) : f_resFromMinutes(f_tfRes(customTF,f_resInMinutes()))
label.set_xy(labelTF,array.get(arrayXSGann,0),array.get(arrayYSGann,0))
label.set_text(labelTF,texLabel)
label.set_style(labelTF,array.get(arrayYSGann,0) < array.get(arrayYSGann,1) ? label.style_label_upper_right : label.style_label_lower_right)
else if(showGann)
if(showLabel and (barstate.islast or barstate.islastconfirmedhistory))
texLabel = f_resInMinutes() == f_tfRes(customTF,f_resInMinutes()) ? f_resFromMinutes(f_resInMinutes()) : f_resFromMinutes(f_tfRes(customTF,f_resInMinutes()))
label.set_xy(labelTF,array.get(arrayXGann,0),array.get(arrayYGann,0))
label.set_text(labelTF,texLabel)
label.set_style(labelTF,array.get(arrayYGann,0) < array.get(arrayYGann,1) ? label.style_label_upper_right : label.style_label_lower_right)
///ema///
EMA = "EMA Setting"
len = input.int(21, minval=1, title="EMA Length")
len1= input.int(34, minval=1, title="EMA Length")
len2 = input.int(89, minval=1, title="EMA Length")
len3 = input.int(200, minval=1, title="EMA Length")
src = close
ema = ta.ema(src, len)
ema1 = ta.ema(close,len1) //34
ema2 = ta.ema(close,len2) //89
ema3 = ta.ema (close,len3)//200
up = ema > ema
down = ema < ema
mycolor = up ? #00a7bc : down ? #b91002 : color.blue
plot(ema, title="EMA", color=mycolor, linewidth=1)
//plot(ema1, title="EMA", color=mycolor, linewidth=1,editable = false)
//plot(ema2, title="EMA", color=mycolor, linewidth=1,editable = false)
//plot(ema3, title="EMA", color=mycolor, linewidth=1,editable = false)
table_color_up = color.new(#00a7bc,70)
table_color_down = color.new(#b91002,70)
//vẽ bảng ema + rsi//
t = table.new(position = position.bottom_right, columns = 5, rows = 9, bgcolor = #fde9c9)
table.cell(t, 0, 0, "Time",text_size = size.small)
table.cell(t, 1, 0, "EMA",text_size = size.small)
table.cell(t, 0, 1, "5m",text_size = size.small)
table.cell(t, 0, 2, "15m",text_size = size.small)
table.cell(t, 0, 3, "4h",text_size = size.small)
table.cell(t, 0, 4, "1d",text_size = size.small)
// tính toán giá EMA của các khung thời gian khác nhau
ema5 = request.security(syminfo.tickerid, "5", ta.ema(src, len))
ema15 = request.security(syminfo.tickerid, "15", ta.ema(src, len))
ema4h = request.security(syminfo.tickerid, "240", ta.ema(src, len))
ema1d = request.security(syminfo.tickerid, "D", ta.ema(src, len))
//tô màu cho bảng chứa EMA
ema5_color = ema5 < close ? table_color_up : table_color_down
ema15_color = ema15 < close ? table_color_up :table_color_down
ema4h_color = ema4h < close ? table_color_up : table_color_down
ema1d_color = ema1d < close ? table_color_up : table_color_down
//tính toán ema 123_5
//ema5_1 = request.security(syminfo.tickerid, "5", ta.ema(close, len1))
//ema5_2 = request.security(syminfo.tickerid, "5", ta.ema(close, len2))
//ema5_3 = request.security(syminfo.tickerid, "5", ta.ema(close, len3))
//trend_ema5_color = (ema5_1 > ema5_2 and ema5_2 > ema5_3) ? color.green : (ema5_1 > ema5_2 and ema5_2 < ema5_3)? color.new(color.green,70) : (ema5_1 < ema5_2 and ema5_2 < ema5_3) ? color.red : (ema5_1 < ema5_2 and ema5_2 > ema5_3) ? color.new(color.red,70) : color.orange
//tính toán ema 123_15
ema15_1 = request.security(syminfo.tickerid, "15", ta.ema(close, len1))
ema15_2 = request.security(syminfo.tickerid, "15", ta.ema(close, len2))
ema15_3 = request.security(syminfo.tickerid, "15", ta.ema(close, len3))
trend_ema15_color = (ema15_1 > ema15_2 and ema15_2 > ema15_3) ? color.green : (ema15_1 > ema15_2 and ema15_2 < ema15_3)? color.new(color.green,70) : (ema15_1 < ema15_2 and ema15_2 < ema15_3) ? color.red : (ema15_1 < ema15_2 and ema15_2 > ema15_3) ? color.new(color.red,70) : color.orange
//tính toán ema 123_4h
ema4h_1 = request.security(syminfo.tickerid, "240", ta.ema(close, len1))
ema4h_2 = request.security(syminfo.tickerid, "240", ta.ema(close, len2))
ema4h_3 = request.security(syminfo.tickerid, "240", ta.ema(close, len3))
trend_ema4h_color = (ema4h_1 > ema4h_2 and ema4h_2 > ema4h_3) ? color.green : (ema4h_1 > ema4h_2 and ema4h_2 < ema4h_3)? color.new(color.green,70) : (ema4h_1 < ema4h_2 and ema4h_2 < ema4h_3) ? color.red : (ema4h_1 < ema4h_2 and ema4h_2 > ema4h_3) ? color.new(color.red,70) : color.orange
// tính toán RSI của các khung thời gian khác nhau
rsi5 = request.security(syminfo.tickerid, "5", ta.rsi(src, 14))
rsi15 = request.security(syminfo.tickerid, "15", ta.rsi(src, 14))
rsi4h = request.security(syminfo.tickerid, "240", ta.rsi(src, 14))
rsi1d = request.security(syminfo.tickerid, "D", ta.rsi(src, 14))
//tô màu cho bảng chứa RSI
rsi5_color = rsi5 > 70 ? table_color_down : rsi5 < 30 ? table_color_up : color.orange
rsi15_color = rsi15 > 70 ? table_color_down : rsi15 < 30 ? table_color_up : color.orange
rsi4h_color = rsi4h > 70 ? table_color_down : rsi4h < 30 ? table_color_up : color.orange
rsi1d_color = rsi1d > 70 ? table_color_down : rsi1d < 30 ? table_color_up : color.orange
//tính toán % thay đổi 1d, 7d, 30d
// Lấy giá trị giá đóng cửa của các ngày trước đó
yesterday_close = request.security(syminfo.tickerid, "D", close )
last_week_close = request.security(syminfo.tickerid, "W", close )
last_month_close = request.security(syminfo.tickerid, "M", close )
// Tính toán phần trăm thay đổi giá so với các ngày trước đó
day_change = math.round((close / yesterday_close - 1) * 100,1)
week_change = math.round((close / last_week_close - 1) * 100,1)
month_change = math.round((close / last_month_close - 1) * 100,1)
//tô màu cho bảng chứa % thay đổi
day_change_color = day_change < 0 ? table_color_down : table_color_up
weak_change_color = week_change < 0 ? table_color_down : table_color_up
month_change_color = month_change < 0 ? table_color_down : table_color_up
// tính toán btc.d usdt.d dxy
btc_d = request.security("CRYPTOCAP:BTC.D", timeframe.period, close)
usdt_d = request.security("CRYPTOCAP:USDT.D", timeframe.period, close)
dxy = request.security("TVC:DXY", timeframe.period, close)
yesterday_btc_d = request.security("CRYPTOCAP:BTC.D", timeframe.period, close )
yesterday_usdt_d = request.security("CRYPTOCAP:USDT.D", timeframe.period, close )
yesterday_dxy = request.security("TVC:DXY", timeframe.period, close )
btc_d_color = btc_d < yesterday_btc_d ? table_color_down : table_color_up //too mau
usdt_d_color = usdt_d < yesterday_usdt_d ? table_color_down : table_color_up
dxy_color = dxy < yesterday_dxy ? table_color_down : table_color_up
// điền giá EMA vào bảng
table.cell(t, 1, 1, str.tostring(math.round(ema5, 3)), bgcolor = ema5_color,text_size = size.small)
table.cell(t, 1, 2, str.tostring(math.round(ema15, 3)), bgcolor = ema15_color,text_size = size.small)
table.cell(t, 1, 3, str.tostring(math.round(ema4h, 3)), bgcolor = ema4h_color,text_size = size.small)
table.cell(t, 1, 4, str.tostring(math.round(ema1d, 3)), bgcolor = ema1d_color,text_size = size.small)
// điền rsi vào bảng
show_info_2 = input.bool(title = "Show % RSI",defval = true,group = "Table Setting")
if show_info_2
table.cell(t, 2, 0, "RSI",text_size = size.small)
table.cell(t, 2, 1, str.tostring(math.round(rsi5,0)), bgcolor = rsi5_color,text_size = size.small)
table.cell(t, 2, 2, str.tostring(math.round(rsi15,0)), bgcolor = rsi15_color,text_size = size.small)
table.cell(t, 2, 3, str.tostring(math.round(rsi4h,0)), bgcolor = rsi4h_color,text_size = size.small)
table.cell(t, 2, 4, str.tostring(math.round(rsi1d,0)), bgcolor = rsi1d_color,text_size = size.small)
// điển % change vào bảng
show_info_1 = input.bool(title = "Show % Change 1d, 7d, 30d",defval = true,group = "Table Setting")
if show_info_1
table.cell(t,0,5,"%",text_size = size.small)
table.cell(t,1,5,"1d",text_size = size.small)
table.cell(t,2,5,"7d",text_size = size.small)
table.cell(t,3,5,"30d",text_size = size.small)
table.cell(t, 1, 6, str.tostring(day_change, "#.##") + "%",bgcolor= day_change_color,text_size = size.small)
table.cell(t, 2, 6, str.tostring(week_change, "#.##") + "%",bgcolor = weak_change_color,text_size = size.small)
table.cell(t, 3, 6, str.tostring(month_change,"#.##") + "%", bgcolor = month_change_color,text_size = size.small)
//điện btc.d usdt.d dxy vào bảng
Table_Info = "Table Setting"
show_info = input.bool(title = "Show BTC.D, USSDT, DXY",defval = true,group = "Table Setting")
if show_info
table.cell(t,0,7,"#",text_size = size.small)
table.cell(t,1,7,"BTC.D",text_size = size.small)
table.cell(t,2,7,"USDT.D",text_size = size.small)
table.cell(t,3,7,"DXY",text_size = size.small)
table.cell(t, 1, 8, str.tostring(btc_d, "#.##") + "%",bgcolor= btc_d_color,text_size = size.small)
table.cell(t, 2, 8, str.tostring(usdt_d, "#.##") + "%",bgcolor = usdt_d_color,text_size = size.small)
table.cell(t, 3, 8, str.tostring(dxy,"#.##") + "%", bgcolor = dxy_color,text_size = size.small)
//điền trend ema vào bảng
show_info_3 = input.bool(title = "Show Trend",defval = true,group = "Table Setting")
if show_info_3
table.cell(t,3,0,"Trend",text_size = size.small)
//table.cell(t,3,1,"",bgcolor = trend_ema5_color)
table.cell(t,3,2,"",bgcolor = trend_ema15_color)
table.cell(t,3,3,"",bgcolor = trend_ema4h_color)
//đánh dấu volume với các osb + nến bulish bearish
//indicator("Color Ultra Volume Background", shorttitle = "UV",overlay=true, max_boxes_count=500, max_labels_count=500, max_lines_count=500, max_bars_back=1000)
UltraVol = "Ultra volume background"
colorultravol = input.color(color.new(color.purple,50),"Color UltraVol",group = UltraVol)
//Công thức//
lengthVolumeMA = input.int(20,minval=1,title="Length of MA applied on Volume",group = UltraVol)
ratioUltraVolume = input.float(2.2,minval=1,title="Ultra High Volume Ratio", group = UltraVol)
float volumeMA = 0
volumeMA := nz(volumeMA ) + (volume-nz(volumeMA )) / lengthVolumeMA
ultraHighVolumeMin = volumeMA * ratioUltraVolume
volUltraHigh = volume >= ultraHighVolumeMin? true : false
// Màu volume
color_cande_up_down = input.color(color.new(color.purple,100),"Color UltraVol",group = OSB_up_down)
Candle_body = input.float(0.5, 'Height of Engulfing candle body (%)', group = OSB_up_down)
//scan nến osb-eng - mera mera//
osb_up = high > high and low < low and close > close
osb_down = high > high and low < low and close < close
eng_up = open >= close and close > high and (close - open) >= Candle_body*(high - low)
eng_down = open <= close and close < low and (open - close) >= Candle_body*(high - low)
mm_up = osb_up and close > close and close > close
mm_down = osb_down and close < close and close < close
cande_up = close > close
cande_down = close < close
//tô màu nến//
colorOSB_up = input.color(#0ba4f9,'colorOSB_up',inline = "Up Outside Bar",group = OSB_up_down)
colorOSB_down = input.color(#fd1700,'colorOSB_dowwn',inline = "Down Outside Bar",group = OSB_up_down)
barcolor(osb_up ? colorOSB_up : na, title="Up Outside Bar")
barcolor(osb_down ? colorOSB_down : na, title="Down Outside Bar")
coloreng_up = input.color(#00a7bc,'coloreng_up',inline = "Bullish Bar",group = OSB_up_down)
coloreng_down = input.color(#b91002,'coloreng_dowwn',inline = "Bearlish Bar",group = OSB_up_down)
barcolor(eng_up ? coloreng_up : na, title="Bullish Bar")
barcolor(eng_down ? coloreng_down : na, title="Bearlish Bar")
//đánh dấu vol - mera mera
plotshape(volUltraHigh and cande_up,"Candle_UltraVol_up_shape",style = shape.circle,location = location.belowbar,color = coloreng_up,size = size.tiny)
plotshape(volUltraHigh and cande_down,"Candle_UltraVol_down_shape",style = shape.circle,location = location.abovebar,color = coloreng_down,size = size.tiny)
plotshape(volUltraHigh and osb_up,"Up Outside Bar+ Vol",style = shape.circle,location = location.belowbar,color = color_cande_up_down,size = size.tiny)
plotshape(volUltraHigh and osb_down,"Down Outside Bar+ Vol",style = shape.circle,location = location.abovebar,color = color_cande_up_down,size = size.tiny)
plotshape(volUltraHigh and eng_up,"Bullish Bar + Vol",style = shape.circle,location = location.belowbar,color = color_cande_up_down,size = size.tiny)
plotshape(volUltraHigh and eng_down,"Bearlish + Vol Bar",style = shape.circle,location = location.abovebar,color = color_cande_up_down,size = size.tiny)
plotshape(mm_up ? high : na, style=shape.circle, location=location.belowbar, color=#0ba4f9,title = "Mera UP",size = size.tiny)
plotshape(mm_down ? low : na, style=shape.circle, location=location.abovebar, color=#fd1700, title = "Mera Down", size = size.tiny)
//cảnh báo khi xuất hiện nến/
close_osb_up = close
close_osb_down = close
close_eng_up = close
close_eng_down = close
close_mm_up = close
close_mm_down = close
time_h4 = request.security(syminfo.tickerid, "240",close)
time_D1 = request.security(syminfo.tickerid, "D",close)
if (osb_up and barstate.isconfirmed)
if (close_osb_up > ema)
alert("OSB_UP: Above Ema: " + str.tostring(close_osb_up))
if volUltraHigh
alert("OSB_UP + Volume: Above Ema: " + str.tostring(close_osb_up))
else if (close_osb_up < ema)
alert("OSB_UP: Below Ema: " + str.tostring(close_osb_up))
if volUltraHigh
alert("OSB_UP + Volume: Below Ema: " + str.tostring(close_osb_up))
if (osb_down and barstate.isconfirmed)
if (close_osb_down > ema)
alert("OSB_DOWN: Above Ema: " + str.tostring(close_osb_down))
if volUltraHigh
alert("OSB_DOWN + Volume: Above Ema: " + str.tostring(close_osb_down))
else if (close_osb_down < ema)
alert("OSB_DOWN: Below Ema: " + str.tostring(close_osb_down))
if volUltraHigh
alert("OSB_DOWN + Volume: Below Ema: " + str.tostring(close_osb_down))
if (eng_up and barstate.isconfirmed)
if (close_eng_up > ema)
alert("Bar_UP: Above Ema: " + str.tostring(close_eng_up))
if volUltraHigh
alert("Bar_UP + Volume: Above Ema: " + str.tostring(close_eng_up))
else if (close_eng_up < ema)
alert("Bar_UP: Below Ema: " + str.tostring(close_eng_up))
if volUltraHigh
alert("Bar_UP + Volume: Below Ema: " + str.tostring(close_eng_up))
if (eng_down and barstate.isconfirmed)
if (close_eng_down > ema)
alert("Bar_DOWN: Above Ema: " + str.tostring(close_eng_down))
if volUltraHigh
alert("Bar_DOWN + Volume: Above Ema: " + str.tostring(close_eng_down))
else if (close_eng_down < ema)
alert("Bar_DOWN: Below Ema: " + str.tostring(close_eng_down))
if volUltraHigh
alert("Bar_DOWN + Volume: Below Ema: " + str.tostring(close_eng_down))
if (mm_up and barstate.isconfirmed)
if (close_mm_up > ema)
alert("Mera_UP: Above Ema: " + str.tostring(close_mm_up))
if volUltraHigh
alert("Mera_UP + Volume: Above Ema: " + str.tostring(close_mm_up))
else if (close_mm_up < ema)
alert("Mera_UP: Below Ema: " + str.tostring(close_mm_up))
if volUltraHigh
alert("Mera_UP + Volume: Below Ema: " + str.tostring(close_mm_up))
if (mm_down and barstate.isconfirmed)
if (close_mm_down > ema)
alert("Mera_DOWN: Above Ema: " + str.tostring(close_mm_down))
if volUltraHigh
alert("Mera_DOWN + Volume: Above Ema: " + str.tostring(close_mm_down))
else if (close_mm_down < ema)
alert("Mera_DOWN: Below Ema: " + str.tostring(close_mm_down))
if volUltraHigh
alert("Mera_DOWN + Volume: Below Ema: " + str.tostring(close_mm_down))
//indicator("Initial Balance", shorttitle="Initial Balance", overlay=true, max_bars_back=5000)
ib_session = input.session("2300-0000", title="Initial Balance", group="Calculation period")
show_extra_levels = input.bool(false, "Show extra levels (IBH x2 & IBL x2)", group="Information")
show_intermediate_levels = input.bool(false, "Show intermediate levels (50%)", group="Information")
show_ib_calculation_area = input.bool(false, "Initial balance calculation period coloration", group="Information")
show_labels = input.bool(false, "Show labels", group="Information")
fill_ib_areas = input.bool(false, "Colour IB areas", group="Information")
only_current_levels = input.bool(true, "Only display the current IB Levels", group="Information")
only_current_zone = input.bool(false, "Only display the current IB calculation area", group="Information")
label_size = input.string("Small", title="Label Size", options= , group="Drawings")
lvl_width = input.int(1, "Daily price level width", group="Drawings")
high_col = input.color(color.black, "Initial balance high levels color", group="Drawings")
low_col = input.color(color.black, "Initial balance low levels color", group="Drawings")
middle_col = input.color(#ffa726, "50% initial balance color", group="Drawings")
extend_level = input.string("Right", title="Extend current levels", options= , group="Drawings")
main_levels_style = input.string("Solid" , "Main levels line style", options= , group="Drawings")
ext_levels_style = input.string("Dashed" , "Extended levels line style", options= , group="Drawings")
int_levels_style = input.string("Dotted" , "Intermediate levels line style", options= , group="Drawings")
fill_ib_color= input.color(#b8851faa, "IB area background color", group="Drawings")
ext = extend_level == "Right" ? extend.right : extend_level == "Left" ? extend.left : extend_level == "Both" ? extend.both : extend.none
var delta_history = array.new_float(20)
inSession(sess) => na(time(timeframe.period, sess)) == false
get_line_style(s) =>
s == "Solid" ? line.style_solid : s == "Dotted" ? line.style_dotted : line.style_dashed
get_levels(n) =>
h = high
l = low
for i=1 to n
if low < l
l := low
if high > h
h := high
var line ibh = na
var line ibl = na
var line ibm = na
var line ib_plus = na
var line ib_minus = na
var line ib_plus2 = na
var line ib_minus2 = na
var line ibm_plus = na
var line ibm_minus = na
var label labelh = na
var label labell = na
var label labelm = na
var label label_plus = na
var label label_minus = na
var label label_plus2 = na
var label label_minus2 = na
var label labelm_plus = na
var label labelm_minus = na
var box ib_area = na
labelSize = (label_size == "Huge") ? size.huge :
(label_size == "Large") ? size.large :
(label_size == "Small") ? size.small :
(label_size == "Tiny") ? size.tiny :
(label_size == "Auto") ? size.auto : size.normal
var offset = 0
ins = inSession(ib_session)
bgcolor(show_ib_calculation_area and ins ? #673ab730 : na, title="IB calculation zone")
var float ib_delta = na
if ins
offset += 1
if ins and not ins
= get_levels(offset)
ib_delta := h - l
if array.size(delta_history) >= 20
array.shift(delta_history)
array.push(delta_history, ib_delta)
line.set_extend(ibh, extend.none)
line.set_extend(ibl, extend.none)
if show_intermediate_levels
line.set_extend(ibm, extend.none)
if show_extra_levels
line.set_extend(ib_plus, extend.none)
line.set_extend(ib_minus, extend.none)
line.set_extend(ib_plus2, extend.none)
line.set_extend(ib_minus2, extend.none)
if show_intermediate_levels
line.set_extend(ibm_plus, extend.none)
line.set_extend(ibm_minus, extend.none)
if show_labels
if only_current_levels
label.delete(labelh)
label.delete(labell)
label.delete(labelm)
label.delete(label_plus)
label.delete(label_minus)
label.delete(label_plus2)
label.delete(label_minus2)
label.delete(labelm_plus)
label.delete(labelm_minus)
labelh := label.new(bar_index , h, text="IBH 100%: "+str.tostring(h), style=label.style_none, textcolor=high_col, size=labelSize)
labell := label.new(bar_index , l, text="IBL 0%: "+str.tostring(l), style=label.style_none, textcolor=low_col, size=labelSize)
if show_intermediate_levels
labelm := label.new(bar_index , m, text="IBM 50%: "+str.tostring(m)+" IBΔ: "+str.tostring(h - l), style=label.style_none, textcolor=middle_col, size=labelSize)
if show_extra_levels
label_plus := label.new(bar_index , h + ib_delta, text="IBH x2 - "+str.tostring(h + ib_delta), style=label.style_none, textcolor=high_col, size=labelSize)
label_minus := label.new(bar_index , l - ib_delta, text="IBL x2: "+str.tostring(l - ib_delta), style=label.style_none, textcolor=low_col, size=labelSize)
label_plus2 := label.new(bar_index , h + (ib_delta*2), text="IBH x3 - "+str.tostring(h + (ib_delta*2)), style=label.style_none, textcolor=high_col, size=labelSize)
label_minus2 := label.new(bar_index , l - (ib_delta*2), text="IBL x3: "+str.tostring(l - (ib_delta*2)), style=label.style_none, textcolor=low_col, size=labelSize)
if fill_ib_areas
if only_current_zone
box.delete(ib_area)
ib_area := box.new(bar_index , h, bar_index, l, bgcolor=fill_ib_color, border_color=#00000000)//, extend=ext)
if only_current_levels
line.delete(ibh)
line.delete(ibl)
line.delete(ibm)
line.delete(ib_plus)
line.delete(ib_minus)
line.delete(ib_plus2)
line.delete(ib_minus2)
line.delete(ibm_plus)
line.delete(ibm_minus)
ibh := line.new(bar_index , h, bar_index, h, color=high_col, extend=ext, width=lvl_width, style=get_line_style(main_levels_style))
ibl := line.new(bar_index , l, bar_index, l, color=low_col, extend=ext, width=lvl_width, style=get_line_style(main_levels_style))
if show_intermediate_levels
ibm := line.new(bar_index , m, bar_index, m, color=middle_col, style=get_line_style(int_levels_style), extend=ext, width=lvl_width)
if show_extra_levels
ib_plus := line.new(bar_index , h + ib_delta, bar_index, h + ib_delta, color=high_col, style=get_line_style(ext_levels_style), extend=ext, width=lvl_width)
ib_minus := line.new(bar_index , l - ib_delta, bar_index, l - ib_delta, color=low_col, style=get_line_style(ext_levels_style), extend=ext, width=lvl_width)
ib_plus2 := line.new(bar_index , h + (ib_delta*2), bar_index, h + (ib_delta *2), color=high_col, style=get_line_style(ext_levels_style), extend=ext, width=lvl_width)
ib_minus2 := line.new(bar_index , l - (ib_delta*2), bar_index, l - (ib_delta*2), color=low_col, style=get_line_style(ext_levels_style), extend=ext, width=lvl_width)
if show_intermediate_levels
ibm_plus := line.new(bar_index , h + (ib_delta/2), bar_index, h + (ib_delta/2), color=middle_col, style=get_line_style(int_levels_style), extend=ext, width=lvl_width)
ibm_minus := line.new(bar_index , l - (ib_delta/2), bar_index, l - (ib_delta/2), color=middle_col, style=get_line_style(int_levels_style), extend=ext, width=lvl_width)
offset := 0
if (not ins) and (not ins )
line.set_x2(ibh, bar_index)
line.set_x2(ibl, bar_index)
if show_intermediate_levels
line.set_x2(ibm, bar_index)
if show_extra_levels
line.set_x2(ib_plus, bar_index)
line.set_x2(ib_minus, bar_index)
line.set_x2(ib_plus2, bar_index)
line.set_x2(ib_minus2, bar_index)
if show_intermediate_levels
line.set_x2(ibm_plus, bar_index)
line.set_x2(ibm_minus, bar_index)
var table ib_analytics = table.new(position.bottom_left, 2, 6)
ib_sentiment() =>
h = array.max(delta_history)
l = array.min(delta_history)
a = array.avg(delta_history)
h_comp = ib_delta > h ? ib_delta - h : (ib_delta - h) * -1
l_comp = ib_delta > l ? ib_delta - l : (ib_delta - l) * -1
a_comp = ib_delta > a ? ib_delta - a : (ib_delta - a) * -1
(h_comp < l_comp and h_comp < a_comp) ? "Huge" : (l_comp < h_comp and l_comp < a_comp) ? "Small" : "Medium"
//@version=5
//indicator('Key Levels', overlay=true)
group = 'KEYLVL_SETTINGS'
displaystyle = input.string('Standard', ' Display Style', group = group, inline='onest', options= )
linestyle = input.string('Solid', ' Line Style ', group = group, inline='twost', options= )
fontstyle = input.string('Monospace', ' Font Type ', group = group, inline='trest', options= )
labelpos = input.string('Middle', ' Label Pos ', group = group, inline=' ', options= )
bar_offset = input.int (30, ' Offset ', group = group, inline='onest', minval=0, maxval=450, step = 5)
threshold = input.float (0.1, ' Threshold %', group = group, inline='twost', minval=0, step=0.05, tooltip='Threshold - the distance between the levels after which the labels merge.')
index = input.int (0, ' Index ', group = group, inline='trest', minval=0, step=1, tooltip='Index - Default 0 allows you to see current and past price levels. Changing to 1 will shift the current levels to the previous levels, and the previous levels to the previous levels, etc.')
color_cD = input.color (#2a89c9, ' cD', group = group, inline='cols1')
color_cW = input.color (#b7d123, ' cW', group = group, inline='cols1')
color_cM = input.color (#8056b8, ' cM', group = group, inline='cols1')
color_cQ = input.color (#c23eb0, ' cQ', group = group, inline='cols1')
color_cY = input.color (#d62e28, ' cY', group = group, inline='cols1')
color_pD = input.color (#2a89c9, ' pD', group = group, inline='cols2')
color_pW = input.color (#b7d123, ' pW', group = group, inline='cols2')
color_pM = input.color (#8056b8, ' pM', group = group, inline='cols2')
color_pQ = input.color (#c23eb0, ' pQ', group = group, inline='cols2')
color_pY = input.color (#d62e28, ' pY', group = group, inline='cols2', tooltip="Prefix 'C' = Current/today. Prefix 'P' = Previous/yesterday. Prefix 'D' = Day. Prefix 'W' = Week. Prefix 'M' = Mounth. Prefix 'Q' = Quarterly. Prefix 'Y' = Year.'" )
i_tG = input.bool (true, ' Global Color Text', group = group, inline='colsg')
color_tG = input.color (color.black, ' ', group = group, inline='colsg')
i_lG = input.bool (true, ' Global Color Line', group = group, inline='colsg')
color_lG = input.color (color.black, ' ', group = group, inline='colsg')
fontstyles = switch fontstyle
"Default" => font.family_default
"Monospace" => font.family_monospace
linestyles = switch linestyle
"Solid" => line.style_solid
"Dashed" => line.style_dashed
"Dotted" => line.style_dotted
displaystyles = switch displaystyle
"Standard" => extend.none
"Right" => extend.right
"Both" => extend.both
"Left" => extend.left
getprice(TimeFrame, Index)=> // Get Open, High, Low, Close, Time data
i = Index
tf = TimeFrame
= request.security(syminfo.tickerid, tf, [open , high , low , close , time ], lookahead=barmerge.lookahead_on)
= getprice('D', 0+index) // Get Current Day Open, High, Low, Close, Time
= getprice('W', 0+index) // Get Current Weekly Open, High, Low, Close, Time
= getprice('M', 0+index) // Get Current Mounth Open, High, Low, Close, Time
= getprice('3M', 0+index) // Get Current Quarter Open, High, Low, Close, Time
= getprice('12M', 0+index) // Get Current Year Open, High, Low, Close, Time
= getprice('D', 1+index) // Get Previous Day Open, High, Low, Close, Time
= getprice('W', 1+index) // Get Previous Weekly Open, High, Low, Close, Time
= getprice('M', 1+index) // Get Previous Mounth Open, High, Low, Close, Time
= getprice('3M', 1+index) // Get Previous Quarter Open, High, Low, Close, Time
= getprice('12M', 1+index) // Get Previous Year Open, High, Low, Close, Time
extend(bars) => // Extends the current time by the product of the time difference between elements and the number of bars.
timenow + (time - time ) * bars
getlevel(time, level, txtcolor, linecolor, txtlabel)=> // Get draws a line and a label on the chart
if barstate.islast // The following code doesn't need to be processed on every candle
xindex = displaystyle == 'Standard' ? time : bar_index+bar_offset
xloc = displaystyle == 'Standard' ? xloc.bar_time : xloc.bar_index
xid = displaystyle == 'Standard' ? extend(bar_offset) : bar_index+bar_offset+1
lblpos = labelpos == 'Middle' ? label.style_label_center : label.style_none
lines = line.new (x1=xindex, x2=xid, y1=level, y2=level, xloc=xloc, style=linestyles, extend=displaystyles, color=linecolor)
labels = label.new(x=xid, y=level, text=txtlabel, style=lblpos, xloc=xloc, text_font_family=fontstyles, textcolor=txtcolor, color = #ffffff00)
line.delete(lines ) // remove the previous line when new bar appears
label.delete(labels ) // remove the previous label when new bar appears
// Get Inputs, Lines, Labels
i_cDO = input(false, 'DO ', group = group, inline='D'), = getlevel(cDtime, i_cDO ? cDopen : na, i_tG ? color_tG : color_cD, i_lG ? color_lG : color_cD, 'DO' )
i_cDH = input(false, 'DH ', group = group, inline='D'), = getlevel(cDtime, i_cDH ? cDhigh : na, i_tG ? color_tG : color_cD, i_lG ? color_lG : color_cD, 'DH' )
i_cDL = input(false, 'DL ', group = group, inline='D'), = getlevel(cDtime, i_cDL ? cDlow : na, i_tG ? color_tG : color_cD, i_lG ? color_lG : color_cD, 'DL' )
i_pDO = input(false, 'pDO', group = group, inline='D'), = getlevel(pDtime, i_pDO ? pDopen : na, i_tG ? color_tG : color_pD, i_lG ? color_lG : color_pD, 'pDO' )
i_pDH = input(true, 'pDH', group = group, inline='D'), = getlevel(pDtime, i_pDH ? pDhigh : na, i_tG ? color_tG : color_pD, i_lG ? color_lG : color_pD, 'pDH' )
i_pDL = input(true, 'pDL', group = group, inline='D'), = getlevel(pDtime, i_pDL ? pDlow : na, i_tG ? color_tG : color_pD, i_lG ? color_lG : color_pD, 'pDL' )
i_cWO = input(false, 'WO ', group = group, inline='W'), = getlevel(cWtime, i_cWO ? cWopen : na, i_tG ? color_tG : color_cW, i_lG ? color_lG : color_cW, 'WO' )
i_cWH = input(false, 'WH ', group = group, inline='W'), = getlevel(cWtime, i_cWH ? cWhigh : na, i_tG ? color_tG : color_cW, i_lG ? color_lG : color_cW, 'WH' )
i_cWL = input(false, 'WL ', group = group, inline='W'), = getlevel(cWtime, i_cWL ? cWlow : na, i_tG ? color_tG : color_cW, i_lG ? color_lG : color_cW, 'WL' )
i_pWO = input(false, 'pWO', group = group, inline='W'), = getlevel(pWtime, i_pWO ? pWopen : na, i_tG ? color_tG : color_pW, i_lG ? color_lG : color_pW, 'pWO' )
i_pWH = input(false, 'pWH', group = group, inline='W'), = getlevel(pWtime, i_pWH ? pWhigh : na, i_tG ? color_tG : color_pW, i_lG ? color_lG : color_pW, 'pWH' )
i_pWL = input(false, 'pWL', group = group, inline='W'), = getlevel(pWtime, i_pWL ? pWlow : na, i_tG ? color_tG : color_pW, i_lG ? color_lG : color_pW, 'pWL' )
i_cMO = input(false, 'MO ', group = group, inline='M'), = getlevel(cMtime, i_cMO ? cMopen : na, i_tG ? color_tG : color_cM, i_lG ? color_lG : color_cM, 'MO' )
i_cMH = input(false, 'MH ', group = group, inline='M'), = getlevel(cMtime, i_cMH ? cMhigh : na, i_tG ? color_tG : color_cM, i_lG ? color_lG : color_cM, 'MH' )
i_cML = input(false, 'ML ', group = group, inline='M'), = getlevel(cMtime, i_cML ? cMlow : na, i_tG ? color_tG : color_cM, i_lG ? color_lG : color_cM, 'ML' )
i_pMO = input(false, 'pMO', group = group, inline='M'), = getlevel(pMtime, i_pMO ? pMopen : na, i_tG ? color_tG : color_pM, i_lG ? color_lG : color_pM, 'pMO' )
i_pMH = input(false, 'pMH', group = group, inline='M'), = getlevel(pMtime, i_pMH ? pMhigh : na, i_tG ? color_tG : color_pM, i_lG ? color_lG : color_pM, 'pMH' )
i_pML = input(false, 'pML', group = group, inline='M'), = getlevel(pMtime, i_pML ? pMlow : na, i_tG ? color_tG : color_pM, i_lG ? color_lG : color_pM, 'pML' )
i_cQO = input(false, 'QO ', group = group, inline='Q'), = getlevel(cQtime, i_cQO ? cQopen : na, i_tG ? color_tG : color_cQ, i_lG ? color_lG : color_cQ, 'QO' )
i_cQH = input(false, 'QH ', group = group, inline='Q'), = getlevel(cQtime, i_cQH ? cQhigh : na, i_tG ? color_tG : color_cQ, i_lG ? color_lG : color_cQ, 'QH' )
i_cQL = input(false, 'QL ', group = group, inline='Q'), = getlevel(cQtime, i_cQL ? cQlow : na, i_tG ? color_tG : color_cQ, i_lG ? color_lG : color_cQ, 'QL' )
i_pQO = input(false, 'pQO', group = group, inline='Q'), = getlevel(pQtime, i_pQO ? pQopen : na, i_tG ? color_tG : color_pQ, i_lG ? color_lG : color_pQ, 'pQO' )
i_pQH = input(false, 'pQH', group = group, inline='Q'), = getlevel(pQtime, i_pQH ? pQhigh : na, i_tG ? color_tG : color_pQ, i_lG ? color_lG : color_pQ, 'pQH' )
i_pQL = input(false, 'pQL', group = group, inline='Q'), = getlevel(pQtime, i_pQL ? pQlow : na, i_tG ? color_tG : color_pQ, i_lG ? color_lG : color_pQ, 'pQL' )
i_cYO = input(false, 'YO ', group = group, inline='Y'), = getlevel(cYtime, i_cYO ? cYopen : na, i_tG ? color_tG : color_cY, i_lG ? color_lG : color_cY, 'YO' )
i_cYH = input(false, 'YH ', group = group, inline='Y'), = getlevel(cYtime, i_cYH ? cYhigh : na, i_tG ? color_tG : color_cY, i_lG ? color_lG : color_cY, 'YH' )
i_cYL = input(false, 'YL ', group = group, inline='Y'), = getlevel(cYtime, i_cYL ? cYlow : na, i_tG ? color_tG : color_cY, i_lG ? color_lG : color_cY, 'YL' )
i_pYO = input(false, 'pYO', group = group, inline='Y'), = getlevel(pYtime, i_pYO ? pYopen : na, i_tG ? color_tG : color_pY, i_lG ? color_lG : color_pY, 'pYO' )
i_pYH = input(false, 'pYH', group = group, inline='Y'), = getlevel(pYtime, i_pYH ? pYhigh : na, i_tG ? color_tG : color_pY, i_lG ? color_lG : color_pY, 'pYH' )
i_pYL = input(false, 'pYL', group = group, inline='Y'), = getlevel(pYtime, i_pYL ? pYlow : na, i_tG ? color_tG : color_pY, i_lG ? color_lG : color_pY, 'pYL' )
// Сollecting labels into an array for normalization
labels = array.from(cDOlabel,cDHlabel,cDLlabel,pDOlabel,pDHlabel,pDLlabel,cWOlabel,cWHlabel,cWLlabel,pWOlabel,pWHlabel,pWLlabel,cMOlabel,cMHlabel,cMLlabel,pMOlabel,pMHlabel,pMLlabel,cQOlabel,cQHlabel,cQLlabel,pQOlabel,pQHlabel,pQLlabel,cYOlabel,cYHlabel,cYLlabel,pYOlabel,pYHlabel,pYLlabel)
// This loop merge items in arrays "labels" into a single label if their difference is less than a certain threshold, and updates the label text.
for i = 0 to array.size(labels) - 2 // Loop through all the labels
txt = label.get_text(array.get(labels, i)) // Get the text of the current label
price_i = label.get_y(array.get(labels, i)) // Get the y coordinate of the current label
label_i = array.get(labels, i) // Store the current label
for j = i + 1 to array.size(labels) - 1 // Loop through the remaining labels
price_j = label.get_y(array.get(labels, j)) // Get the y coordinate of the current label
if math.abs(price_i - price_j) < (threshold/100) * price_i // Compare the prices
txt := txt + ' / ' + label.get_text(array.get(labels, j)) // Add the text of the second label
label.delete(array.get(labels, j)) // Delete the second label
label.set_text(label_i, txt) // Set the text of the current label
repeat(str, num) => // Returns a string that is created by repeating the input str num times
res = ""
len = str.length(str)
if num > 0 and len * num <= 4096
for r = 1 to num
res := res + str
res
// Loop to change the position of the Label
if labelpos == 'Middle'
for z = 0 to array.size(labels) - 1
label_z = array.get(labels, z) // Get the label at position z
texts = label.get_text(label_z) // Get the text of the label
spaces = fontstyle=='Default' ? repeat(' ', math.ceil(str.length(texts))*2) : repeat(' ', math.ceil(str.length(texts))) // Calculate the number of spaces needed
label.set_text(label_z, displaystyle=='Right'? texts + spaces + ' ' : spaces+' ' + texts) // Set the label text with the calculated spaces
//
//@version=5
//indicator("Congestion Zone", overlay=true)
Congestion_Zone = "Congestio_Zone"
Show_CZ = input.bool(true, title="On/off Congestion Zone", group="Congestion_Zone")
minbar = input(title="Minimum Bars in Zone", defval=5, group="Congestion_Zone", inline="Box",tooltip = "Số lượng nến tối thiểu để có 1 vùng CZ")
border_width = input.int(title="CZ boder width", defval=1, inline="Box1", group="Congestion_Zone", step=1,tooltip = "Viền CZ")
max_boxes = input.int(title="Max CZ", defval=50, group="Congestion_Zone", minval=1,tooltip = "Số vùng box tối đa muốn hiển thị để tránh rối mắt")
boxcolor_basic = input.color(title="CZ Color Basic", defval=color.new(color.orange, 80), group="Congestion_Zone",tooltip = "Nến thoát khỏi box không có xu hướng rõ ràng")
boxcolor_up = input.color(title="CZ Color Up", defval=color.new(color.green, 80), group="Congestion_Zone",tooltip = "Nến thoát khỏi box có giá đóng cửa > vùng CZ")
boxcolor_down = input.color(title="CZ Color Dowwn", defval=color.new(color.red, 80), group="Congestion_Zone",tooltip = "Nến thoát khỏi box có đóng cửa < vùng CZ")
var boxopen = array.new_float()
var boxclose = array.new_float()
var boxes = array.new_box()
congestion_condition = close >= low and close <= high and open >= low and open <= high
if congestion_condition and Show_CZ
array.push(boxopen, open > close ? open : close)
array.push(boxclose, open > close ? close : open)
else if array.size(boxopen) < minbar
array.clear(boxopen)
array.clear(boxclose)
if not congestion_condition and array.size(boxopen) >= minbar and Show_CZ
box_max = array.max(boxopen)
box_min = array.min(boxclose)
box_color = close >= box_max ? boxcolor_up : close <= box_min ? boxcolor_down : boxcolor_basic
if box_color == boxcolor_basic
alert("CZ basic")
else if box_color == boxcolor_up
alert("CZ UP")
else if box_color == boxcolor_down
alert("CZ DOWN")
// Determine box color based on last candle
new_box = box.new(bar_index - array.size(boxopen), box_max, bar_index - 1, box_min, bgcolor=box_color, border_width=border_width,border_color = box_color)
array.push(boxes, new_box)
array.clear(boxopen)
array.clear(boxclose)
//Remove old boxes if limit is reached
while array.size(boxes) > max_boxes
box.delete(array.shift(boxes))
Fibonacci Extensions and Retracements for Selected TimeframesPurpose of the Script
This script plots Fibonacci levels (retracements and extensions) based on the high and low points of the previous day, previous week, or previous month. It is a trading aid to help identify potential support and resistance zones. These zones are often used by traders to determine entry or exit points for trades.
How It Works
Select Timeframe
The trader can choose whether to calculate Fibonacci levels based on the high and low points of the previous day, previous week, or previous month.
This is selected using the timeframe_input input.
Examples:
"D" for the previous day
"W" for the previous week
"M" for the previous month
Calculate Price Range
The script calculates the price range using the high and low of the selected timeframe:
Formula: price_range = High - Low
Draw Fibonacci Levels
Retracements: Within the price range, Fibonacci levels such as 12%, 23%, 38%, 50%, 61%, 78%, and 88% are calculated. These help identify potential support or resistance zones.
Extensions: Beyond the price range, Fibonacci extensions such as 127%, 161%, 200%, 224%, and 241% are plotted to indicate potential breakout targets.
Visualization
The script plots lines and labels for each level.
These lines extend to the right, providing real-time guidance during trading.
Colors and line styles can be customized to match personal preferences.
How to Use as a Trading Aid
Use Fibonacci Retracements:
Use retracements (e.g., 38%, 50%, 61%) to identify potential support or resistance zones.
Example: If the price dropped sharply the previous day, the retracement levels could act as support during a rebound.
Use Fibonacci Extensions:
Extensions help identify price targets when the price breaks above or below the high or low of the previous day, week, or month.
Example: After a breakout above the previous week’s high, the 127% or 161% level could serve as a target.
Adjust Timeframe:
Choose the timeframe that suits your strategy:
Intraday traders can use the previous day’s high and low.
Swing traders might prefer the previous week.
Long-term traders could work with the previous month.
Example
A trader selects the weekly timeframe (W) to analyze the high and low of the previous week:
The script calculates the price range based on the high and low of the previous week.
Fibonacci retracements (e.g., 50% and 61%) are drawn to identify potential support zones.
Fibonacci extensions (e.g., 127% and 161%) help define price targets for a potential breakout above or below the range.
Fibonacci Channel (200 SMA) AND CANDLE ANALYSISsame as other indicator, but includes extra candle indicators of bullish and bearish reversals at fib levels.
scan_wt_cross_set_1Bist100 hisselerini wt_cross gözüyle tarar, al veya sat sinyali veren hisseleri grafik üzerinde listeler. Sıkı veya rahat şekilde taramaya izin verir. Sıkı taramada aşırı sat bölgesinde al veya aşırı al bölgesinde sat veren hisseleri bulur.