TOTALES_LIBRARY_MAINLibrary "TOTALES_LIBRARY_MAIN"
sigmoid_strategy(source_sigmoid, lookback, volatility_period, base_steepness, base_midpoint, z_period, ma_type, ma_lookback, upper_threshold, lower_threshold)
Parameters:
source_sigmoid (float)
lookback (simple int)
volatility_period (simple int)
base_steepness (simple float)
base_midpoint (simple float)
z_period (simple int)
ma_type (simple string)
ma_lookback (simple int)
upper_threshold (simple float)
lower_threshold (simple float)
fdi_supertrend_strategy(src, per, speed, fdi_mult_upper, fdi_mult_lower, adapt)
Parameters:
src (float)
per (simple int)
speed (simple int)
fdi_mult_upper (simple float)
fdi_mult_lower (simple float)
adapt (simple bool)
volume_trend_strategy(volume_trend_x, volume_trend_y)
Parameters:
volume_trend_x (simple int)
volume_trend_y (simple int)
rti_strategy(rtiTrendDataCount, rtiTrendSensitivityPercentage, rtiSignalLength, upper_threshold_rti, lower_threshold_rti, useSignalLength_rti)
Parameters:
rtiTrendDataCount (simple int)
rtiTrendSensitivityPercentage (simple int)
rtiSignalLength (simple int)
upper_threshold_rti (simple float)
lower_threshold_rti (simple float)
useSignalLength_rti (simple bool)
zscore_heikin_strategy(len_zscore, upper_threshold_zscore, lower_threshold_zscore)
Parameters:
len_zscore (simple int)
upper_threshold_zscore (simple float)
lower_threshold_zscore (simple float)
emd_strategy(input_src_emd, avg_type_emd, length_emd, mult_upper_emd, mult_lower_emd)
Parameters:
input_src_emd (simple string)
avg_type_emd (simple string)
length_emd (simple int)
mult_upper_emd (simple float)
mult_lower_emd (simple float)
bbpct_strategy(length_bbpct, src_bbpct, mult_bbpct, upper_threshold_bbpct, lower_threshold_bbpct)
Parameters:
length_bbpct (simple int)
src_bbpct (float)
mult_bbpct (simple float)
upper_threshold_bbpct (simple float)
lower_threshold_bbpct (simple float)
dega_rma_strategy(src_dema, len_dema, len_FG, sigma_FG, len_rma, len_ATR, mult_ATRup, mult_ATRdn)
Parameters:
src_dema (float)
len_dema (simple int)
len_FG (simple int)
sigma_FG (simple float)
len_rma (simple int)
len_ATR (simple int)
mult_ATRup (simple float)
mult_ATRdn (simple float)
dssd_strategy(DemaLen_dssd, DemaSrc_dssd, PerLen_dssd, pertype_dssd, SDlen_dssd, EmaLen_dssd, IncluedeEma_dssd)
Parameters:
DemaLen_dssd (simple int)
DemaSrc_dssd (float)
PerLen_dssd (simple int)
pertype_dssd (simple string)
SDlen_dssd (simple int)
EmaLen_dssd (simple int)
IncluedeEma_dssd (simple bool)
impulsive_momentum_strategy(Lu_imp, Su_imp, yes_imp, lenEMA, mult, atr_length, lenEMA2, atr_momentum_length, mult2, lenMED, mult3, rsi_length, sma_rsi_length)
Parameters:
Lu_imp (simple float)
Su_imp (simple float)
yes_imp (simple bool)
lenEMA (simple int)
mult (simple float)
atr_length (simple int)
lenEMA2 (simple int)
atr_momentum_length (simple int)
mult2 (simple float)
lenMED (simple int)
mult3 (simple float)
rsi_length (simple int)
sma_rsi_length (simple int)
get_sigmoid_score(source_sigmoid, lookback, volatility_period, base_steepness, base_midpoint, z_period, ma_type, ma_lookback, upper_threshold, lower_threshold)
Parameters:
source_sigmoid (float)
lookback (simple int)
volatility_period (simple int)
base_steepness (simple float)
base_midpoint (simple float)
z_period (simple int)
ma_type (simple string)
ma_lookback (simple int)
upper_threshold (simple float)
lower_threshold (simple float)
get_fdi_supertrend_score(src, per, speed, fdi_mult_upper, fdi_mult_lower, adapt)
Parameters:
src (float)
per (simple int)
speed (simple int)
fdi_mult_upper (simple float)
fdi_mult_lower (simple float)
adapt (simple bool)
get_volume_trend_score(volume_trend_x, volume_trend_y)
Parameters:
volume_trend_x (simple int)
volume_trend_y (simple int)
get_rti_score(rtiTrendDataCount, rtiTrendSensitivityPercentage, rtiSignalLength, upper_threshold_rti, lower_threshold_rti, useSignalLength_rti)
Parameters:
rtiTrendDataCount (simple int)
rtiTrendSensitivityPercentage (simple int)
rtiSignalLength (simple int)
upper_threshold_rti (simple float)
lower_threshold_rti (simple float)
useSignalLength_rti (simple bool)
get_zscore_heikin_score(len_zscore, upper_threshold_zscore, lower_threshold_zscore)
Parameters:
len_zscore (simple int)
upper_threshold_zscore (simple float)
lower_threshold_zscore (simple float)
get_emd_score(input_src_emd, avg_type_emd, length_emd, mult_upper_emd, mult_lower_emd)
Parameters:
input_src_emd (simple string)
avg_type_emd (simple string)
length_emd (simple int)
mult_upper_emd (simple float)
mult_lower_emd (simple float)
get_bbpct_score(length_bbpct, src_bbpct, mult_bbpct, upper_threshold_bbpct, lower_threshold_bbpct)
Parameters:
length_bbpct (simple int)
src_bbpct (float)
mult_bbpct (simple float)
upper_threshold_bbpct (simple float)
lower_threshold_bbpct (simple float)
get_dega_rma_score(src_dema, len_dema, len_FG, sigma_FG, len_rma, len_ATR, mult_ATRup, mult_ATRdn)
Parameters:
src_dema (float)
len_dema (simple int)
len_FG (simple int)
sigma_FG (simple float)
len_rma (simple int)
len_ATR (simple int)
mult_ATRup (simple float)
mult_ATRdn (simple float)
get_dssd_score(DemaLen_dssd, DemaSrc_dssd, PerLen_dssd, pertype_dssd, SDlen_dssd, EmaLen_dssd, IncluedeEma_dssd)
Parameters:
DemaLen_dssd (simple int)
DemaSrc_dssd (float)
PerLen_dssd (simple int)
pertype_dssd (simple string)
SDlen_dssd (simple int)
EmaLen_dssd (simple int)
IncluedeEma_dssd (simple bool)
get_impulsive_momentum_score(Lu_imp, Su_imp, yes_imp, lenEMA, mult, atr_length, lenEMA2, atr_momentum_length, mult2, lenMED, mult3, rsi_length, sma_rsi_length)
Parameters:
Lu_imp (simple float)
Su_imp (simple float)
yes_imp (simple bool)
lenEMA (simple int)
mult (simple float)
atr_length (simple int)
lenEMA2 (simple int)
atr_momentum_length (simple int)
mult2 (simple float)
lenMED (simple int)
mult3 (simple float)
rsi_length (simple int)
sma_rsi_length (simple int)
get_tpi_score(use_sigmoid, use_fdi_supertrend, use_volume_trend, use_rti, use_zscore_heikin, use_emd, use_bbpct, use_dega_rma, use_dssd, use_impulsive_momentum, source_sigmoid, lookback, volatility_period, base_steepness, base_midpoint, z_period, ma_type, ma_lookback, upper_threshold, lower_threshold, src, per, speed, fdi_mult_upper, fdi_mult_lower, adapt, volume_trend_x, volume_trend_y, rtiTrendDataCount, rtiTrendSensitivityPercentage, rtiSignalLength, upper_threshold_rti, lower_threshold_rti, useSignalLength_rti, len_zscore, upper_threshold_zscore, lower_threshold_zscore, input_src_emd, avg_type_emd, length_emd, mult_upper_emd, mult_lower_emd, length_bbpct, src_bbpct, mult_bbpct, upper_threshold_bbpct, lower_threshold_bbpct, src_dema, len_dema, len_FG, sigma_FG, len_rma, len_ATR, mult_ATRup, mult_ATRdn, DemaLen_dssd, DemaSrc_dssd, PerLen_dssd, pertype_dssd, SDlen_dssd, EmaLen_dssd, IncluedeEma_dssd, Lu_imp, Su_imp, yes_imp, lenEMA, mult, atr_length, lenEMA2, atr_momentum_length, mult2, lenMED, mult3, rsi_length, sma_rsi_length)
Parameters:
use_sigmoid (simple bool)
use_fdi_supertrend (simple bool)
use_volume_trend (simple bool)
use_rti (simple bool)
use_zscore_heikin (simple bool)
use_emd (simple bool)
use_bbpct (simple bool)
use_dega_rma (simple bool)
use_dssd (simple bool)
use_impulsive_momentum (simple bool)
source_sigmoid (float)
lookback (simple int)
volatility_period (simple int)
base_steepness (simple float)
base_midpoint (simple float)
z_period (simple int)
ma_type (simple string)
ma_lookback (simple int)
upper_threshold (simple float)
lower_threshold (simple float)
src (float)
per (simple int)
speed (simple int)
fdi_mult_upper (simple float)
fdi_mult_lower (simple float)
adapt (simple bool)
volume_trend_x (simple int)
volume_trend_y (simple int)
rtiTrendDataCount (simple int)
rtiTrendSensitivityPercentage (simple int)
rtiSignalLength (simple int)
upper_threshold_rti (simple float)
lower_threshold_rti (simple float)
useSignalLength_rti (simple bool)
len_zscore (simple int)
upper_threshold_zscore (simple float)
lower_threshold_zscore (simple float)
input_src_emd (simple string)
avg_type_emd (simple string)
length_emd (simple int)
mult_upper_emd (simple float)
mult_lower_emd (simple float)
length_bbpct (simple int)
src_bbpct (float)
mult_bbpct (simple float)
upper_threshold_bbpct (simple float)
lower_threshold_bbpct (simple float)
src_dema (float)
len_dema (simple int)
len_FG (simple int)
sigma_FG (simple float)
len_rma (simple int)
len_ATR (simple int)
mult_ATRup (simple float)
mult_ATRdn (simple float)
DemaLen_dssd (simple int)
DemaSrc_dssd (float)
PerLen_dssd (simple int)
pertype_dssd (simple string)
SDlen_dssd (simple int)
EmaLen_dssd (simple int)
IncluedeEma_dssd (simple bool)
Lu_imp (simple float)
Su_imp (simple float)
yes_imp (simple bool)
lenEMA (simple int)
mult (simple float)
atr_length (simple int)
lenEMA2 (simple int)
atr_momentum_length (simple int)
mult2 (simple float)
lenMED (simple int)
mult3 (simple float)
rsi_length (simple int)
sma_rsi_length (simple int)
get_all_strategy_scores(source_sigmoid, lookback, volatility_period, base_steepness, base_midpoint, z_period, ma_type, ma_lookback, upper_threshold, lower_threshold, src, per, speed, fdi_mult_upper, fdi_mult_lower, adapt, volume_trend_x, volume_trend_y, rtiTrendDataCount, rtiTrendSensitivityPercentage, rtiSignalLength, upper_threshold_rti, lower_threshold_rti, useSignalLength_rti, len_zscore, upper_threshold_zscore, lower_threshold_zscore, input_src_emd, avg_type_emd, length_emd, mult_upper_emd, mult_lower_emd, length_bbpct, src_bbpct, mult_bbpct, upper_threshold_bbpct, lower_threshold_bbpct, src_dema, len_dema, len_FG, sigma_FG, len_rma, len_ATR, mult_ATRup, mult_ATRdn, DemaLen_dssd, DemaSrc_dssd, PerLen_dssd, pertype_dssd, SDlen_dssd, EmaLen_dssd, IncluedeEma_dssd, Lu_imp, Su_imp, yes_imp, lenEMA, mult, atr_length, lenEMA2, atr_momentum_length, mult2, lenMED, mult3, rsi_length, sma_rsi_length)
Parameters:
source_sigmoid (float)
lookback (simple int)
volatility_period (simple int)
base_steepness (simple float)
base_midpoint (simple float)
z_period (simple int)
ma_type (simple string)
ma_lookback (simple int)
upper_threshold (simple float)
lower_threshold (simple float)
src (float)
per (simple int)
speed (simple int)
fdi_mult_upper (simple float)
fdi_mult_lower (simple float)
adapt (simple bool)
volume_trend_x (simple int)
volume_trend_y (simple int)
rtiTrendDataCount (simple int)
rtiTrendSensitivityPercentage (simple int)
rtiSignalLength (simple int)
upper_threshold_rti (simple float)
lower_threshold_rti (simple float)
useSignalLength_rti (simple bool)
len_zscore (simple int)
upper_threshold_zscore (simple float)
lower_threshold_zscore (simple float)
input_src_emd (simple string)
avg_type_emd (simple string)
length_emd (simple int)
mult_upper_emd (simple float)
mult_lower_emd (simple float)
length_bbpct (simple int)
src_bbpct (float)
mult_bbpct (simple float)
upper_threshold_bbpct (simple float)
lower_threshold_bbpct (simple float)
src_dema (float)
len_dema (simple int)
len_FG (simple int)
sigma_FG (simple float)
len_rma (simple int)
len_ATR (simple int)
mult_ATRup (simple float)
mult_ATRdn (simple float)
DemaLen_dssd (simple int)
DemaSrc_dssd (float)
PerLen_dssd (simple int)
pertype_dssd (simple string)
SDlen_dssd (simple int)
EmaLen_dssd (simple int)
IncluedeEma_dssd (simple bool)
Lu_imp (simple float)
Su_imp (simple float)
yes_imp (simple bool)
lenEMA (simple int)
mult (simple float)
atr_length (simple int)
lenEMA2 (simple int)
atr_momentum_length (simple int)
mult2 (simple float)
lenMED (simple int)
mult3 (simple float)
rsi_length (simple int)
sma_rsi_length (simple int)
get_tpi_color(tpi_score)
Parameters:
tpi_score (float)
get_strategy_color(score)
Parameters:
score (float)
format_strategy_score(is_enabled, score)
Parameters:
is_enabled (bool)
score (float)
Göstergeler ve stratejiler
Penny Stock Short ScalpPenny Stock Short Scalp:
This Penny Stock Short Scalp Strategy is designed for traders aiming to capitalize on rapid, short-term price declines in penny stocks using TradingView. Focused on high-volatility periods, this strategy leverages quick entries and exits to capture small, consistent profits.
Strategy Overview
Timeframe: 1-minute or 2-minute charts for precise entries and exits.
Market: Penny stocks (low-priced, high-volatility stocks, typically under $5).
Trading Window: Best executed during the first 1-2 hours of market open (9:30 AM - 11:30 AM EST) when volatility is highest.
Position Type: Short positions only, targeting rapid price drops.
Key Indicators
Exponential Moving Average (EMA): 20-period EMA to identify short-term trends. A price below the EMA signals a potential short opportunity.
Relative Strength Index (RSI): 14-period RSI to detect overbought conditions (RSI > 70) for short entry signals.
Volume: High trading volume confirms momentum and liquidity for quick exits.
Bollinger Bands: Used to identify overextended price movements. A price touching or breaking above the upper band suggests a potential reversal for shorting.
Entry Rules
Price Action: Price breaks above the 20 EMA and touches or exceeds the upper Bollinger Band.
RSI Confirmation: RSI is above 70, indicating overbought conditions.
Volume Surge: A spike in volume supports the potential for a quick reversal.
Support/Resistance: Identify a nearby resistance level (intraday or daily) to confirm the short setup.
Exit Rules
Profit Target: Aim for a 2-5% price drop or a fixed profit target (e.g., $0.05-$0.10 per share, depending on stock price).
Stop Loss: Set a stop loss above the recent high or 2% above entry to limit risk.
Close Position: Exit if the price crosses back above the 20 EMA or RSI drops below 50, signaling a potential reversal.
Risk Management
Position Sizing: Risk no more than 1-2% of your account per trade.
Liquidity Check: Ensure the stock has sufficient volume to avoid slippage.
Time Limit: Exit trades within 5-10 minutes to avoid holding through unpredictable swings.
Notes
Market Conditions: Best suited for ranging or slightly bearish markets where pullbacks are frequent.
Caution: Penny stocks are highly volatile; use tight stops and avoid overleveraging.
Platform: Configure TradingView with the above indicators and use real-time data for accurate signals.
Disclaimer: This strategy involves significant risk due to the volatile nature of penny stocks. Always conduct your own research and consult a financial advisor before trading. Past performance is not indicative of future results.
ema_stoploss_libLibrary "ema_stoploss_lib"
This library derives stop-loss levels from a dynamic list of EMA lengths. It computes each EMA internally (so dynamic lengths are allowed), keeps strict side filtering (long: only EMAs below the source; short: only EMAs above), sorts by distance to the source, and returns the n-th nearest value plus the original index of that EMA length.
get_stop_loss(index)
Initializes (once) a default length list:
21, 50, 100, 200, 250, 500, 750, 1000.
Returns:
sl_buy / sl_sell: selected EMA values
nearest_buy_idx / nearest_sell_idx: 0-based indices in the original lensArr
Parameters & Notes
Index (input in the example; default 2) is 0-based:
0 = nearest, 1 = second nearest, 2 = third, etc.
If there aren’t enough EMAs on the requested side, the value becomes na (plot will skip that bar).
Strict filtering means no fallback to the opposite side.
Performance:
EMA updates are O(n) per bar (n = number of lengths).
Sorting is O(k²) (k = candidates on the chosen side) — negligible for small lists.
oscillator fast cryptosmart (Bands on Scale)The oscillator fast cryptosmart is a high-sensitivity momentum indicator designed to generate signals more rapidly than many traditional oscillators, such as the MACD. It is engineered to detect potential price breakouts by analyzing short-term market cycles.
At its core, the indicator uses a Detrended Price Oscillator (DPO) to remove the longer-term trend from price action, allowing it to focus purely on the underlying momentum cycles. It then calculates dynamic volatility bands around this oscillator line.
Signals are generated when momentum breaks out from a normal range, providing traders with an early warning of a potential acceleration in price.
How to Interpret the Signals:
Buy Signal (Green Vertical Line): A buy signal is generated when the oscillator's main line (yellow) crosses above its upper statistical band. This indicates a sharp surge in positive momentum, suggesting a potential upward move is beginning.
Sell Signal (Red Vertical Line): A sell signal is generated when the oscillator's main line crosses below its lower statistical band. This indicates a significant increase in negative momentum, suggesting a potential downward move is starting.
By focusing on momentum breakouts rather than lagging moving average crossovers, the oscillator fast cryptosmart aims to provide an edge in identifying opportunities in fast-moving markets.
High/Low Targets - Abu Aydسكربت
//@version=5
indicator("High/Low Targets - Abu Ayd", overlay = true, max_lines_count = 200, ع")
widthLow = input.int(2, "سماكة خط القاع", minval=1, maxval=5)
colorHigh = input.color(color.purple, "لون خط القمة")
widthHigh = input.int(2, "سماكة خط القمة", minval=1, maxval=5)
colorUp = input.color(color.green, "لون أهداف الصعود")
widthUp = input.int(1, "سماكة أهداف الصعود", minval=1, maxval=5)
colorDown = input.color(color.red, "لون أهداف الهبوط")
widthDown = input.int(1, "سماكة أهداف الهبوط", minval=1, maxval=5)
//========= مكان كتابة الأهداف =========//
labelPosition = input.string("يمين", "مكان كتابة الأهداف", options= )
offsetBars = input.int(5, "المسافة أفقياً للكتابة", minval=1, maxval=50)
//========= عدد الأهداف =========//
targetsUpNum = input.int(5, "عدد أهداف الصعود", minval=1, maxval=20)
targetsDownNum = input.int(5, "عدد أهداف الهبوط", minval=1, maxval=20)
//========= حساب القاع والقمة =========//
srcLow = request.security(syminfo.tickerid, tf == "" ? timeframe.period : tf, ta.lowest(low, lookback))
srcHigh = request.security(syminfo.tickerid, tf == "" ? timeframe.period : tf, ta.highest(high, lookback))
// قاع أمس
yLow = request.security(syminfo.tickerid, "D", low )
yHigh = request.security(syminfo.tickerid, "D", high )
yOpen = request.security(syminfo.tickerid, "D", open )
yClose = request.security(syminfo.tickerid, "D", close )
yBodyLow = math.min(yOpen, yClose)
yLowerWick = yBodyLow - yLow
yRange = yHigh - yLow
isValidYesterdayLow = yLowerWick > yRange * wickRatio
// اختيار القاع
lowPoint =
mode == "Manual" ? manualLow :
(mode == "Auto" and useYesterdayLow and isValidYesterdayLow) ? yLow :
srcLow
// اختيار القمة
highPoint = mode == "Auto" ? srcHigh : manualHigh
//========= دالة لحساب مكان الليبل =========//
f_getXoffset(_pos) =>
_pos == "يمين" ? bar_index + offsetBars : _pos == "يسار" ? bar_index - offsetBars : bar_index
//========= أهداف القاع =========//
if mode == "Manual" or (mode == "Auto" and showLowAuto and not na(lowPoint))
// أهداف فوق القاع
for i = 1 to targetsUpNum
levelUp = lowPoint + stepUp * i
line.new(bar_index, levelUp, bar_index+1, levelUp, color=colorUp, width=widthUp, extend=extend.right)
if barstate.islast
label.new(f_getXoffset(labelPosition), levelUp, "🎯 " + str.tostring(levelUp),
textcolor=color.white, color=colorUp, style=label.style_label_left,
xloc=xloc.bar_index, yloc=yloc.price)
// أهداف تحت القاع إذا اخترنا "فوق وتحت"
if lowTargetsMode == "فوق وتحت"
for i = 1 to targetsDownNum
levelDownFromLow = lowPoint - stepDown * i
line.new(bar_index, levelDownFromLow, bar_index+1, levelDownFromLow, color=colorDown, width=widthDown, extend=extend.right)
if barstate.islast
label.new(f_getXoffset(labelPosition), levelDownFromLow, "🎯 " + str.tostring(levelDownFromLow),
textcolor=color.white, color=colorDown, style=label.style_label_left,
xloc=xloc.bar_index, yloc=yloc.price)
//========= أهداف القمة =========//
if mode == "Manual" or (mode == "Auto" and showHighAuto)
Anil's Momentum Scanner with Buy/Sell ArrowsThis script will:
Plot green arrows when bullish momentum is strong.
Plot red arrows when bearish momentum is strong.
Use VWAP, RSI, Volume, and EMA crossovers to confirm momentum.
Works ONLY with 2h timeframe.
✅ BUY (Green Arrow) appears when:
Price is above VWAP
Fast EMA > Slow EMA (trend up)
RSI > 70 (momentum positive)
Volume > 1.1x average
✅ SELL (Red Arrow) appears when:
Price is below VWAP
Fast EMA < Slow EMA (trend down)
RSI < 50 (momentum weak)
Volume > 1.1x average
Scalp EMA+RSI+ADX+Vol v7 (универсальная, x25)// @version=6
// Scalp EMA+RSI+ADX+Vol v7 — универсальная версия с ликвидационным стопом (x25)
// Автор: ChatGPT
// === ПАРАМЕТРЫ ===
percent_of_equity = input.float(2.0, "Position size (% of equity)", step=0.1, minval=0.1)
fastLen = input.int(8, "Fast EMA length", minval=1)
slowLen = input.int(21, "Slow EMA length", minval=1)
rsiLen = input.int(7, "RSI length", minval=1)
rsiConfirm= input.int(50, "RSI confirmation level")
adxLen = input.int(10, "ADX length", minval=1)
adxThresh = input.int(15, "ADX threshold (min trend strength)")
volSmaLen = input.int(20, "Volume SMA length", minval=1)
volMult = input.float(0.8, "Min volume multiplier", step=0.1, minval=0.1)
atrLen = input.int(10, "ATR length", minval=1)
atrTP = input.float(1.6, "TP = x * ATR", step=0.1, minval=0.1)
useTrailing = input.bool(false, "Use trailing stop")
trailOffsetMult = input.float(0.8, "Trailing offset = x * ATR", step=0.1, minval=0.1)
maxTradesPerDay = input.int(0, "Max trades per day (0 = unlimited)")
useTimeFilter = input.bool(false, "Enable time filter (exchange time)")
startH = input.int(0, "Start hour (0-23)")
startM = input.int(0, "Start minute (0-59)")
endH = input.int(23, "End hour (0-23)")
endM = input.int(59, "End minute (0-59)")
leverage = input.int(25, "Leverage (для расчета ликвидации)", minval=1) // ← по умолчанию 25
// === STRATEGY DECLARATION ===
strategy("Scalp EMA+RSI+ADX+Vol v7 (универсальная, x25)", overlay=true,
default_qty_type=strategy.percent_of_equity, default_qty_value=2.0,
initial_capital=10000, pyramiding=1)
// === ИНДИКАТОРЫ ===
fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)
rsi = ta.rsi(close, rsiLen)
volSMA = ta.sma(volume, volSmaLen)
atr = ta.atr(atrLen)
plot(fastEMA, title="Fast EMA", linewidth=1, color=color.teal)
plot(slowEMA, title="Slow EMA", linewidth=1, color=color.orange)
// === ADX (ручной расчет) ===
upMove = high - high
downMove = low - low
plusDM = (upMove > downMove and upMove > 0) ? upMove : 0.0
minusDM = (downMove > upMove and downMove > 0) ? downMove : 0.0
tr = math.max(high - low, math.max(math.abs(high - close ), math.abs(low - close )))
atr_adx = ta.rma(tr, adxLen)
smPlus = ta.rma(plusDM, adxLen)
smMinus = ta.rma(minusDM, adxLen)
plusDI = atr_adx == 0 ? 0.0 : 100.0 * smPlus / atr_adx
minusDI = atr_adx == 0 ? 0.0 : 100.0 * smMinus / atr_adx
sumDI = plusDI + minusDI
dx = sumDI == 0 ? 0.0 : 100.0 * math.abs(plusDI - minusDI) / sumDI
adx = ta.rma(dx, adxLen)
// === СИГНАЛЫ ===
crossUp = ta.crossover(fastEMA, slowEMA)
crossDown = ta.crossunder(fastEMA, slowEMA)
volOK = volume > volSMA * volMult
rsiOK_long = rsi > rsiConfirm
rsiOK_short = rsi < rsiConfirm
adxOK = adx >= adxThresh
candleBull= close > open
candleBear= close < open
longSignal = crossUp and rsiOK_long and adxOK and volOK and candleBull
shortSignal = crossDown and rsiOK_short and adxOK and volOK and candleBear
// === TIME FILTER ===
s = useTimeFilter ? timestamp(year(time), month(time), dayofmonth(time), startH, startM) : na
e = useTimeFilter ? timestamp(year(time), month(time), dayofmonth(time), endH, endM) : na
inTradeHours = not useTimeFilter ? true : (e > s ? (time >= s and time <= e) : (time >= s or time <= e))
// === DAILY COUNTER ===
var int tradesToday = 0
var int lastDay = na
if dayofmonth(time) != lastDay
tradesToday := 0
lastDay := dayofmonth(time)
canOpenMore = (maxTradesPerDay == 0) or (tradesToday < maxTradesPerDay)
// === ENTRIES / EXITS ===
if longSignal and inTradeHours and canOpenMore and strategy.position_size == 0
entryPrice = close
liqPrice = entryPrice - entryPrice / leverage // стоп по ликвидации x25
takePrice = entryPrice + atr * atrTP
if useTrailing
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", from_entry="Long", limit=takePrice, trail_offset=atr * trailOffsetMult)
else
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", from_entry="Long", stop=liqPrice, limit=takePrice)
tradesToday += 1
if shortSignal and inTradeHours and canOpenMore and strategy.position_size == 0
entryPrice = close
liqPrice = entryPrice + entryPrice / leverage // стоп по ликвидации x25
takePrice = entryPrice - atr * atrTP
if useTrailing
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", from_entry="Short", limit=takePrice, trail_offset=atr * trailOffsetMult)
else
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", from_entry="Short", stop=liqPrice, limit=takePrice)
tradesToday += 1
// === ВИЗУАЛИЗАЦИЯ ===
plotshape(longSignal, title="Long Signal", location=location.belowbar, style=shape.triangleup, size=size.small, color=color.green, text="LONG")
plotshape(shortSignal, title="Short Signal", location=location.abovebar, style=shape.triangledown, size=size.small, color=color.red, text="SHORT")
// INFO BOX
var label info = na
if barstate.islast
label.delete(info)
infoText = "EMA: " + str.tostring(fastLen) + "/" + str.tostring(slowLen) +
" | RSI: " + str.tostring(rsiLen) + " (conf=" + str.tostring(rsiConfirm) + ")" +
" | ADX: " + str.tostring(adxLen) + "(thr=" + str.tostring(adxThresh) + ")" +
" | VolMult=" + str.tostring(volMult) +
" | ATR TP=" + str.tostring(atrTP) +
" | Leverage=" + str.tostring(leverage) + "x" +
" | TradesToday=" + str.tostring(tradesToday)
info := label.new(bar_index, high, infoText, xloc=xloc.bar_index, yloc=yloc.abovebar,
style=label.style_label_left, size=size.small, color=color.new(color.blue, 70))
Session Highlighter (Asia/London/NY)Session Highlighter (Asia/London/NY)
This custom TradingView indicator visually highlights the three major trading sessions — Asia, London, and New York — directly on your chart.
Asia Session (8 PM – 4 AM NY Time) is shaded light red
London Session (3 AM – 11 AM NY Time) is shaded light green
New York Session (8 AM – 5 PM NY Time) is shaded light brown
This makes it easy to quickly see which session you’re in, identify overlaps (such as London–New York), and analyze session-based price behavior.
You can customize the colors in the settings panel to match your chart theme.
oi + funding oscillator cryptosmartThe oi + funding oscillator cryptosmart is an advanced momentum tool designed to gauge sentiment in the crypto derivatives market. It combines Open Interest (OI) changes with Funding Rates, normalizes them into a single oscillator using a z-score, and identifies potential market extremes.
This provides traders with a powerful visual guide to spot when the market is over-leveraged (overheated) or when a significant deleveraging event has occurred (oversold), signaling potential reversals.
How It Works
Combined Data: The indicator tracks the rate of change in Open Interest and the value of Funding Rates.
Oscillator: It blends these two data points into a single, smoothed oscillator line that moves above and below a zero line.
Extreme Zones:
Overheated (Red Zone): When the oscillator enters the upper critical zone, it suggests excessive greed and high leverage, increasing the risk of a sharp correction (long squeeze). A cross below this level generates a potential sell signal.
Oversold (Green Zone): When the oscillator enters the lower critical zone, it indicates panic, liquidations, and a potential market bottom. A cross above this level generates a potential buy signal.
Trading Strategy & Timeframes
This oscillator is designed to be versatile, but its effectiveness can vary depending on the timeframe.
Optimal Timeframes (1H and 4H): The indicator has shown its highest effectiveness on the 1-hour and 4-hour charts. These timeframes are ideal for capturing significant shifts in market sentiment reflected in OI and funding data, filtering out short-term noise while still providing timely reversal signals.
Lower Timeframes (e.g., 1-min, 5-min, 15-min): On shorter timeframes, the oscillator is still a highly effective tool, but it is best used as a confluence factor within a broader trading system. Due to the increased noise on these charts, it is not recommended to use its signals in isolation. Instead, use it as a final argument for entry. For example, if your primary scalping strategy gives you a buy signal, you can check if the oscillator is also exiting the oversold (green) zone to add a powerful layer of confirmation to your trade.
MultiScalpMACDThis indicator, the "Custom MACD MTF," is an adaptive version of the classic Moving Average Convergence Divergence (MACD) that automatically adjusts its parameters based on the chart's timeframe. It is designed to provide more fine-tuned momentum readings for traders who focus on specific intraday timeframes.
Overview
The "Custom MACD MTF" modifies the standard MACD calculation by applying unique settings for the 5-minute, 15-minute, and 1-hour charts. For all other timeframes, it reverts to the user-defined default values. This dynamic adjustment allows the indicator to better reflect the momentum characteristics of different trading sessions without requiring manual changes from the user.
Key Features
Adaptive Parameters: The indicator automatically uses optimized MACD settings for popular timeframes:
5-minute: Fast Length = 3, Slow Length = 10, Signal Length = 16
15-minute: Fast Length = 8, Slow Length = 17, Signal Length = 9
1-hour: Fast Length = 12, Slow Length = 26, Signal Length = 9
Momentum-Based Histogram: The histogram bars are colored to provide a clear visual cue about changes in momentum. A light gray bar indicates that momentum is increasing (the current bar is higher than the previous one), while a dark gray bar indicates that momentum is decreasing.
Clear Visual Plots: The indicator plots a pink MACD line, a black signal line, and a gray zero line for easy interpretation of crossovers and trend direction.
How to Interpret
This indicator can be used in the same way as a traditional MACD, but with added sensitivity on the specified timeframes. Traders can look for MACD and signal line crossovers, zero-line crosses, and divergences to identify potential trade signals. The histogram's color change provides an early warning that momentum is either accelerating or decelerating, which can precede a change in price direction.
Settings
Fast Length (Default): The default fast EMA period used for all timeframes except 5m, 15m, and 1h.
Slow Length (Default): The default slow EMA period used for all timeframes except 5m, 15m, and 1h.
Signal Length (Default): The default signal line EMA period used for all timeframes except 5m, 15m, and 1h.
Source: The price source for the MACD calculation (default is Close).
Indicador de Confluência - M. LolasIndicador com finalidade específica em um projeto específico. By M. Lolas.
Heikin Ashi Overlay SuiteHeikin Ashi Overlay Suite is designed to give traders more control and clarity when working with Heikin Ashi candles — whether you're analyzing trend strength, reducing chart noise, or simply improving your visual read of market momentum. It works by layering multiple types of HA overlays and color systems on top of your standard candlestick chart — without switching chart types. With dynamic gradient coloring, smoothing options, and a predictive line tool, this script helps you see not just what the current trend is, but how strong it is, and what it would take to reverse it.
Heikin Ashi candles help reduce noise but this script goes further by:
➡️adding color intelligence that shows trend strength using a streak counter
➡️uses smoothing logic to clean up chop and whipsaws
➡️introduces a predictive close line — a subtle but powerful guide for anticipating trend flips before they happen
Everything is configurable: colors, candle sources, overlays, predictive tools, and line styles. It’s built for traders who want visual speed, but don’t want to sacrifice signal quality.
At its core, the script offers two powerful dropdown controls:
💥HA Color Scheme (Colors Regular Candles) — Applies Heikin Ashi-derived coloring to your regular candles based on trend direction or streak strength. This gives you instant visual context without switching to a separate chart type.
💥HA Candle Overlay Mode — Overlays actual Heikin Ashi-style candles directly on top of your chart, using your preferred source:
➡️Custom HA candles using internal formula logic
➡️TradingView’s built-in Heikin Ashi source with your own colors
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
🎨 Custom + Gradient HA Coloring🎨
See trend strength at a glance:
➡️1–4 bar streaks → lighter tone
➡️5–8 bars → medium tone
➡️9+ bars → bold tone, ideal for momentum-based entries, exits, or scaling strategies
→ Choose from:
➡️Your own custom color set
➡️A simple 2-color base mode
➡️Or a 3-level gradient for progressive trend analysis (using the streak counter)
🏛️ TradingView Official Heikin Ashi Overlay
Prefer native HA candles but want your own colors?
This mode plots TradingView's Heikin Ashi source, with your personal bullish/bearish color scheme.
➡️Ensures consistency with built-in charts while still leveraging your visual style.
🌊 Smoothed Heikin Ashi Candles — Clarity in Chaos🌊
These aren’t your standard HA candles. Smoothed Heikin Ashi uses a two-step EMA process to transform chaotic price action into a cleaner, slower-moving trend structure:
🔹 First, it smooths the raw OHLC data using EMA — filtering out minor price fluctuations.
🔹 Then, it applies the Heikin Ashi transformation on top of the smoothed data.
🔹 Finally, it applies a second EMA smoothing pass to the HA values — creating ultra-smooth candles.
📈 What You See:
Trends appear more fluid and consistent.
Choppy ranges and fakeouts are visually suppressed.
Minor pullbacks within a trend are de-emphasized, helping you avoid premature exits.
🎯 Best For:
Swing traders looking to stay in positions longer.
Intraday traders dealing with volatile or noisy instruments.
Anyone who wants a "trend map" overlay without the distractions of raw price action.
✅ Reduces whipsaws
✅ Delivers high-contrast trend zones
✅ Makes reversals more visually apparent (but with a slight lag)
📍 Predictive Close Line📍
Shows where the real close must land to flip the current HA candle's color.
✅ Use it like predictive support/resistance
✅ Know if the trend is actually at risk
✅Visualize potential fakeouts or confirmation
Color-coded based on current HA direction (bullish, bearish, or neutral).
📈 Tick by tick & bar-to-bar Plots📈
Provides 2 plot types:
1)1 plot that tracks a bar tick by tick
2)another plot that tracks the close from bar to bar
For the bar to bar plot, you can choose between 2 options:
✅Full Plot — continuous line colored by HA trend
✅Recent Segments — color just the last few bars (configurable) to reduce chart clutter
✅ Customize width, number of bars, and visibility
➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖
📘 How to Use this script📘
Imagine you're watching a choppy 15-minute chart on a volatile crypto pair — price action is messy, and it’s hard to tell if a trend is forming or just noise.
Here’s how to cut through the chaos using Heikin Ashi Overlay Suite:
🔹 Step 1: Enable "Smoothed HA Candles"
Start by turning on the smoothed candles. You’ll immediately notice the noise fades, and broader directional moves become easier to follow. It's like switching from static to clean trend zones.
🧠 Why: Smoothed HA uses a double EMA process that filters out small reversals and lets larger moves stand out. Perfect for sideways or jittery charts.
🔹 Step 2: Watch the Color Gradient Build
As the smoothed candles begin to align in one direction, the gradient coloring (1–4, 5–8, 9+ streaks) gives you an at-a-glance visual of how strong the trend is.
✅ If you see 9+ same-colored candles? You’re likely in a mature trend.
✅ If it resets often? You’re in chop — consider staying out.
🔹 Step 3: Use the Predictive Close Line for Anticipation
Now here’s the edge — this line tells you where the candle would have to close to flip colors.
📉 If price is hovering just above it during a bullish run — momentum may be weakening.
📈 If price bounces off it — the trend may be strengthening.
This is excellent for confirming entries, exits, or spotting early warning signs.
🔹 Step 4: Switch Between Candle Modes as Needed
You can flip between:
✅ Custom HA: Gradient candles with your colors
✅ TradingView HA: The official source with your styling
✅ None: Just color regular candles using the HA logic
Use what fits your style — everything is modular.
🔹 Step 5: Tune It to Your Chart
Lastly, tweak streak thresholds (currently only can do this within the source code), smoothing lengths, and line styles to match your timeframe and strategy.
🎯 Tailor The Settings to Fit Your Trading Style🎯
🔹 🧪 Scalper (1–5 min charts)
If you’re trading fast intraday moves, you want quicker responsiveness and less lag.
Try these settings:
🔸Smoothing Lengths: Use lower values (e.g. len = 3, len2 = 5)
🔸Candle Mode: Use Custom HA or TV’s HA for real-time color flips
🔸Predictive Close Line: Great for ultra-fast anticipation of color reversals
🔸Line Mode: Use Recent Segments mode to track short bursts of trend
🔸Colors: Use high-contrast, opaque colors for clarity
✅ These settings help you catch micro-trends and flip signals faster, while still filtering out the worst of the noise.
🔹 🧪 Swing Trader (30m–4h charts and beyond)
If you’re looking for multi-hour or multi-day trend confirmation, prioritize clarity and staying in moves longer.
Recommended setup:
🔸Smoothing Lengths: Medium to high values (e.g. len = 8, len2 = 21)
🔸Candle Mode: Use Smoothed HA Candles to block out intrabar chop
🔸Gradient Colors: Enable to visualize trend maturity and strength
🔸Predictive Close Line: Helps confirm trend continuation or spot early reversals
🔸Line Mode: Use Full Plot Line for clean HA-based trend tracking
✅ These settings give you a calm, clean view of the bigger picture — ideal for holding positions longer and avoiding early exits.
🔧 This script isn’t just a chart overlay — it’s a visual trend engine.🔧
Ideal For:
🔶 Trend-followers who want clean, color-coded confirmation
🔶 Reversal traders spotting exhaustion via predictive flips
🔶 Scalpers filtering noise with lighter smoothing
🔶 Swing traders using smoothed visuals to hold longer
📌 Final Note
Heikin Ashi Overlay Pro is designed to help you see momentum, trend shifts, and market structure with greater clarity — not to predict price on its own. For best results:
✔️ Combine with support/resistance, moving averages, or price action patterns
✔️ Use Predictive Close as a confirmation tool, not a signal generator
✔️ Pair gradient colors with structure to gauge trend maturity
✔️ Always zoom out and check higher timeframes for context
🧠 Use this as part of a layered approach — not a standalone system.
🙏 Credits🙏
⚡HA logic based on SimpleCryptoLife
⚡Smoothed HA concept adapted from a script by Jackvmk
💡💡💡Turn logic into clarity. Structure into trades. And uncertainty into confidence.💡💡💡
ema_stoplossLibrary "ema_stoploss"
What it does
A small library that builds stop-loss levels from dynamically computed EMAs. It finds EMAs strictly on the desired side of price (long: below; short: above), sorts them by distance to price, and returns the n-th nearest as your stop.
How it works
sortEMAsByDistanceStrictDyn(signal, lensArr, src, ascending)
Computes each EMA internally with the alpha formula (alpha = 2/(len+1)), so you can pass a dynamic array of lengths.
Strict side filter:
signal = 1 → only EMAs < src (below)
signal = -1 → only EMAs > src (above)
Sorts candidates by distance to src (default: nearest → farthest) and returns two arrays: EMA values and their lengths.
get_stop_loss(index) (exported)
Builds a default length array: 21, 50, 100, 200, 250, 500, 750, 1000.
Long side uses low to find the index-th nearest lower EMA.
Short side uses high to find the index-th nearest upper EMA.
Returns .
Plots
Stop-Loss Long (green): the selected lower EMA (based on low).
Stop-Loss Short (red): the selected upper EMA (based on high).
Input
Index (default 2): 0-based.
0 = nearest, 1 = second nearest, 2 = third, etc.
If there aren’t enough EMAs on the required side, the function returns na (no plot).
Why internal EMA calc?
ta.ema() doesn’t accept a series length; by updating each EMA with its alpha step every bar, the library supports arbitrary dynamic length arrays and stays bar-consistent.
Customize
Edit the list in get_stop_loss() to use your own EMA lengths.
Change ascending in sortEMAsByDistanceStrictDyn if you prefer farthest → nearest.
Use a different src if needed (e.g., close, hlc3, etc.).
The example intentionally uses low for long stops and high for short stops.
Notes
Strict side filtering: EMAs on the wrong side are ignored (no fallback).
If no EMA qualifies on a side, you’ll get na for that side.
Complexity is O(n²) for sorting, which is negligible for small EMA lists.
Otekura Range Trade Algorithm [Tradebuddies]The Range Trade Algorithm calculates the levels for Monday.
On the chart you will see that the Monday levels will be marked as 1 0 -1.
The M High level calculates Monday's high close and plots it on the screen.
M Low calculates the low close of Monday and plots it on the screen.
The coloured lines on the screen are the points of the range levels formulated with fibonacci values.
The indicator has its own Value table. The prices of the levels are written.
Potential Range breakout targets tell prices at points matching the fibonacci values. These are Take profit or reversal points.
Buy and Sell indicators are determined by the range breakout.
Users can set an alarm on the indicator and receive direct notification with their targets when a new range occurs.
Fib values are multiplied by range values and create an average target according to the price situation. These values represent an area. Breakdown targets show that the target is targeted until the area.
Market Structure - BOS LinesMarket Structure - BOS Lines individuazione delle 3cf e segnalazione con il bos
SMT Divergences Dual Lookback - MoonTradesThis Pine Script, titled "SMT Divergences Dual Lookback", is designed to detect and visualize divergences between two comparison symbols (symbols A and B) using two different lookback periods. The script specifically identifies bullish and bearish divergences based on pivot highs and lows and marks them on the chart with color-coded labels.
Bullish Divergence (Swing High) is marked when a price swing low diverges from a pivot low, indicating potential upward momentum.
Bearish Divergence (Swing Low) is marked when a price swing high diverges from a pivot high, indicating potential downward momentum.
The script works with two customizable comparison symbols and can also apply a specific timeframe for divergence detection (separate from the chart’s default timeframe). The results are displayed with labels showing the corresponding symbols, helping traders identify potential reversal points or continuation trends.
Users can customize the lookback periods and the colors for the divergence markers. This tool aids in technical analysis for traders who focus on multi-timeframe and multi-symbol divergence strategies.
Candle Sweep Alert - MoonThis Pine Script is designed to detect Bearish Sweep and Bullish Sweep patterns on a TradingView chart and trigger alerts and notifications.
Bearish Sweep occurs when the current candle’s high is higher than the previous high, the close is lower than the open (bearish), and the current low is either lower or higher than the previous low.
Bullish Sweep occurs when the current candle’s low is lower than the previous low, the close is higher than the open (bullish), and the current high is either lower or higher than the previous high.
Alerts and notifications will be triggered when these conditions are met, helping traders monitor market movements automatically.
Price Action Concepts [RUDYINDICATOR]/// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) creativecommons.org
// © RUDYBANK INDICATOR - formerly know as RUDY INDICATOR
//@version=5
indicator("Price Action Concepts ", shorttitle = "RUDYINDICATOR-V1
- Price Action RUDYINDICATOR ", overlay = true, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500, max_bars_back = 500, max_polylines_count = 100)
//-----------------------------------------------------------------------------{
//Boolean set
//-----------------------------------------------------------------------------{
s_BOS = 0
s_CHoCH = 1
i_BOS = 2
i_CHoCH = 3
i_pp_CHoCH = 4
green_candle = 5
red_candle = 6
s_CHoCHP = 7
i_CHoCHP = 8
boolean =
array.from(
false
, false
, false
, false
, false
, false
, false
, false
, false
)
//-----------------------------------------------------------------------------{
// User inputs
//-----------------------------------------------------------------------------{
show_swing_ms = input.string ("All" , "Swing " , inline = "1", group = "MARKET STRUCTURE" , options = )
show_internal_ms = input.string ("All" , "Internal " , inline = "2", group = "MARKET STRUCTURE" , options = )
internal_r_lookback = input.int (5 , "" , inline = "2", group = "MARKET STRUCTURE" , minval = 2)
swing_r_lookback = input.int (50 , "" , inline = "1", group = "MARKET STRUCTURE" , minval = 2)
ms_mode = input.string ("Manual" , "Market Structure Mode" , inline = "a", group = "MARKET STRUCTURE" , tooltip = " Use selected lenght Use automatic lenght" ,options = )
show_mtf_str = input.bool (true , "MTF Scanner" , inline = "9", group = "MARKET STRUCTURE" , tooltip = "Display Multi-Timeframe Market Structure Trend Directions. Green = Bullish. Red = Bearish")
show_eql = input.bool (false , "Show EQH/EQL" , inline = "6", group = "MARKET STRUCTURE")
plotcandle_bool = input.bool (false , "Plotcandle" , inline = "3", group = "MARKET STRUCTURE" , tooltip = "Displays a cleaner colored candlestick chart in place of the default candles. (requires hiding the current ticker candles)")
barcolor_bool = input.bool (false , "Bar Color" , inline = "4", group = "MARKET STRUCTURE" , tooltip = "Color the candle bodies according to market strucutre trend")
i_ms_up_BOS = input.color (#089981 , "" , inline = "2", group = "MARKET STRUCTURE")
i_ms_dn_BOS = input.color (#f23645 , "" , inline = "2", group = "MARKET STRUCTURE")
s_ms_up_BOS = input.color (#089981 , "" , inline = "1", group = "MARKET STRUCTURE")
s_ms_dn_BOS = input.color (#f23645 , "" , inline = "1", group = "MARKET STRUCTURE")
lvl_daily = input.bool (false , "Day " , inline = "1", group = "HIGHS & LOWS MTF")
lvl_weekly = input.bool (false , "Week " , inline = "2", group = "HIGHS & LOWS MTF")
lvl_monthly = input.bool (false , "Month" , inline = "3", group = "HIGHS & LOWS MTF")
lvl_yearly = input.bool (false , "Year " , inline = "4", group = "HIGHS & LOWS MTF")
css_d = input.color (color.blue , "" , inline = "1", group = "HIGHS & LOWS MTF")
css_w = input.color (color.blue , "" , inline = "2", group = "HIGHS & LOWS MTF")
css_m = input.color (color.blue , "" , inline = "3", group = "HIGHS & LOWS MTF")
css_y = input.color (color.blue , "" , inline = "4", group = "HIGHS & LOWS MTF")
s_d = input.string ('⎯⎯⎯' , '' , inline = '1', group = 'HIGHS & LOWS MTF' , options = )
s_w = input.string ('⎯⎯⎯' , '' , inline = '2', group = 'HIGHS & LOWS MTF' , options = )
s_m = input.string ('⎯⎯⎯' , '' , inline = '3', group = 'HIGHS & LOWS MTF' , options = )
s_y = input.string ('⎯⎯⎯' , '' , inline = '4', group = 'HIGHS & LOWS MTF' , options = )
ob_show = input.bool (true , "Show Last " , inline = "1", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Display volumetric order blocks on the chart Ammount of volumetric order blocks to show")
ob_num = input.int (5 , "" , inline = "1", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Orderblocks number", minval = 1, maxval = 10)
ob_metrics_show = input.bool (true , "Internal Buy/Sell Activity" , inline = "2", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Display volume metrics that have formed the orderblock")
css_metric_up = input.color (color.new(#089981, 50) , " " , inline = "2", group = "VOLUMETRIC ORDER BLOCKS")
css_metric_dn = input.color (color.new(#f23645 , 50) , "" , inline = "2", group = "VOLUMETRIC ORDER BLOCKS")
ob_swings = input.bool (false , "Swing Order Blocks" , inline = "a", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Display swing volumetric order blocks")
css_swing_up = input.color (color.new(color.gray , 90) , " " , inline = "a", group = "VOLUMETRIC ORDER BLOCKS")
css_swing_dn = input.color (color.new(color.silver, 90) , "" , inline = "a", group = "VOLUMETRIC ORDER BLOCKS")
ob_filter = input.string ("None" , "Filtering " , inline = "d", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Filter out volumetric order blocks by BOS/CHoCH/CHoCH+", options = )
ob_mitigation = input.string ("Absolute" , "Mitigation " , inline = "4", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Trigger to remove volumetric order blocks", options = )
ob_pos = input.string ("Precise" , "Positioning " , inline = "k", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Position of the Order Block Cover the whole candle Cover half candle Adjust to volatility Same as Accurate but more precise", options = )
use_grayscale = input.bool (false , "Grayscale" , inline = "6", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Use gray as basic order blocks color")
use_show_metric = input.bool (true , "Show Metrics" , inline = "7", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Show volume associated with the orderblock and his relevance")
use_middle_line = input.bool (true , "Show Middle-Line" , inline = "8", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Show mid-line order blocks")
use_overlap = input.bool (true , "Hide Overlap" , inline = "9", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = "Hide overlapping order blocks")
use_overlap_method = input.string ("Previous" , "Overlap Method " , inline = "Z", group = "VOLUMETRIC ORDER BLOCKS" , tooltip = " Preserve the most recent volumetric order blocks Preserve the previous volumetric order blocks", options = )
ob_bull_css = input.color (color.new(#089981 , 90) , "" , inline = "1", group = "VOLUMETRIC ORDER BLOCKS")
ob_bear_css = input.color (color.new(#f23645 , 90) , "" , inline = "1", group = "VOLUMETRIC ORDER BLOCKS")
show_acc_dist_zone = input.bool (false , "" , inline = "1", group = "Accumulation And Distribution")
zone_mode = input.string ("Fast" , "" , inline = "1", group = "Accumulation And Distribution" , tooltip = " Find small zone pattern formation Find bigger zone pattern formation" ,options = )
acc_css = input.color (color.new(#089981 , 60) , "" , inline = "1", group = "Accumulation And Distribution")
dist_css = input.color (color.new(#f23645 , 60) , "" , inline = "1", group = "Accumulation And Distribution")
show_lbl = input.bool (false , "Show swing point" , inline = "1", group = "High and Low" , tooltip = "Display swing point")
show_mtb = input.bool (false , "Show High/Low/Equilibrium" , inline = "2", group = "High and Low" , tooltip = "Display Strong/Weak High And Low and Equilibrium")
toplvl = input.color (color.red , "Premium Zone " , inline = "3", group = "High and Low")
midlvl = input.color (color.gray , "Equilibrium Zone" , inline = "4", group = "High and Low")
btmlvl = input.color (#089981 , "Discount Zone " , inline = "5", group = "High and Low")
fvg_enable = input.bool (false , " " , inline = "1", group = "FAIR VALUE GAP" , tooltip = "Display fair value gap")
what_fvg = input.string ("FVG" , "" , inline = "1", group = "FAIR VALUE GAP" , tooltip = "Display fair value gap", options = )
fvg_num = input.int (5 , "Show Last " , inline = "1a", group = "FAIR VALUE GAP" , tooltip = "Number of fvg to show")
fvg_upcss = input.color (color.new(#089981, 80) , "" , inline = "1", group = "FAIR VALUE GAP")
fvg_dncss = input.color (color.new(color.red , 80) , "" , inline = "1", group = "FAIR VALUE GAP")
fvg_extend = input.int (10 , "Extend FVG" , inline = "2", group = "FAIR VALUE GAP" , tooltip = "Extend the display of the FVG.")
fvg_src = input.string ("Close" , "Mitigation " , inline = "3", group = "FAIR VALUE GAP" , tooltip = " Use the close of the body as trigger Use the extreme point of the body as trigger", options = )
fvg_tf = input.timeframe ("" , "Timeframe " , inline = "4", group = "FAIR VALUE GAP" , tooltip = "Timeframe of the fair value gap")
t = color.t (ob_bull_css)
invcol = color.new (color.white , 100)
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - UDT }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
type bar
float o = open
float c = close
float h = high
float l = low
float v = volume
int n = bar_index
int t = time
type Zphl
line top
line bottom
label top_label
label bottom_label
bool stopcross
bool sbottomcross
bool itopcross
bool ibottomcross
string txtup
string txtdn
float topy
float bottomy
float topx
float bottomx
float tup
float tdn
int tupx
int tdnx
float itopy
float itopx
float ibottomy
float ibottomx
float uV
float dV
type FVG
box box
line ln
bool bull
float top
float btm
int left
int right
type ms
float p
int n
float l
type msDraw
int n
float p
color css
string txt
bool bull
type obC
float top
float btm
int left
float avg
float dV
float cV
int wM
int blVP
int brVP
int dir
float h
float l
int n
type obD
box ob
box eOB
box blB
box brB
line mL
type zone
chart.point points
float p
int c
int t
type hqlzone
box pbx
box ebx
box lbx
label plb
label elb
label lbl
type ehl
float pt
int t
float pb
int b
type pattern
string found = "None"
bool isfound = false
int period = 0
bool bull = false
type alerts
bool chochswing = false
bool chochplusswing = false
bool swingbos = false
bool chochplus = false
bool choch = false
bool bos = false
bool equal = false
bool ob = false
bool swingob = false
bool zone = false
bool fvg = false
bool obtouch = false
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - End }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - General Setup }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
bar b = bar.new()
var pattern p = pattern.new()
alerts blalert = alerts.new()
alerts bralert = alerts.new()
if p.isfound
p.period += 1
if p.period == 50
p.period := 0
p.found := "None"
p.isfound := false
p.bull := na
switch
b.c > b.o => boolean.set(green_candle, true)
b.c < b.o => boolean.set(red_candle , true)
f_zscore(src, lookback) =>
(src - ta.sma(src, lookback)) / ta.stdev(src, lookback)
var int iLen = internal_r_lookback
var int sLen = swing_r_lookback
vv = f_zscore(((close - close ) / close ) * 100,iLen)
if ms_mode == "Dynamic"
switch
vv >= 1.5 or vv <= -1.5 => iLen := 10
vv >= 1.6 or vv <= -1.6 => iLen := 9
vv >= 1.7 or vv <= -1.7 => iLen := 8
vv >= 1.8 or vv <= -1.8 => iLen := 7
vv >= 1.9 or vv <= -1.9 => iLen := 6
vv >= 2.0 or vv <= -2.0 => iLen := 5
=> iLen
var msline = array.new(0)
iH = ta.pivothigh(high, iLen, iLen)
sH = ta.pivothigh(high, sLen, sLen)
iL = ta.pivotlow (low , iLen, iLen)
sL = ta.pivotlow (low , sLen, sLen)
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - End }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - ARRAYS }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
hl () =>
= request.security(syminfo.tickerid , 'D' , hl() , lookahead = barmerge.lookahead_on)
= request.security(syminfo.tickerid , 'W' , hl() , lookahead = barmerge.lookahead_on)
= request.security(syminfo.tickerid , 'M' , hl() , lookahead = barmerge.lookahead_on)
= request.security(syminfo.tickerid , '12M', hl() , lookahead = barmerge.lookahead_on)
lstyle(style) =>
out = switch style
'⎯⎯⎯' => line.style_solid
'----' => line.style_dashed
'····' => line.style_dotted
mtfphl(h, l ,tf ,css, pdhl_style) =>
var line hl = line.new(
na
, na
, na
, na
, xloc = xloc.bar_time
, color = css
, style = lstyle(pdhl_style)
)
var line ll = line.new(
na
, na
, na
, na
, xloc = xloc.bar_time
, color = css
, style = lstyle(pdhl_style)
)
var label lbl = label.new(
na
, na
, xloc = xloc.bar_time
, text = str.format('P{0}L', tf)
, color = invcol
, textcolor = css
, size = size.small
, style = label.style_label_left
)
var label hlb = label.new(
na
, na
, xloc = xloc.bar_time
, text = str.format('P{0}H', tf)
, color = invcol
, textcolor = css
, size = size.small
, style = label.style_label_left
)
hy = ta.valuewhen(h != h , h , 1)
hx = ta.valuewhen(h == high , time , 1)
ly = ta.valuewhen(l != l , l , 1)
lx = ta.valuewhen(l == low , time , 1)
if barstate.islast
extension = time + (time - time ) * 50
line.set_xy1(hl , hx , hy)
line.set_xy2(hl , extension , hy)
label.set_xy(hlb, extension , hy)
line.set_xy1(ll , lx , ly)
line.set_xy2(ll , extension , ly)
label.set_xy(lbl, extension , ly)
if lvl_daily
mtfphl(pdh , pdl , 'D' , css_d, s_d)
if lvl_weekly
mtfphl(pwh , pwl , 'W' , css_w, s_w)
if lvl_monthly
mtfphl(pmh , pml, 'M' , css_m, s_m)
if lvl_yearly
mtfphl(pyh , pyl , '12M', css_y, s_y)
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - End }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - Market Structure }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
method darkcss(color css, float factor, bool bull) =>
blue = color.b(css) * (1 - factor)
red = color.r(css) * (1 - factor)
green = color.g(css) * (1 - factor)
color.rgb(red, green, blue, 0)
method f_line(msDraw d, size, style) =>
var line id = na
var label lbl = na
id := line.new(
d.n
, d.p
, b.n
, d.p
, color = d.css
, width = 1
, style = style
)
if msline.size() >= 250
line.delete(msline.shift())
msline.push(id)
lbl := label.new(
int(math.avg(d.n, b.n))
, d.p
, d.txt
, color = invcol
, textcolor = d.css
, style = d.bull ? label.style_label_down : label.style_label_up
, size = size
, text_font_family = font.family_monospace
)
structure(bool mtf) =>
msDraw drw = na
bool isdrw = false
bool isdrwS = false
var color css = na
var color icss = na
var int itrend = 0
var int trend = 0
bool bull_ob = false
bool bear_ob = false
bool s_bull_ob = false
bool s_bear_ob = false
n = bar_index
var ms up = ms.new(
array.new()
, array.new< int >()
, array.new()
)
var ms dn = ms.new(
array.new()
, array.new< int >()
, array.new()
)
var ms sup = ms.new(
array.new()
, array.new< int >()
, array.new()
)
var ms sdn = ms.new(
array.new()
, array.new< int >()
, array.new()
)
switch show_swing_ms
"All" => boolean.set(s_BOS , true ), boolean.set(s_CHoCH, true ) , boolean.set(s_CHoCHP, true )
"CHoCH" => boolean.set(s_BOS , false), boolean.set(s_CHoCH, true ) , boolean.set(s_CHoCHP, false )
"CHoCH+" => boolean.set(s_BOS , false), boolean.set(s_CHoCH, false) , boolean.set(s_CHoCHP, true )
"BOS" => boolean.set(s_BOS , true ), boolean.set(s_CHoCH, false) , boolean.set(s_CHoCHP, false )
"None" => boolean.set(s_BOS , false), boolean.set(s_CHoCH, false) , boolean.set(s_CHoCHP, false )
=> na
switch show_internal_ms
"All" => boolean.set(i_BOS, true ), boolean.set(i_CHoCH, true ), boolean.set(i_CHoCHP, true )
"CHoCH" => boolean.set(i_BOS, false), boolean.set(i_CHoCH, true ), boolean.set(i_CHoCHP, false)
"CHoCH+" => boolean.set(i_BOS, false), boolean.set(i_CHoCH, false ), boolean.set(i_CHoCHP, true )
"BOS" => boolean.set(i_BOS, true ), boolean.set(i_CHoCH, false ), boolean.set(i_CHoCHP, false)
"None" => boolean.set(i_BOS, false), boolean.set(i_CHoCH, false ), boolean.set(i_CHoCHP, false)
=> na
switch
iH =>
up.p.unshift(b.h )
up.l.unshift(b.h )
up.n.unshift(n )
iL =>
dn.p.unshift(b.l )
dn.l.unshift(b.l )
dn.n.unshift(n )
sL =>
sdn.p.unshift(b.l )
sdn.l.unshift(b.l )
sdn.n.unshift(n )
sH =>
sup.p.unshift(b.h )
sup.l.unshift(b.h )
sup.n.unshift(n )
// INTERNAL BULLISH STRUCTURE
if up.p.size() > 0 and dn.l.size() > 1
if ta.crossover(b.c, up.p.first())
bool CHoCH = na
string txt = na
if itrend < 0
CHoCH := true
switch
not CHoCH =>
txt := "BOS"
css := i_ms_up_BOS
blalert.bos := true
if boolean.get(i_BOS) and mtf == false and na(drw)
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BOS
, txt
, true
)
CHoCH =>
dn.l.first() > dn.l.get(1) ? blalert.chochplus : blalert.choch
txt := dn.l.first() > dn.l.get(1) ? "CHoCH+" : "CHoCH"
css := i_ms_up_BOS.darkcss(0.25, true)
if (dn.l.first() > dn.l.get(1) ? boolean.get(i_CHoCHP) : boolean.get(i_CHoCH)) and mtf == false and na(drw)
isdrw := true
drw := msDraw.new(
up.n.first()
, up.p.first()
, i_ms_up_BOS.darkcss(0.25, true)
, txt
, true
)
if mtf == false
switch
ob_filter == "None" => bull_ob := true
ob_filter == "BOS" and txt == "BOS" => bull_ob := true
ob_filter == "CHoCH" and txt == "CHoCH" => bull_ob := true
ob_filter == "CHoCH+" and txt == "CHoCH+" => bull_ob := true
itrend := 1
up.n.clear()
up.p.clear()
// INTERNAL BEARISH STRUCTURE
if dn.p.size() > 0 and up.l.size() > 1
if ta.crossunder(b.c, dn.p.first())
bool CHoCH = na
string txt = na
if itrend > 0
CHoCH := true
switch
not CHoCH =>
bralert.bos := true
txt := "BOS"
css := i_ms_dn_BOS
if boolean.get(i_BOS) and mtf == false and na(drw)
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BOS
, txt
, false
)
CHoCH =>
if up.l.first() < up.l.get(1)
bralert.chochplus := true
else
bralert.choch := true
txt := up.l.first() < up.l.get(1) ? "CHoCH+" : "CHoCH"
css := i_ms_dn_BOS.darkcss(0.25, false)
if (up.l.first() < up.l.get(1) ? boolean.get(i_CHoCHP) : boolean.get(i_CHoCH)) and mtf == false and na(drw)
isdrw := true
drw := msDraw.new(
dn.n.first()
, dn.p.first()
, i_ms_dn_BOS.darkcss(0.25, false)
, txt
, false
)
if mtf == false
switch
ob_filter == "None" => bear_ob := true
ob_filter == "BOS" and txt == "BOS" => bear_ob := true
ob_filter == "CHoCH" and txt == "CHoCH" => bear_ob := true
ob_filter == "CHoCH+" and txt == "CHoCH+" => bear_ob := true
itrend := -1
dn.n.clear()
dn.p.clear()
// SWING BULLISH STRUCTURE
if sup.p.size() > 0 and sdn.l.size() > 1
if ta.crossover(b.c, sup.p.first())
bool CHoCH = na
string txt = na
if trend < 0
CHoCH := true
switch
not CHoCH =>
blalert.swingbos := true
txt := "BOS"
icss := s_ms_up_BOS
if boolean.get(s_BOS) and mtf == false and na(drw)
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BOS
, txt
, true
)
CHoCH =>
if sdn.l.first() > sdn.l.get(1)
blalert.chochplusswing := true
else
blalert.chochswing := true
txt := sdn.l.first() > sdn.l.get(1) ? "CHoCH+" : "CHoCH"
icss := s_ms_up_BOS.darkcss(0.25, true)
if (sdn.l.first() > sdn.l.get(1) ? boolean.get(s_CHoCHP) : boolean.get(s_CHoCH)) and mtf == false and na(drw)
isdrwS := true
drw := msDraw.new(
sup.n.first()
, sup.p.first()
, s_ms_up_BOS.darkcss(0.25, true)
, txt
, true
)
if mtf == false
switch
ob_filter == "None" => s_bull_ob := true
ob_filter == "BOS" and txt == "BOS" => s_bull_ob := true
ob_filter == "CHoCH" and txt == "CHoCH" => s_bull_ob := true
ob_filter == "CHoCH+" and txt == "CHoCH+" => s_bull_ob := true
trend := 1
sup.n.clear()
sup.p.clear()
// SWING BEARISH STRUCTURE
if sdn.p.size() > 0 and sup.l.size() > 1
if ta.crossunder(b.c, sdn.p.first())
bool CHoCH = na
string txt = na
if trend > 0
CHoCH := true
switch
not CHoCH =>
bralert.swingbos := true
txt := "BOS"
icss := s_ms_dn_BOS
if boolean.get(s_BOS) and mtf == false and na(drw)
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BOS
, txt
, false
)
CHoCH =>
if sup.l.first() < sup.l.get(1)
bralert.chochplusswing := true
else
bralert.chochswing := true
txt := sup.l.first() < sup.l.get(1) ? "CHoCH+" : "CHoCH"
icss := s_ms_dn_BOS.darkcss(0.25, false)
if (sup.l.first() < sup.l.get(1) ? boolean.get(s_CHoCHP) : boolean.get(s_CHoCH)) and mtf == false and na(drw)
isdrwS := true
drw := msDraw.new(
sdn.n.first()
, sdn.p.first()
, s_ms_dn_BOS.darkcss(0.25, false)
, txt
, false
)
if mtf == false
switch
ob_filter == "None" => s_bear_ob := true
ob_filter == "BOS" and txt == "BOS" => s_bear_ob := true
ob_filter == "CHoCH" and txt == "CHoCH" => s_bear_ob := true
ob_filter == "CHoCH+" and txt == "CHoCH+" => s_bear_ob := true
trend := -1
sdn.n.clear()
sdn.p.clear()
= structure(false)
if isdrw
f_line(drw, size.small, line.style_dashed)
if isdrwS
f_line(drw, size.small, line.style_solid)
= request.security("", "15" , structure(true))
= request.security("", "60" , structure(true))
= request.security("", "240" , structure(true))
= request.security("", "1440" , structure(true))
if show_mtf_str
var tab = table.new(position = position.top_right, columns = 10, rows = 10, bgcolor = na, frame_color = color.rgb(54, 58, 69, 0), frame_width = 1, border_color = color.rgb(54, 58, 69, 100), border_width = 1)
table.cell(tab, 0, 1, text = "15" , text_color = color.silver, text_halign = text.align_center, text_size = size.normal, bgcolor = chart.bg_color, text_font_family = font.family_monospace, width = 2)
table.cell(tab, 0, 2, text = "1H" , text_color = color.silver, text_halign = text.align_center, text_size = size.normal, bgcolor = chart.bg_color, text_font_family = font.family_monospace, width = 2)
table.cell(tab, 0, 3, text = "4H" , text_color = color.silver, text_halign = text.align_center, text_size = size.normal, bgcolor = chart.bg_color, text_font_family = font.family_monospace, width = 2)
table.cell(tab, 0, 4, text = "1D" , text_color = color.silver, text_halign = text.align_center, text_size = size.normal, bgcolor = chart.bg_color, text_font_family = font.family_monospace, width = 2)
table.cell(tab, 1, 1, text = itrend15 == 1 ? "BULLISH" : itrend15 == -1 ? "BEARISH" : na , text_halign = text.align_center, text_size = size.normal, text_color = itrend15 == 1 ? i_ms_up_BOS.darkcss(-0.25, true) : itrend15 == -1 ? i_ms_dn_BOS.darkcss(0.25, false) : color.gray, bgcolor = chart.bg_color, text_font_family = font.family_monospace)
table.cell(tab, 1, 2, text = itrend1H == 1 ? "BULLISH" : itrend1H == -1 ? "BEARISH" : na , text_halign = text.align_center, text_size = size.normal, text_color = itrend1H == 1 ? i_ms_up_BOS.darkcss(-0.25, true) : itrend1H == -1 ? i_ms_dn_BOS.darkcss(0.25, false) : color.gray, bgcolor = chart.bg_color, text_font_family = font.family_monospace)
table.cell(tab, 1, 3, text = itrend4H == 1 ? "BULLISH" : itrend4H == -1 ? "BEARISH" : na , text_halign = text.align_center, text_size = size.normal, text_color = itrend4H == 1 ? i_ms_up_BOS.darkcss(-0.25, true) : itrend4H == -1 ? i_ms_dn_BOS.darkcss(0.25, false) : color.gray, bgcolor = chart.bg_color, text_font_family = font.family_monospace)
table.cell(tab, 1, 4, text = itrend1D == 1 ? "BULLISH" : itrend1D == -1 ? "BEARISH" : na , text_halign = text.align_center, text_size = size.normal, text_color = itrend1D == 1 ? i_ms_up_BOS.darkcss(-0.25, true) : itrend1D == -1 ? i_ms_dn_BOS.darkcss(0.25, false) : color.gray, bgcolor = chart.bg_color, text_font_family = font.family_monospace)
table.cell(tab, 0, 5, text = "Detected Pattern", text_halign = text.align_center, text_size = size.normal, text_color = color.silver, bgcolor = chart.bg_color, text_font_family = font.family_monospace)
table.cell(tab, 0, 6, text = p.found, text_halign = text.align_center, text_size = size.normal, text_color = na(p.bull) ? color.white : p.bull ? i_ms_up_BOS.darkcss(-0.25, true) : p.bull == false ? i_ms_dn_BOS.darkcss(0.25, false) : na, bgcolor = chart.bg_color, text_font_family = font.family_monospace)
table.merge_cells(tab, 0, 5, 1, 5)
table.merge_cells(tab, 0, 6, 1, 6)
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - End }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - Strong/Weak High/Low And Equilibrium }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
var phl = Zphl.new(
na
, na
, label.new(na , na , color = invcol , textcolor = i_ms_dn_BOS , style = label.style_label_down , size = size.tiny , text = "")
, label.new(na , na , color = invcol , textcolor = i_ms_up_BOS , style = label.style_label_up , size = size.tiny , text = "")
, true
, true
, true
, true
, ""
, ""
, 0
, 0
, 0
, 0
, high
, low
, 0
, 0
, 0
, 0
, 0
, 0
, na
, na
)
zhl(len)=>
upper = ta.highest(len)
lower = ta.lowest(len)
var float out = 0
out := b.h > upper ? 0 : b.l < lower ? 1 : out
top = out == 0 and out != 0 ? b.h : 0
btm = out == 1 and out != 1 ? b.l : 0
= zhl(sLen)
= zhl(iLen)
upphl(trend) =>
var label lbl = label.new(
na
, na
, color = invcol
, textcolor = toplvl
, style = label.style_label_down
, size = size.small
)
if top
phl.stopcross := true
phl.txtup := top > phl.topy ? "HH" : "HL"
if show_lbl
topl = label.new(
b.n - swing_r_lookback
, top
, phl.txtup
, color = invcol
, textcolor = toplvl
, style = label.style_label_down
, size = size.small
)
line.delete(phl.top )
phl.top := line.new(
b.n - sLen
, top
, b.n
, top
, color = toplvl)
phl.topy := top
phl.topx := b.n - sLen
phl.tup := top
phl.tupx := b.n - sLen
if itop
phl.itopcross := true
phl.itopy := itop
phl.itopx := b.n - iLen
phl.tup := math.max(high, phl.tup)
phl.tupx := phl.tup == high ? b.n : phl.tupx
phl.uV := phl.tup != phl.tup ? b.v : phl.uV
if barstate.islast
line.set_xy1(
phl.top
, phl.tupx
, phl.tup
)
line.set_xy2(
phl.top
, b.n + 50
, phl.tup
)
label.set_x(
lbl
, b.n + 50
)
label.set_y(
lbl
, phl.tup
)
dist = math.abs(phl.uV / (phl.uV + phl.dV)) * 100
label.set_text (lbl, trend < 0
? "Strong High | " + str.tostring(phl.uV, format.volume) + " (" + str.tostring(math.round(dist,0)) + "%)"
: "Weak High | " + str.tostring(phl.uV, format.volume) + " (" + str.tostring(math.round(dist,0)) + "%)")
dnphl(trend) =>
var label lbl = label.new(
na
, na
, color = invcol
, textcolor = btmlvl
, style = label.style_label_up
, size = size.small
)
if btm
phl.sbottomcross := true
phl.txtdn := btm > phl.bottomy ? "LH" : "LL"
if show_lbl
btml = label.new(
b.n - swing_r_lookback
, btm, phl.txtdn
, color = invcol
, textcolor = btmlvl
, style = label.style_label_up
, size = size.small
)
line.delete(phl.bottom )
phl.bottom := line.new(
b.n - sLen
, btm
, b.n
, btm
, color = btmlvl
)
phl.bottomy := btm
phl.bottomx := b.n - sLen
phl.tdn := btm
phl.tdnx := b.n - sLen
if ibtm
phl.ibottomcross := true
phl.ibottomy := ibtm
phl.ibottomx := b.n - iLen
phl.tdn := math.min(low, phl.tdn)
phl.tdnx := phl.tdn == low ? b.n : phl.tdnx
phl.dV := phl.tdn != phl.tdn ? b.v : phl.dV
if barstate.islast
line.set_xy1(
phl.bottom
, phl.tdnx
, phl.tdn
)
line.set_xy2(
phl.bottom
, b.n + 50
, phl.tdn
)
label.set_x(
lbl
, b.n + 50
)
label.set_y(
lbl
, phl.tdn
)
dist = math.abs(phl.dV / (phl.uV + phl.dV)) * 100
label.set_text (lbl, trend > 0
? "Strong Low | " + str.tostring(phl.dV, format.volume) + " (" + str.tostring(math.round(dist,0)) + "%)"
: "Weak Low | " + str.tostring(phl.uV, format.volume) + " (" + str.tostring(math.round(dist,0)) + "%)")
midphl() =>
avg = math.avg(phl.bottom.get_y2(), phl.top.get_y2())
var line l = line.new(
y1 = avg
, y2 = avg
, x1 = b.n - sLen
, x2 = b.n + 50
, color = midlvl
, style = line.style_solid
)
var label lbl = label.new(
x = b.n + 50
, y = avg
, text = "Equilibrium"
, style = label.style_label_left
, color = invcol
, textcolor = midlvl
, size = size.small
)
if barstate.islast
more = (phl.bottom.get_x1() + phl.bottom.get_x2()) > (phl.top.get_x1() + phl.top.get_x2()) ? phl.top.get_x1() : phl.bottom.get_x1()
line.set_xy1(l , more , avg)
line.set_xy2(l , b.n + 50, avg)
label.set_x (lbl , b.n + 50 )
label.set_y (lbl , avg )
dist = math.abs((l.get_y2() - close) / close) * 100
label.set_text (lbl, "Equilibrium (" + str.tostring(math.round(dist,0)) + "%)")
hqlzone() =>
if barstate.islast
var hqlzone dZone = hqlzone.new(
box.new(
na
, na
, na
, na
, bgcolor = color.new(toplvl, 70)
, border_color = na
)
, box.new(
na
, na
, na
, na
, bgcolor = color.new(midlvl, 70)
, border_color = na
)
, box.new(
na
, na
, na
, na
, bgcolor = color.new(btmlvl, 70)
, border_color = na
)
, label.new(na, na, text = "Premium" , color = invcol, textcolor = toplvl, style = label.style_label_down, size = size.small)
, label.new(na, na, text = "Equilibrium", color = invcol, textcolor = midlvl, style = label.style_label_left, size = size.small)
, label.new(na, na, text = "Discount" , color = invcol, textcolor = btmlvl, style = label.style_label_up , size = size.small)
)
dZone.pbx.set_lefttop(int(math.max(phl.topx, phl.bottomx)) , phl.tup)
dZone.pbx.set_rightbottom(b.n + 50 , 0.95 * phl.tup + 0.05 * phl.tdn)
dZone.ebx.set_lefttop(int(math.max(phl.topx, phl.bottomx)), 0.525 * phl.tup + 0.475 * phl.tdn)
dZone.ebx.set_rightbottom(b.n + 50 , 0.525 * phl.tdn + 0.475 * phl.tup)
dZone.lbx.set_lefttop(int(math.max(phl.topx, phl.bottomx)), 0.95 * phl.tdn + 0.05 * phl.tup)
dZone.lbx.set_rightbottom(b.n + 50 , phl.tdn)
dZone.plb.set_xy( int(math.avg(math.max(phl.topx, phl.bottomx), int(b.n + 50))) , phl.tup)
dZone.elb.set_xy( int(b.n + 50) , math.avg(phl.tup, phl.tdn))
dZone.lbl.set_xy( int(math.avg(math.max(phl.topx, phl.bottomx), int(b.n + 50))) , phl.tdn)
if show_mtb
upphl (trend)
dnphl (trend)
hqlzone()
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - End }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - Volumetric Order Block }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
method eB(box b, bool ext, color css, bool swing) =>
b.unshift(
box.new(
na
, na
, na
, na
, xloc = xloc.bar_time
, text_font_family = font.family_monospace
, extend = ext ? extend.right : extend.none
, border_color = swing ? color.new(css, 0) : color.new(color.white,100)
, bgcolor = css
, border_width = 1
)
)
method eL(line l, bool ext, bool solid, color css) =>
l.unshift(
line.new(
na
, na
, na
, na
, width = 1
, color = css
, xloc = xloc.bar_time
, extend = ext ? extend.right : extend.none
, style = solid ? line.style_solid : line.style_dashed
)
)
method drawVOB(bool cdn, bool bull, color css, int loc, bool swing) =>
= request.security(
syminfo.tickerid
, ""
,
, lookahead = barmerge.lookahead_off
)
var obC obj = obC.new(
array.new()
, array.new()
, array.new< int >()
, array.new()
, array.new()
, array.new()
, array.new< int >()
, array.new< int >()
, array.new< int >()
, array.new< int >()
, array.new()
, array.new()
, array.new< int >()
)
var obD draw = obD.new(
array.new()
, array.new()
, array.new()
, array.new()
, array.new()
)
if barstate.isfirst
for i = 0 to ob_num - 1
draw.mL .eL(false, false, use_grayscale ? color.new(color.gray, 0) : color.new(css,0))
draw.ob .eB(false, use_grayscale ? color.new(color.gray, 90) : css, swing)
draw.blB.eB(false, css_metric_up , swing)
draw.brB.eB(false, css_metric_dn , swing)
draw.eOB.eB(true , use_grayscale ? color.new(color.gray, 90) : css, swing)
float pos = ob_pos == "Full"
? (bull ? high : low)
: ob_pos == "Middle"
? ohlc4
: ob_pos == "Accurate"
? hl2
: hl2
if cdn
obj.h.clear()
obj.l.clear()
obj.n.clear()
for i = 0 to math.abs((loc - b.n)) - 1
obj.h.push(hH )
obj.l.push(lL )
obj.n.push(b.t )
// obj.h.reverse()
// obj.l.reverse()
int iU = obj.l.indexof(obj.l.min()) + 1
int iD = obj.h.indexof(obj.h.max()) + 1
obj.dir.unshift(
bull
? (b.c > b.o ? 1 : -1)
: (b.c > b.o ? 1 : -1)
)
obj.top.unshift(
bull
? pos
: obj.h.max()
)
obj.btm.unshift(
bull
? obj.l.min()
: pos
)
obj.left.unshift(
bull
? obj.n.get(obj.l.indexof(obj.l.min()))
: obj.n.get(obj.h.indexof(obj.h.max()))
)
obj.avg.unshift(
math.avg(obj.top.first(), obj.btm.first())
)
obj.cV.unshift(
bull
? b.v
: b.v
)
if ob_pos == "Precise"
switch bull
true =>
if obj.avg.get(0) < (b.c < b.o ? b.c : b.o ) and obj.top.get(0) > hlcc4
obj.top.set(0, obj.avg.get(0))
obj.avg.set(0, math.avg(obj.top.first(), obj.btm.first()))
false =>
if obj.avg.get(0) > (b.c < b.o ? b.o : b.c ) and obj.btm.get(0) < hlcc4
obj.btm.set(0, obj.avg.get(0))
obj.avg.set(0, math.avg(obj.top.first(), obj.btm.first()))
obj.blVP.unshift ( 0 )
obj.brVP.unshift ( 0 )
obj.wM .unshift ( 1 )
if use_overlap
int rmP = use_overlap_method == "Recent" ? 1 : 0
if obj.avg.size() > 1
if bull
? obj.btm.first() < obj.top.get(1)
: obj.top.first() > obj.btm.get(1)
obj.wM .remove(rmP)
obj.cV .remove(rmP)
obj.dir .remove(rmP)
obj.top .remove(rmP)
obj.avg .remove(rmP)
obj.btm .remove(rmP)
obj.left .remove(rmP)
obj.blVP .remove(rmP)
obj.brVP .remove(rmP)
if barstate.isconfirmed
for x = 0 to ob_num - 1
tg = switch ob_mitigation
"Middle" => obj.avg
"Absolute" => bull ? obj.btm : obj.top
for in tg
if (bull ? cC < pt : cC > pt)
obj.wM .remove(idx)
obj.cV .remove(idx)
obj.dir .remove(idx)
obj.top .remove(idx)
obj.avg .remove(idx)
obj.btm .remove(idx)
obj.left .remove(idx)
obj.blVP .remove(idx)
obj.brVP .remove(idx)
if barstate.islast
if obj.avg.size() > 0
// Alert
if bull
? ta.crossunder(low , obj.top.get(0))
: ta.crossover (high, obj.btm.get(0))
switch bull
true => blalert.obtouch := true
false => bralert.obtouch := true
float tV = 0
obj.dV.clear()
seq = math.min(ob_num - 1, obj.avg.size() - 1)
for j = 0 to seq
tV += obj.cV.get(j)
if j == seq
for y = 0 to seq
obj.dV.unshift(
math.floor(
(obj.cV.get(y) / tV) * 100)
)
obj.dV.reverse()
for i = 0 to math.min(ob_num - 1, obj.avg.size() - 1)
dmL = draw.mL .get(i)
dOB = draw.ob .get(i)
dblB = draw.blB.get(i)
dbrB = draw.brB.get(i)
deOB = draw.eOB.get(i)
dOB.set_lefttop (obj.left .get(i) , obj.top.get(i))
deOB.set_lefttop (b.t , obj.top.get(i))
dOB.set_rightbottom (b.t , obj.btm.get(i))
deOB.set_rightbottom(b.t + (b.t - b.t ) * 100 , obj.btm.get(i))
if use_middle_line
dmL.set_xy1(obj.left.get(i), obj.avg.get(i))
dmL.set_xy2(b.t , obj.avg.get(i))
if ob_metrics_show
dblB.set_lefttop (obj.left.get(i), obj.top.get(i))
dbrB.set_lefttop (obj.left.get(i), obj.avg.get(i))
dblB.set_rightbottom(obj.left.get(i), obj.avg.get(i))
dbrB.set_rightbottom(obj.left.get(i), obj.btm.get(i))
rpBL = dblB.get_right()
rpBR = dbrB.get_right()
dbrB.set_right(rpBR + (b.t - b.t ) * obj.brVP.get(i))
dblB.set_right(rpBL + (b.t - b.t ) * obj.blVP.get(i))
if use_show_metric
txt = switch
obj.cV.get(i) >= 1000000000 => str.tostring(math.round(obj.cV.get(i) / 1000000000,3)) + "B"
obj.cV.get(i) >= 1000000 => str.tostring(math.round(obj.cV.get(i) / 1000000,3)) + "M"
obj.cV.get(i) >= 1000 => str.tostring(math.round(obj.cV.get(i) / 1000,3)) + "K"
obj.cV.get(i) < 1000 => str.tostring(math.round(obj.cV.get(i)))
deOB.set_text(
str.tostring(
txt + " (" + str.tostring(obj.dV.get(i)) + "%)")
)
deOB.set_text_size (size.auto)
deOB.set_text_halign(text.align_left)
deOB.set_text_color (use_grayscale ? color.silver : color.new(css, 0))
if ob_metrics_show and barstate.isconfirmed
if obj.wM.size() > 0
for i = 0 to obj.avg.size() - 1
switch obj.dir.get(i)
1 =>
switch obj.wM.get(i)
1 => obj.blVP.set(i, obj.blVP.get(i) + 1), obj.wM.set(i, 2)
2 => obj.blVP.set(i, obj.blVP.get(i) + 1), obj.wM.set(i, 3)
3 => obj.brVP.set(i, obj.brVP.get(i) + 1), obj.wM.set(i, 1)
-1 =>
switch obj.wM.get(i)
1 => obj.brVP.set(i, obj.brVP.get(i) + 1), obj.wM.set(i, 2)
2 => obj.brVP.set(i, obj.brVP.get(i) + 1), obj.wM.set(i, 3)
3 => obj.blVP.set(i, obj.blVP.get(i) + 1), obj.wM.set(i, 1)
var hN = array.new(1, b.n)
var lN = array.new(1, b.n)
var hS = array.new(1, b.n)
var lS = array.new(1, b.n)
if iH
hN.pop()
hN.unshift(int(b.n ))
if iL
lN.pop()
lN.unshift(int(b.n ))
if sH
hS.pop()
hS.unshift(int(b.n ))
if sL
lS.pop()
lS.unshift(int(b.n ))
if ob_show
bull_ob.drawVOB(true , ob_bull_css, hN.first(), false)
bear_ob.drawVOB(false, ob_bear_css, lN.first(), false)
if ob_swings
s_bull_ob.drawVOB(true , css_swing_up, hS.first(), true)
s_bear_ob.drawVOB(false, css_swing_dn, lS.first(), true)
if bull_ob
blalert.ob := true
if bear_ob
bralert.ob := true
if s_bull_ob
blalert.swingob := true
if s_bear_ob
blalert.swingob := true
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - End }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{ - FVG | VI | OG }
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
//{----------------------------------------------------------------------------------------------------------------------------------------------}
ghl() => request.security(syminfo.tickerid, fvg_tf, [high , low , close , open ])
tfG() => request.security(syminfo.tickerid, fvg_tf, )
cG(bool bull) =>
= ghl()
= tfG()
var FVG draw = FVG.new(
array.new()
, array.new()
)
var FVG cords = array.new()
float pup = na
float pdn = na
bool cdn = na
int pos = 2
cc = timeframe.change(fvg_tf)
if barstate.isfirst
for i = 0 to fvg_num - 1
draw.box.unshift(box.new (na, na, na, na, border_color = color.new(color.white, 100), xloc = xloc.bar_time))
draw.ln.unshift (line.new(na, na, na, na, xloc = xloc.bar_time, width = 1, style = line.style_solid))
switch what_fvg
"FVG" =>
pup := bull ? gl : l
pdn := bull ? h : gh
cdn := bull ? gl > h and cc : gh < l and cc
pos := 2
"VI" =>
pup := bull
? (gc > go
? go
: gc)
: (gc > go
? go
: gc )
pdn := bull
? (gc > go
? gc
: go )
: (gc > go
? gc
: go)
cdn := bull
? go > gc and gh > gl and gc > gc and go > go and gh < math.min(gc, go) and cc
: go < gc and gl < gh and gc < gc and go < go and gl > math.max(gc, go) and cc
pos := 1
"OG" =>
pup := bull ? b.l : gl
p