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)
Penunjuk dan strategi
Peshraw strategy 1//@version=5
indicator("Peshraw strategy 1", overlay=false)
// --- Stochastic Settings
kPeriod = 100
dPeriod = 3
slowing = 3
k = ta.sma(ta.stoch(close, high, low, kPeriod), slowing)
d = ta.sma(k, dPeriod)
// --- Moving Average on Stochastic %K
maLength = 2
maOnK = ta.sma(k, maLength)
// --- Plot Stochastic
plot(k, color=color.blue, title="%K")
plot(d, color=color.orange, title="%D")
// --- Plot MA(2) on %K
plot(maOnK, color=color.red, title="MA(2) on %K")
// --- Levels (fix hline error)
hline(9, "Level 9", color=color.gray, linestyle=hline.style_dotted)
hline(18, "Level 18", color=color.gray, linestyle=hline.style_dotted)
hline(27, "Level 27", color=color.gray, linestyle=hline.style_dotted)
hline(36, "Level 36", color=color.gray, linestyle=hline.style_dotted)
hline(45, "Level 45", color=color.gray, linestyle=hline.style_dotted)
hline(54, "Level 54", color=color.gray, linestyle=hline.style_dotted)
hline(63, "Level 63", color=color.gray, linestyle=hline.style_dotted)
hline(72, "Level 72", color=color.gray, linestyle=hline.style_dotted)
hline(81, "Level 81", color=color.gray, linestyle=hline.style_dotted)
hline(91, "Level 91", color=color.gray, linestyle=hline.style_dotted)
WTI Futures Premarket Channels (Flexible Price Alerts)It is a channel indicator for WTI Futures Premarket between 9:00 AM EST to 9:30 AM EST.
How it works:
Pre-market high and low is defined per trading day between 9:00 EST to 9:30 EST.
Then we looking for the first breakout on either PM high or PM low.
- Breakout high = long trade
- Breakout low = short trade
Highest High, Lowest Low 4H 30 Bars LookbackThis indicator plots the Highest High and Lowest Low levels over a selected lookback period, along with a Simple Moving Average (SMA). It helps identify breakout levels and trend direction.
Green Line → Highest High over the chosen period.
Red Line → Lowest Low over the chosen period.
Cyan Line → SMA of closing prices.
How to use:
A breakout above the Highest High may indicate a bullish move.
A breakdown below the Lowest Low may indicate a bearish move.
The SMA helps filter signals by trend direction.
Alerts are triggered when the price crosses above the Highest High or below the Lowest Low.
Pip distance by Jim Belardi//@version=5
indicator("Pip-Distanz zum Hoch/Tief (EURUSD)", overlay=true)
// Pip-Faktor fix for EURUSD (5 Nachkommastellen, 1 Pip = 0.0001)
pip_factor = 10000.0
// live candle
current_price = close
candle_high = high
candle_low = low
// calculate distance in pips
dist_high_pips = (candle_high - current_price) * pip_factor
dist_low_pips = (current_price - candle_low) * pip_factor
// create table (once)
var table pipTable = table.new(position.bottom_right, 2, 2, border_width=1, frame_color=color.gray)
// updating table
if barstate.islast
table.cell(pipTable, 0, 0, "Distanz zum Hoch", text_color=color.red, text_size=size.large)
table.cell(pipTable, 1, 0, str.tostring(dist_high_pips, format.mintick) + " Pips", text_color=color.red, text_size=size.large)
table.cell(pipTable, 0, 1, "Distanz zum Tief", text_color=color.green, text_size=size.large)
table.cell(pipTable, 1, 1, str.tostring(dist_low_pips, format.mintick) + " Pips", text_color=color.green, text_size=size.large)
Swing RSI Panel//@version=6
indicator("Swing RSI Panel", overlay=false)
// RSI Settings
rsiLength = input.int(14, "RSI Length")
rsiOversold = input.int(40, "RSI Oversold")
rsiOverbought = input.int(60, "RSI Overbought")
// Calculate RSI
rsiValue = ta.rsi(close, rsiLength)
// Plot RSI
plot(rsiValue, "RSI", color=color.purple, linewidth=2)
hline(50, "Midline", color=color.gray, linestyle=hline.style_dotted)
hline(rsiOversold, "Oversold", color=color.green, linestyle=hline.style_dotted)
hline(rsiOverbought, "Overbought", color=color.red, linestyle=hline.style_dotted)
// Fill zones
bgcolor(rsiValue >= rsiOverbought ? color.new(color.red, 90) :
rsiValue <= rsiOversold ? color.new(color.green, 90) : na, title="RSI Zones")
SCTR - AbsoluteIndicator for showing Absolute Value of SCTR - StockCharts Technical Rank.
Uses the calculations from Stock Charts based on the following:
Long-Term Indicators (weighting)
--------------------------------
* Percent above/below 200-day EMA (30%)
* 125-Day Rate-of-Change (30%)
Medium-Term Indicators (weighting)
----------------------------------
* Percent above/below 50-day EMA (15%)
* 20-day Rate-of-Change (15%)
Short-Term Indicators (weighting)
---------------------------------
* 3-day slope of PPO(12,26,9) Histogram/3 (5%)
* 14-day RSI (5%)
First H4 Window Box with PanelThis indicator will explain in detail about the characterstics of first hour open in Gold
ALMA HẰNG DIỄM @//@version=5
indicator("ALMA Đa khung thời gian", overlay=true)
// Hàm ALMA tùy chỉnh
f_alma(src, len, offset, sigma) =>
m = math.floor(offset * (len - 1))
s = len > 1 ? len - 1 : 1
norm = 0.0
sum = 0.0
for i = 0 to len - 1
w = math.exp(-(math.pow(i - m, 2)) / (2 * math.pow(sigma, 2)))
norm := norm + w
sum := sum + src * w
sum / norm
// Tham số người dùng
alma_len_short = input.int(9, title="Chu kỳ ngắn")
alma_len_long = input.int(50, title="Chu kỳ dài")
alma_offset = input.float(0.85, title="Offset")
alma_sigma = input.float(6.0, title="Sigma")
// ALMA hiện tại (khung đang xem)
alma_short = f_alma(close, alma_len_short, alma_offset, alma_sigma)
alma_long = f_alma(close, alma_len_long, alma_offset, alma_sigma)
// ALMA khung D1
alma_d1_short = request.security(syminfo.tickerid, "D", f_alma(close, alma_len_short, alma_offset, alma_sigma))
alma_d1_long = request.security(syminfo.tickerid, "D", f_alma(close, alma_len_long, alma_offset, alma_sigma))
// ALMA khung W1
alma_w1_short = request.security(syminfo.tickerid, "W", f_alma(close, alma_len_short, alma_offset, alma_sigma))
alma_w1_long = request.security(syminfo.tickerid, "W", f_alma(close, alma_len_long, alma_offset, alma_sigma))
// Vẽ biểu đồ
plot(alma_short, color=color.orange, title="ALMA Ngắn (Hiện tại)")
plot(alma_long, color=color.blue, title="ALMA Dài (Hiện tại)")
plot(alma_d1_short, color=color.green, title="ALMA Ngắn (D1)", linewidth=1)
plot(alma_d1_long, color=color.red, title="ALMA Dài (D1)", linewidth=1)
plot(alma_w1_short, color=color.purple, title="ALMA Ngắn (W1)", linewidth=1)
plot(alma_w1_long, color=color.gray, title="ALMA Dài (W1)", linewidth=1)
// Chênh lệch ALMA hiện tại
plot(alma_short - alma_long, title="Chênh lệch ALMA", color=color.fuchsia, style=plot.style_columns)
Pre‑Market Cumulative VolumeDescription:
This indicator plots the cumulative trading volume for the pre‑market session on intraday charts. It automatically detects when a bar is part of the extended pre‑market period using TradingView’s built‑in session variables, starts a new running total at the first pre‑market bar of each day, and resets at the beginning of regular trading hours. During regular market hours or the post‑market session, the indicator does not display values.
To use this script effectively, ensure extended‑hour data is enabled on the chart, and select an intraday timeframe where pre‑market data is available. The result is a simple yet powerful tool for monitoring cumulative pre‑market activity.
How to use
Add the script to a chart and make sure you are on an intraday timeframe (e.g., 1‑min, 5‑min). Extended‑hour data must be enabled; otherwise session.ispremarket will always be false.
During each pre‑market session, the indicator will reset at the first pre‑market bar and then accumulate the volume of subsequent pre‑market bars.
Outside the pre‑market (regular trading hours and post‑market), the plot outputs na, so it does not draw on those bars.
Customization (optional)
If you want to define your own pre‑market times instead of relying on TradingView’s built‑in session, you can replace the isPreMarket line with a time‑range check. For example, isPreMarket = not na(time(timeframe.period, "0400-0930")) detects bars between 04:00 and 09:30 (U.S. Eastern time). You can parameterize the session string with input.session("0400-0930", "Pre‑Market Session") to let users adjust it.
Bullish_Mayank_entry_IndicatorThis indicator works on finding bullish momemtum using EMAs, RSIs amd Weighted Moving Average of RSI
ApicodeLibrary "Apicode"
percentToTicks(percent, from)
Converts a percentage of the average entry price or a specified price to ticks when the
strategy has an open position.
Parameters:
percent (float) : (series int/float) The percentage of the `from` price to express in ticks, e.g.,
a value of 50 represents 50% (half) of the price.
from (float) : (series int/float) Optional. The price from which to calculate a percentage and convert
to ticks. The default is `strategy.position_avg_price`.
Returns: (float) The number of ticks within the specified percentage of the `from` price if
the strategy has an open position. Otherwise, it returns `na`.
percentToPrice(percent, from)
Calculates the price value that is a specific percentage distance away from the average
entry price or a specified price when the strategy has an open position.
Parameters:
percent (float) : (series int/float) The percentage of the `from` price to use as the distance. If the value
is positive, the calculated price is above the `from` price. If negative, the result is
below the `from` price. For example, a value of 10 calculates the price 10% higher than
the `from` price.
from (float) : (series int/float) Optional. The price from which to calculate a percentage distance.
The default is `strategy.position_avg_price`.
Returns: (float) The price value at the specified `percentage` distance away from the `from` price
if the strategy has an open position. Otherwise, it returns `na`.
percentToCurrency(price, percent)
Parameters:
price (float) : (series int/float) The price from which to calculate the percentage.
percent (float) : (series int/float) The percentage of the `price` to calculate.
Returns: (float) The amount of the symbol's currency represented by the percentage of the specified
`price`.
percentProfit(exitPrice)
Calculates the expected profit/loss of the open position if it were to close at the
specified `exitPrice`, expressed as a percentage of the average entry price.
NOTE: This function may not return precise values for positions with multiple open trades
because it only uses the average entry price.
Parameters:
exitPrice (float) : (series int/float) The position's hypothetical closing price.
Returns: (float) The expected profit percentage from exiting the position at the `exitPrice`. If
there is no open position, it returns `na`.
priceToTicks(price)
Converts a price value to ticks.
Parameters:
price (float) : (series int/float) The price to convert.
Returns: (float) The value of the `price`, expressed in ticks.
ticksToPrice(ticks, from)
Calculates the price value at the specified number of ticks away from the average entry
price or a specified price when the strategy has an open position.
Parameters:
ticks (float) : (series int/float) The number of ticks away from the `from` price. If the value is positive,
the calculated price is above the `from` price. If negative, the result is below the `from`
price.
from (float) : (series int/float) Optional. The price to evaluate the tick distance from. The default is
`strategy.position_avg_price`.
Returns: (float) The price value at the specified number of ticks away from the `from` price if
the strategy has an open position. Otherwise, it returns `na`.
ticksToCurrency(ticks)
Converts a specified number of ticks to an amount of the symbol's currency.
Parameters:
ticks (float) : (series int/float) The number of ticks to convert.
Returns: (float) The amount of the symbol's currency represented by the tick distance.
ticksToStopLevel(ticks)
Calculates a stop-loss level using a specified tick distance from the position's average
entry price. A script can plot the returned value and use it as the `stop` argument in a
`strategy.exit()` call.
Parameters:
ticks (float) : (series int/float) The number of ticks from the position's average entry price to the
stop-loss level. If the position is long, the value represents the number of ticks *below*
the average entry price. If short, it represents the number of ticks *above* the price.
Returns: (float) The calculated stop-loss value for the open position. If there is no open position,
it returns `na`.
ticksToTpLevel(ticks)
Calculates a take-profit level using a specified tick distance from the position's average
entry price. A script can plot the returned value and use it as the `limit` argument in a
`strategy.exit()` call.
Parameters:
ticks (float) : (series int/float) The number of ticks from the position's average entry price to the
take-profit level. If the position is long, the value represents the number of ticks *above*
the average entry price. If short, it represents the number of ticks *below* the price.
Returns: (float) The calculated take-profit value for the open position. If there is no open
position, it returns `na`.
calcPositionSizeByStopLossTicks(stopLossTicks, riskPercent)
Calculates the entry quantity required to risk a specified percentage of the strategy's
current equity at a tick-based stop-loss level.
Parameters:
stopLossTicks (float) : (series int/float) The number of ticks in the stop-loss distance.
riskPercent (float) : (series int/float) The percentage of the strategy's equity to risk if a trade moves
`stopLossTicks` away from the entry price in the unfavorable direction.
Returns: (int) The number of contracts/shares/lots/units to use as the entry quantity to risk the
specified percentage of equity at the stop-loss level.
calcPositionSizeByStopLossPercent(stopLossPercent, riskPercent, entryPrice)
Calculates the entry quantity required to risk a specified percentage of the strategy's
current equity at a percent-based stop-loss level.
Parameters:
stopLossPercent (float) : (series int/float) The percentage of the `entryPrice` to use as the stop-loss distance.
riskPercent (float) : (series int/float) The percentage of the strategy's equity to risk if a trade moves
`stopLossPercent` of the `entryPrice` in the unfavorable direction.
entryPrice (float) : (series int/float) Optional. The entry price to use in the calculation. The default is
`close`.
Returns: (int) The number of contracts/shares/lots/units to use as the entry quantity to risk the
specified percentage of equity at the stop-loss level.
exitPercent(id, lossPercent, profitPercent, qty, qtyPercent, comment, alertMessage)
A wrapper for the `strategy.exit()` function designed for creating stop-loss and
take-profit orders at percentage distances away from the position's average entry price.
NOTE: This function calls `strategy.exit()` without a `from_entry` ID, so it creates exit
orders for *every* entry in an open position until the position closes. Therefore, using
this function when the strategy has a pyramiding value greater than 1 can lead to
unexpected results. See the "Exits for multiple entries" section of our User Manual's
"Strategies" page to learn more about this behavior.
Parameters:
id (string) : (series string) Optional. The identifier of the stop-loss/take-profit orders, which
corresponds to an exit ID in the strategy's trades after an order fills. The default is
`"Exit"`.
lossPercent (float) : (series int/float) The percentage of the position's average entry price to use as the
stop-loss distance. The function does not create a stop-loss order if the value is `na`.
profitPercent (float) : (series int/float) The percentage of the position's average entry price to use as the
take-profit distance. The function does not create a take-profit order if the value is `na`.
qty (float) : (series int/float) Optional. The number of contracts/lots/shares/units to close when an
exit order fills. If specified, the call uses this value instead of `qtyPercent` to
determine the order size. The exit orders reserve this quantity from the position, meaning
other orders from `strategy.exit()` cannot close this portion until the strategy fills or
cancels those orders. The default is `na`, which means the order size depends on the
`qtyPercent` value.
qtyPercent (float) : (series int/float) Optional. A value between 0 and 100 representing the percentage of the
open trade quantity to close when an exit order fills. The exit orders reserve this
percentage from the open trades, meaning other calls to this command cannot close this
portion until the strategy fills or cancels those orders. The percentage calculation
depends on the total size of the applicable open trades without considering the reserved
amount from other `strategy.exit()` calls. The call ignores this parameter if the `qty`
value is not `na`. The default is 100.
comment (string) : (series string) Optional. Additional notes on the filled order. If the value is specified
and not an empty "string", the Strategy Tester and the chart show this text for the order
instead of the specified `id`. The default is `na`.
alertMessage (string) : (series string) Optional. Custom text for the alert that fires when an order fills. If the
value is specified and not an empty "string", and the "Message" field of the "Create Alert"
dialog box contains the `{{strategy.order.alert_message}}` placeholder, the alert message
replaces the placeholder with this text. The default is `na`.
Returns: (void) The function does not return a usable value.
closeAllAtEndOfSession(comment, alertMessage)
A wrapper for the `strategy.close_all()` function designed to close all open trades with a
market order when the last bar in the current day's session closes. It uses the command's
`immediately` parameter to exit all trades at the last bar's `close` instead of the `open`
of the next session's first bar.
Parameters:
comment (string) : (series string) Optional. Additional notes on the filled order. If the value is specified
and not an empty "string", the Strategy Tester and the chart show this text for the order
instead of the automatically generated exit identifier. The default is `na`.
alertMessage (string) : (series string) Optional. Custom text for the alert that fires when an order fills. If the
value is specified and not an empty "string", and the "Message" field of the "Create Alert"
dialog box contains the `{{strategy.order.alert_message}}` placeholder, the alert message
replaces the placeholder with this text. The default is `na`.
Returns: (void) The function does not return a usable value.
closeAtEndOfSession(entryId, comment, alertMessage)
A wrapper for the `strategy.close()` function designed to close specific open trades with a
market order when the last bar in the current day's session closes. It uses the command's
`immediately` parameter to exit the trades at the last bar's `close` instead of the `open`
of the next session's first bar.
Parameters:
entryId (string)
comment (string) : (series string) Optional. Additional notes on the filled order. If the value is specified
and not an empty "string", the Strategy Tester and the chart show this text for the order
instead of the automatically generated exit identifier. The default is `na`.
alertMessage (string) : (series string) Optional. Custom text for the alert that fires when an order fills. If the
value is specified and not an empty "string", and the "Message" field of the "Create Alert"
dialog box contains the `{{strategy.order.alert_message}}` placeholder, the alert message
replaces the placeholder with this text. The default is `na`.
Returns: (void) The function does not return a usable value.
sortinoRatio(interestRate, forceCalc)
Calculates the Sortino ratio of the strategy based on realized monthly returns.
Parameters:
interestRate (simple float) : (simple int/float) Optional. The *annual* "risk-free" return percentage to compare against
strategy returns. The default is 2, meaning it uses an annual benchmark of 2%.
forceCalc (bool) : (series bool) Optional. A value of `true` forces the function to calculate the ratio on the
current bar. If the value is `false`, the function calculates the ratio only on the latest
available bar for efficiency. The default is `false`.
Returns: (float) The Sortino ratio, which estimates the strategy's excess return per unit of
downside volatility.
sharpeRatio(interestRate, forceCalc)
Calculates the Sharpe ratio of the strategy based on realized monthly returns.
Parameters:
interestRate (simple float) : (simple int/float) Optional. The *annual* "risk-free" return percentage to compare against
strategy returns. The default is 2, meaning it uses an annual benchmark of 2%.
forceCalc (bool) : (series bool) Optional. A value of `true` forces the function to calculate the ratio on the
current bar. If the value is `false`, the function calculates the ratio only on the latest
available bar for efficiency. The default is `false`.
Returns: (float) The Sortino ratio, which estimates the strategy's excess return per unit of
total volatility.
10-Crypto Normalized IndexOverview
This indicator builds a custom index for up to 10 cryptocurrencies and plots their combined trend as a single line. Each coin is normalized to 100 at a user-selected base date (or at its first available bar), then averaged (equally or by your custom weights). The result lets you see the market direction of your basket at a glance.
How it works
For each symbol, the script finds a base price (first bar ≥ the chosen base date; or the first bar in history if base-date normalization is off).
It converts the current price to a normalized value: price / base × 100.
It then computes a weighted average of those normalized values to form the index.
A dotted baseline at 100 marks the starting point; values above/below 100 represent % performance vs. the base.
Key inputs
Symbols (10 max): Default set: BTC, ETH, SOL, POL, OKB, BNB, SUI, LINK, 1INCH, TRX (USDT pairs). You can change exchange/quote (keep all the same quote, e.g., all USDT).
Weights: Toggle equal weights or enter custom weights. Custom weights are auto-normalized internally, so they don’t need to sum to 1.
Base date: Year/Month/Day (default: 2025-06-01). Turning normalization off uses each symbol’s first available bar as its base.
Smoothing: Optional SMA to reduce noise.
Show baseline: Toggle the horizontal line at 100.
Interpretation
Index > 100 and rising → your basket is up since the base date.
Index < 100 and falling → down since the base date.
Use shorter timeframes for intraday sentiment, higher timeframes for swing/trend context.
Default basket & weights (editable)
Order: BTC, ETH, SOL, POL, OKB, BNB, SUI, LINK, 1INCH, TRX.
Default custom weight factors: 30, 30, 20, 10, 10, 5, 5, 5, 5, 5 (auto-normalized).
Base date: 2025-06-01.
Market Bias [Mario]Indicator Description: Market Bias
Core Objective and Philosophy
The Market Bias indicator is designed not as a simple signal generator, but as a comprehensive tool for trend analysis and directional bias assessment. Its primary purpose is to provide traders with a clear, at-a-glance understanding of the market's direction across multiple timeframes. By visualizing the alignment of trends, it helps traders make more informed decisions, ensuring they are trading in harmony with the broader market momentum rather than against it. This is a tool for strategic positioning, not for providing blind buy or sell commands.
How It Works: The Core Mechanic
The indicator's logic is based on the relationship between two configurable moving averages (MAs): a Fast MA (defaulting to a 9-period EMA) and a Slow MA (defaulting to a 21-period SMA). The market bias on any given timeframe is determined as follows:
Bullish Bias: When the Fast MA is trading above the Slow MA, it indicates positive, upward momentum.
Bearish Bias: When the Fast MA is trading below the Slow MA, it indicates negative, downward momentum.
Users have full control to customize the type (SMA, EMA, WMA, etc.) and length of each moving average to fit their specific trading style and the asset being analyzed.
Key Feature: The Higher Timeframe (HTF) Bias Table
This is the most powerful feature of the indicator and its main reason for existence. It displays a simple, color-coded table in the corner of the chart, showing the real-time bias for the Daily (D), 4-Hour (4H), and 1-Hour (1H) timeframes.
Purpose: The HTF table solves a critical problem for traders: losing sight of the bigger picture. A trader on a 15-minute chart might see a setup to go long, but if the 4H and Daily charts are strongly bearish, that trade is fighting a powerful current and has a lower probability of success.
Application: By checking this table, a trader can instantly verify if their intended trade direction is aligned with the higher timeframe trends. The ideal scenario is "confluence," where the bias is the same across all key timeframes (e.g., D, 4H, and 1H are all Bullish), giving the trader a strong conviction to only look for long entries.
On-Chart Visual Aids
To support the analysis on the current chart, the indicator provides several visual aids:
Moving Average Plots: Both the Fast and Slow MAs are drawn directly on the chart, allowing traders to see their interaction with price in real-time.
Color-Coded Bars: To make the current trend immediately obvious, the chart's price bars can be colored. Green bars signify a bullish bias (Fast > Slow), while red bars signify a bearish bias (Fast < Slow).
Crossover Markers (Optional): While the indicator is not a signal provider, it can optionally display "Buy" (up arrow) and "Sell" (down arrow) markers when the MAs cross. These should not be interpreted as direct trade signals. Instead, they serve as alerts that the market momentum may be shifting on the current timeframe. They are best used as points of interest or for confirming a thesis that is already supported by the HTF bias.
Summary
In essence, the Market Bias indicator is a decision-support tool. It encourages a disciplined, top-down approach to trading.
Use the HTF Table first to establish your strategic directional bias for the day or week.
Use the on-chart MAs and colored bars to analyze the trend on your preferred trading timeframe.
Use the optional crossover markers only as a final confirmation or timing tool, ensuring they align with the dominant bias established by the higher timeframes.
Highlight 10-11 AM NY//@version=5
indicator("Highlight 10-11 AM NY", overlay=true)
// Inputs for flexibility
startHour = input.int(10, "Start Hour (NY time)")
endHour = input.int(11, "End Hour (NY time)")
// Check if the current bar is within the session (uses chart time zone)
inSession = (hour(time, syminfo.timezone) >= startHour) and (hour(time, syminfo.timezone) < endHour)
// Highlight background
bgcolor(inSession ? color.new(color.yellow, 85) : na)
Smart Money Flow Index (SMFI) - This tool is useful for comparing price action with underlying money flow and spotting where smart money may be entering or exiting the market.
Hazel nut BB Strategy, volume base- lite versionHazel nut BB Strategy, volume base — lite version
Having knowledge and information in financial markets is only useful when a trader operates with a well-defined trading strategy. Trading strategies assist in capital management, profit-taking, and reducing potential losses.
This strategy is built upon the core principle of supply and demand dynamics. Alongside this foundation, one of the widely used technical tools — the Bollinger Bands — is employed to structure a framework for profit management and risk control.
In this strategy, the interaction of these tools is explained in detail. A key point to note is that for calculating buy and sell volumes, a lower timeframe function is used. When applied with a tick-level resolution, this provides the most precise measurement of buyer/seller flows. However, this comes with a limitation of reduced historical depth. Users should be aware of this trade-off: if precise tick-level data is required, shorter timeframes should be considered to extend historical coverage .
The strategy offers multiple configuration options. Nevertheless, it should be treated strictly as a supportive tool rather than a standalone trading system. Decisions must integrate personal analysis and other instruments. For example, in highly volatile assets with narrow ranges, it is recommended to adjust profit-taking and stop-loss percentages to smaller values.
◉ Volume Settings
• Buyer and seller volume (up/down volume) are requested from a lower timeframe, with an option to override the automatic resolution.
• A global lookback period is applied to calculate moving averages and cumulative sums of buy/sell/delta volumes.
• Ratios of buyers/sellers to total volume are derived both on the current bar and across the lookback window.
◉ Bollinger Band
• Bands are computed using configurable moving averages (SMA, EMA, RMA, WMA, VWMA).
• Inputs allow control of length, standard deviation multiplier, and offset.
• The basis, upper, and lower bands are plotted, with a shaded background between them.
◉ Progress & Proximity
• Relative position of the price to the Bollinger basis is expressed as percentages (qPlus/qMinus).
• “Near band” conditions are triggered when price progress toward the upper or lower band exceeds a user-defined threshold (%).
• A signed score (sScore) represents how far the close has moved above or below the basis relative to band width.
◉ Info Table
• Optional compact table summarizing:
• - Upper/lower band margins
• - Buyer/seller volumes with moving averages
• - Delta and cumulative delta
• - Buyer/seller ratios per bar and across the window
• - Money flow values (buy/sell/delta × price) for bar-level and summed periods
• The table is neutral-colored and resizable for different chart layouts.
◉ Zone Event Gate
• Tracks entry into and exit from “near band” zones.
• Arming logic: a side is armed when price enters a band proximity zone.
• Trigger logic: on exit, a trade event is generated if cumulative buyer or seller volume dominates over a configurable window.
◉ Trading Logic
• Orders are placed only on zone-exit events, conditional on volume dominance.
• Position sizing is defined as a fixed percentage of strategy equity.
• Long entries occur when leaving the lower zone with buyer dominance; short entries occur when leaving the upper zone with seller dominance.
◉ Exit Rules
• Open positions are managed by a strict priority sequence:
• 1. Stop-loss (% of entry price)
• 2. Take-profit (% of entry price)
• 3. Opposite-side event (zone exit with dominance in the other direction)
• Stop-loss and take-profit levels are configurable
◉ Notes
• This lite version is intended to demonstrate the interaction of Bollinger Bands and volume-based dominance logic.
• It provides a framework to observe how price reacts at band boundaries under varying buy/sell pressure, and how zone exits can be systematically converted into entry/exit signals.
When configuring this strategy, it is essential to carefully review the settings within the Strategy Tester. Ensure that the chosen parameters and historical data options are correctly aligned with the intended use. Accurate back testing depends on applying proper configurations for historical reference. The figure below illustrates sample result and configuration type.
Value Investing IndicatorThis is based on PeterNagy Indicator. I just update it from v.4 to v.6 and modify. Open for tweak
RSI DivergenceThe code originally belongs to Matthew J. Slabosz, the founder of Zen Trading (The Art of Trading). ✍️📈
👉 My contribution and improvement was adding a divergence line directly on the RSI chart.
Why? Because most people can’t confirm correctness just by reading the code. 🧑💻❌
They need to see it with their own eyes 👀✔️ — this prevents misinterpretation and makes divergences crystal clear.
✨ By adding these visual confirmations, the efficiency and usability of the code has been significantly enhanced. 🚀📊