Supertrend + RSI Positional StrategyOVERVIEW
This is a long-only, rule-based positional trading strategy designed for stocks, ETFs, and indices, with a primary focus on higher timeframes (1H and above).
The strategy combines:
Trend direction via Supertrend
Momentum confirmation via RSI
An optional ADX filter to ensure sufficient trend strength
The logic is intentionally kept simple, transparent, and non-repainting, making it suitable for both learning and practical positional analysis.
Core Idea
The strategy aims to participate only in sustained directional moves, avoiding choppy or low-momentum conditions.
Trades are taken only when trend and momentum align, and exits are handled using clearly defined, user-selectable rules. There is no prediction involved — only confirmation.
Entry Logic (Long Only)
A long position is considered when all of the following conditions are met:
Supertrend is bullish
RSI is above the bullish threshold (default: 50)
(Optional) ADX is above the ADX threshold (default: 20)
The ADX filter is optional and can be enabled or disabled by the user.
When enabled, it is used only for entry filtering and plays no role in exits.
Exit Logic (User Selectable)
Exit behavior can be adapted to different trading styles using the following options:
Supertrend OR RSI
Exit when either trend reverses or momentum weakens
Supertrend ONLY
Exit strictly on trend reversal
RSI ONLY
Exit when momentum drops below the threshold
Supertrend AND RSI
Exit only when both conditions are met
This flexibility allows users to choose between faster exits or more trend-following behavior.
Trade Management
Long-only strategy
One position at a time
No pyramiding
No intrabar execution logic
Manual trade-state handling ensures consistent behavior across:
Stocks
ETFs
Indices (including cash indices)
The strategy logic is evaluated on confirmed bar closes only, ensuring non-repainting behavior.
Visual Features
BUY / EXIT labels plotted only on the first confirmation candle
Independent customization for BUY and EXIT label position, color, and offset
Optional background highlighting while a trade is active
RSI and ADX are not plotted, keeping the chart clean and uncluttered
Recommended Usage
Timeframes: 1H, 2H, 4H, Daily
Markets: Stocks, ETFs, Indices
Style: Positional / Swing trading
This strategy is not intended for scalping or very low timeframes.
Open & Transparent
This script is published in open-source form to encourage learning and experimentation. Users are free to study the logic, adjust parameters, and understand how a simple trend-plus-momentum positional approach is constructed.
IMPORTANT NOTES
This is a rule-based analytical tool, not a signal service
No performance claims or guarantees are made
Results will vary depending on market conditions and parameter choices
Users are encouraged to understand the logic before applying it to live markets
Göstergeler ve stratejiler
james S/R Trend Pro v6//@version=6
strategy("jaems_MACD+RSI ", shorttitle="jaems_MACD+RSI ", overlay=false, initial_capital=10000, currency=currency.USD, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05, calc_on_every_tick=false)
// =============================================================================
// 1. 설정 (Inputs)
// =============================================================================
group_macd = "📊 MACD 설정"
fastLen = input.int(12, "Fast Length", group=group_macd)
slowLen = input.int(26, "Slow Length", group=group_macd)
sigLen = input.int(9, "Signal Smoothing", group=group_macd)
src = input.source(close, "Source", group=group_macd)
group_col = "🎨 시각화 색상"
col_up = input.color(color.new(#00E676, 0), "상승 (Neon Green)", group=group_col)
col_dn = input.color(color.new(#FF1744, 0), "하락 (Red)", group=group_col)
col_sig = input.color(color.new(#FFEA00, 0), "Signal 기본색", group=group_col)
// =============================================================================
// 2. 계산 (Calculations)
// =============================================================================
fastMA = ta.ema(src, fastLen)
slowMA = ta.ema(src, slowLen)
macd = fastMA - slowMA
signal = ta.ema(macd, sigLen)
hist = macd - signal
// 교차 확인 (Crossovers)
bool crossUp = ta.crossover(macd, signal)
bool crossDn = ta.crossunder(macd, signal)
// 추세 상태 확인
bool isBullish = macd >= signal
// =============================================================================
// 3. 전략 실행 (Execution)
// =============================================================================
if crossUp
strategy.entry("Long", strategy.long)
if crossDn
strategy.entry("Short", strategy.short)
// =============================================================================
// 4. 시각화 (Visualization) - 수정된 부분
// =============================================================================
// 4.1 MACD 라인 색상 동적 변경
color macdDynamicColor = isBullish ? col_up : col_dn
// 4.2 라인 그리기
plot(macd, title="MACD Line", color=macdDynamicColor, linewidth=2)
plot(signal, title="Signal Line", color=col_sig, linewidth=1)
// 4.3 교차점 도트 (Thick Dots) - 괄호 오류 방지를 위해 명시적 변수 할당
float dotLevelUp = crossUp ? signal : na
float dotLevelDn = crossDn ? signal : na
plot(dotLevelUp, title="Golden Cross Dot", style=plot.style_circles, color=col_up, linewidth=5)
plot(dotLevelDn, title="Dead Cross Dot", style=plot.style_circles, color=col_dn, linewidth=5)
// 4.4 히스토그램 색상 (오류 수정: 중첩 삼항연산자 제거 -> if-else 변환)
color histColor = na
if isBullish
// 상승 추세일 때: 히스토그램이 직전보다 커지면 진한색, 작아지면 연한색
if hist < hist
histColor := col_up
else
histColor := color.new(col_up, 50)
else
// 하락 추세일 때: 히스토그램이 직전보다 커지면(덜 음수면) 연한색, 작아지면 진한색
if hist < hist
histColor := color.new(col_dn, 50)
else
histColor := col_dn
plot(hist, title="Histogram", style=plot.style_columns, color=histColor)
// 4.5 기준선
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dotted)
Liquidity Trap Strategy - ATR OptimizedLiquidity Trap Strategy – Optimized Version
1. Overview
The Liquidity Trap Strategy is a high-probability price action trading system designed to exploit “trapped buyers or sellers” around key levels from the previous trading day.
Markets: Works on any market (Forex, Crypto, Futures, Indices, Stocks)
Timeframes: Designed for 15-minute (15m) and 1-hour (1H) charts
Trading Style: “Hunter” style — trades may not happen every day, but setups are high-probability
Trade Frequency: Only first trade per day is taken for simplicity and high quality
2. Key Components
a) Daily Levels
Previous Day High (PDH) and Previous Day Low (PDL) are automatically calculated using the prior day’s bar.
These are drawn as anchored horizontal lines, extending to the current day.
PDH/PDL act as key support/resistance zones — areas where liquidity is often trapped.
b) Trap Concept
The strategy is based on the “liquidity trap” principle:
Buyer Trap (Short Entry):
Price breaks above the previous day high (PDH) → buyers think price will continue higher.
Price reverses immediately below PDH, trapping aggressive buyers above the key level.
This creates selling pressure, giving an opportunity to enter short.
Seller Trap (Long Entry):
Price breaks below the previous day low (PDL) → sellers think price will continue lower.
Price reverses immediately above PDL, trapping aggressive sellers below the key level.
This creates buying pressure, giving an opportunity to enter long.
The key idea: trapped traders cause the market to move in the opposite direction of the breakout, creating high-probability moves.
c) Trade Execution Logic
Buyer Trap / Short Entry:
Condition: high > PDH AND close < PDH AND no trade taken yet today
Entry: Short at the close of the trap candle
Stop Loss: ATR-based above the trap candle high to avoid minor wick stops
Take Profit: 2:1 Risk-to-Reward ratio
Seller Trap / Long Entry:
Condition: low < PDL AND close > PDL AND no trade taken yet today
Entry: Long at the close of the trap candle
Stop Loss: ATR-based below the trap candle low
Take Profit: 2:1 Risk-to-Reward ratio
Only the first trap trade of the day is allowed to avoid overtrading.
d) Risk Management
Stop-Loss (SL):
ATR-based to account for market volatility
Ensures the trade survives minor wick sweeps without being stopped out prematurely
Take-Profit (TP):
Fixed 2:1 R:R relative to SL
Ensures each winning trade outweighs potential losses
Trade Frequency:
Only first trade per day is allowed, making it highly selective and reducing noise
3. Visual Features
PDH/PDL Lines: Anchored to previous day, extend into current day, color-coded:
PDH → Green
PDL → Red
Trade Labels: Placed on the trap candle:
Short → Red label “Short”
Long → Green label “Long”
The visual markers make it easy to identify exactly where the trap occurred and the trade was triggered.
4. How the Strategy Works – Step by Step
Example for Short (Buyer Trap):
Market opens, PDH/PDL from yesterday are drawn.
Price spikes above PDH → some buyers enter expecting breakout continuation.
Price immediately closes back below PDH, trapping buyers.
The strategy enters short at the close of the reversal candle.
SL: placed above the trap candle using ATR to give room
TP: calculated as 2x the risk (distance from entry to SL)
Trade executes — first trade of the day. Any further trap signals today are ignored.
Example for Long (Seller Trap):
Price drops below PDL → some sellers enter.
Price immediately closes back above PDL, trapping sellers.
Strategy enters long at the close of the reversal candle.
SL: below trap candle using ATR
TP: 2:1 R:R
Trade executes — only first trade of the day.
5. Why This Strategy Works
Exploits liquidity zones: Markets often hunt stops above PDH or below PDL.
High-probability reversals: Trapped traders create strong counter moves.
ATR SL: avoids being stopped by minor market noise or wick spikes.
Selective trading: Only first trade per day → reduces overtrading and noise.
Clear visual markers: Makes manual observation and confirmation easy.
6. Key Tips for Traders
Best on high-volume instruments like Forex majors, indices, or crypto pairs with decent liquidity.
Works well on 15m and 1H charts — 15m allows quicker signals, 1H filters noise.
Avoid trading around major news releases — traps can behave differently during high volatility events.
Always backtest and use the ATR SL — never reduce SL too much, otherwise stops will trigger before the real move.
✅ Summary:
The Liquidity Trap Strategy identifies trapped buyers/sellers using previous day highs/lows.
It uses ATR-adapted stops and 2:1 R:R TP.
Only first trade per day is executed, reducing false signals.
Anchored PDH/PDL lines and labels make trade opportunities clear.
This system is low-frequency, high-probability, focusing on trading smart rather than frequently.
Futures Calendar Spread Mean Reversion Strategyfutures calendar spread strategy:
Make sure you type in the correct spread in your chart
3 standard deviations for entry, with a stop at 4 standard deviations, seems to work best
don't select tp at mean
Use with energies and grains futures, anything very seasonal
jaems_Combo: StochRSI + MACD + ADX [QuantDev]//@version=6
strategy("jaems_Combo: StochRSI + MACD + ADX ", overlay=false, initial_capital=10000, currency=currency.USD, commission_type=strategy.commission.percent, commission_value=0.05, slippage=1)
// ==========================================
// 1. 사용자 입력 (User Inputs)
// ==========================================
//
grp_time = "Backtest Period"
useDateFilter = input.bool(true, "기간 필터 적용", group=grp_time)
startDate = input.time(timestamp("2023-01-01 00:00"), "시작일", group=grp_time)
endDate = input.time(timestamp("2099-12-31 23:59"), "종료일", group=grp_time)
inDateRange = not useDateFilter or (time >= startDate and time <= endDate)
//
grp_stoch = "1. Stochastic RSI Settings"
stoch_len = input.int(14, "RSI Length", group=grp_stoch)
stoch_k = input.int(3, "K", group=grp_stoch)
stoch_d = input.int(3, "D", group=grp_stoch)
rsi_len = input.int(14, "Stochastic Length", group=grp_stoch)
//
grp_macd = "2. MACD Settings (Normalized)"
macd_fast = input.int(12, "Fast Length", group=grp_macd)
macd_slow = input.int(26, "Slow Length", group=grp_macd)
macd_sig = input.int(9, "Signal Length", group=grp_macd)
macd_norm_len = input.int(100, "Normalization Lookback", group=grp_macd)
//
grp_adx = "3. ADX Settings"
adx_len = input.int(14, "ADX Smoothing", group=grp_adx)
di_len = input.int(14, "DI Length", group=grp_adx)
adx_thresh = input.int(25, "ADX Threshold", group=grp_adx)
//
grp_risk = "4. Risk Management"
stopLossPct = input.float(2.0, "손절매 (Stop Loss %)", step=0.1, group=grp_risk) / 100
takeProfitPct = input.float(4.0, "익절매 (Take Profit %)", step=0.1, group=grp_risk) / 100
// - 신규 추가 (Alert Configuration)
grp_alert = "5. Alert Configuration"
msg_long_entry = input.string("Long Entry Triggered", "Long 진입 메시지", group=grp_alert)
msg_short_entry = input.string("Short Entry Triggered", "Short 진입 메시지", group=grp_alert)
msg_long_exit = input.string("Long Position Closed", "Long 청산 메시지", group=grp_alert)
msg_short_exit = input.string("Short Position Closed", "Short 청산 메시지", group=grp_alert)
// ==========================================
// 2. 데이터 처리 및 지표 계산
// ==========================================
// Stoch RSI
rsi_val = ta.rsi(close, rsi_len)
k = ta.sma(ta.stoch(rsi_val, rsi_val, rsi_val, stoch_len), stoch_k)
d = ta.sma(k, stoch_d)
// ADX
= ta.dmi(di_len, adx_len)
// Normalized MACD (0~100 Scale)
= ta.macd(close, macd_fast, macd_slow, macd_sig)
highest_macd = ta.highest(macd_line, macd_norm_len)
lowest_macd = ta.lowest(macd_line, macd_norm_len)
// 분모가 0이 되는 예외 처리
denom = (highest_macd - lowest_macd)
norm_macd = denom != 0 ? (macd_line - lowest_macd) / denom * 100 : 50
norm_signal = denom != 0 ? (macd_signal - lowest_macd) / denom * 100 : 50
// ==========================================
// 3. 시각화 (Dark Mode Optimized Colors)
// ==========================================
color gridColor = color.new(#787B86, 50)
hline(0, "Bottom", color=gridColor)
hline(50, "Middle", color=gridColor, linestyle=hline.style_dotted)
hline(100, "Top", color=gridColor)
plot(k, "Stoch K", color=color.new(#00E5FF, 0), linewidth=1) // Neon Cyan
plot(d, "Stoch D", color=color.new(#EA00FF, 0), linewidth=1) // Neon Magenta
plot(adx, "ADX", color=color.new(#FFEB3B, 0), linewidth=2)
hline(adx_thresh, "ADX Threshold", color=color.new(#FFEB3B, 50), linestyle=hline.style_dashed)
plot(norm_macd, "Norm MACD", color=color.new(#76FF03, 60), style=plot.style_area)
plot(norm_signal, "Norm Signal", color=color.new(#FF1744, 20), linewidth=1)
// ==========================================
// 4. 전략 로직 (Strategy Logic) - 요청하신 내용으로 전면 수정
// ==========================================
// 조건: K가 D보다 크고(AND) K가 Norm Signal보다 큰 상태
bool is_bullish = (k > d) and (k > norm_signal)
// 조건: K가 D보다 작고(AND) K가 Norm Signal보다 작은 상태
bool is_bearish = (k < d) and (k < norm_signal)
// 진입 신호: "이전 봉에는 아니었는데, 지금 봉에서 두 조건을 동시에 만족했을 때" (돌파 순간)
longCondition = is_bullish and not is_bullish
shortCondition = is_bearish and not is_bearish
// 주문 실행 (Confirmed Bar Only) + Alert Message 연결
if inDateRange and barstate.isconfirmed
if longCondition
strategy.entry("Long", strategy.long, alert_message=msg_long_entry)
if shortCondition
strategy.entry("Short", strategy.short, alert_message=msg_short_entry)
// ==========================================
// 5. 청산 및 신호 강조 (Alert Message 추가)
// ==========================================
if strategy.position_size > 0
strategy.exit("Long Exit", "Long", stop=strategy.position_avg_price * (1 - stopLossPct), limit=strategy.position_avg_price * (1 + takeProfitPct), alert_message=msg_long_exit)
if strategy.position_size < 0
strategy.exit("Short Exit", "Short", stop=strategy.position_avg_price * (1 + stopLossPct), limit=strategy.position_avg_price * (1 - takeProfitPct), alert_message=msg_short_exit)
// 배경 신호
bgcolor(longCondition ? color.new(#76FF03, 90) : na, title="Long Signal BG")
bgcolor(shortCondition ? color.new(#FF1744, 90) : na, title="Short Signal BG")
Caja TavoStrategy based on "The Box" by Z and Scott
This strategy is based on measuring price volatility one hour before the market opens and half an hour after.
The trade is made in the direction that breaks the upper or lower limits.rior o inferior.
jaems_Double BB[Alert]/W-Bottom/Dashboard// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © Kingjmaes
//@version=6
strategy("jaems_Double BB /W-Bottom/Dashboard", shorttitle="jaems_Double BB /W-Bottom/Dashboard", overlay=true, commission_type=strategy.commission.percent, commission_value=0.05, slippage=1, process_orders_on_close=true)
// ==========================================
// 1. 사용자 입력 (Inputs)
// ==========================================
group_date = "📅 백테스트 기간 설정"
startTime = input.time(timestamp("2024-01-01 00:00"), "시작일", group=group_date)
endTime = input.time(timestamp("2099-12-31 23:59"), "종료일", group=group_date)
group_bb = "📊 더블 볼린저 밴드 설정"
bb_len = input.int(20, "길이 (Length)", minval=5, group=group_bb)
bb_mult_inner = input.float(1.0, "내부 밴드 승수 (Inner A)", step=0.1, group=group_bb)
bb_mult_outer = input.float(2.0, "외부 밴드 승수 (Outer B)", step=0.1, group=group_bb)
group_w = "📉 W 바닥 패턴 설정"
pivot_left = input.int(3, "피벗 좌측 봉 수", minval=1, group=group_w)
pivot_right = input.int(1, "피벗 우측 봉 수", minval=1, group=group_w)
group_dash = "🖥️ 대시보드 설정"
show_dash = input.bool(true, "대시보드 표시", group=group_dash)
comp_sym = input.symbol("NASDAQ:NDX", "비교 지수 (GS Trend)", group=group_dash, tooltip="S&P500은 'SP:SPX', 비트코인은 'BINANCE:BTCUSDT' 등을 입력하세요.")
rsi_len = input.int(14, "RSI 길이", group=group_dash)
group_risk = "🛡 리스크 관리"
use_sl_tp = input.bool(true, "손절/익절 사용", group=group_risk)
sl_pct = input.float(2.0, "손절매 (%)", step=0.1, group=group_risk) / 100
tp_pct = input.float(4.0, "익절매 (%)", step=0.1, group=group_risk) / 100
// ==========================================
// 2. 데이터 처리 및 계산 (Calculations)
// ==========================================
// 기간 필터
inDateRange = time >= startTime and time <= endTime
// 더블 볼린저 밴드
basis = ta.sma(close, bb_len)
dev_inner = ta.stdev(close, bb_len) * bb_mult_inner
dev_outer = ta.stdev(close, bb_len) * bb_mult_outer
upper_A = basis + dev_inner
lower_A = basis - dev_inner
upper_B = basis + dev_outer
lower_B = basis - dev_outer
percent_b = (close - lower_B) / (upper_B - lower_B)
// W 바닥형 (W-Bottom) - 리페인팅 방지
pl = ta.pivotlow(low, pivot_left, pivot_right)
var float p1_price = na
var float p1_pb = na
var float p2_price = na
var float p2_pb = na
var bool is_w_setup = false
if not na(pl)
p1_price := p2_price
p1_pb := p2_pb
p2_price := low
p2_pb := percent_b
// 패턴 감지
bool cond_w = (p1_price < lower_B ) and (p2_price > p1_price) and (p2_pb > p1_pb)
is_w_setup := cond_w ? true : false
w_bottom_signal = is_w_setup and close > open and close > lower_A
if w_bottom_signal
is_w_setup := false
// GS 트렌드 (나스닥 상대 강도)
ndx_close = request.security(comp_sym, timeframe.period, close)
rs_ratio = close / ndx_close
rs_sma = ta.sma(rs_ratio, 20)
gs_trend_bull = rs_ratio > rs_sma
// RSI & MACD
rsi_val = ta.rsi(close, rsi_len)
= ta.macd(close, 12, 26, 9)
macd_bull = macd_line > signal_line
// ==========================================
// 3. 전략 로직 (Strategy Logic)
// ==========================================
long_cond = (ta.crossover(close, lower_A) or ta.crossover(close, basis) or w_bottom_signal) and inDateRange and barstate.isconfirmed
short_cond = (ta.crossunder(close, upper_B) or ta.crossunder(close, upper_A) or ta.crossunder(close, basis)) and inDateRange and barstate.isconfirmed
// 진입 실행 및 알람 발송
if long_cond
strategy.entry("Long", strategy.long, comment="Entry Long")
alert("Long Entry Triggered | Price: " + str.tostring(close), alert.freq_once_per_bar_close)
if short_cond
strategy.entry("Short", strategy.short, comment="Entry Short")
alert("Short Entry Triggered | Price: " + str.tostring(close), alert.freq_once_per_bar_close)
// 청산 실행
if use_sl_tp
if strategy.position_size > 0
strategy.exit("Exit Long", "Long", stop=strategy.position_avg_price * (1 - sl_pct), limit=strategy.position_avg_price * (1 + tp_pct), comment_loss="L-SL", comment_profit="L-TP")
if strategy.position_size < 0
strategy.exit("Exit Short", "Short", stop=strategy.position_avg_price * (1 + sl_pct), limit=strategy.position_avg_price * (1 - tp_pct), comment_loss="S-SL", comment_profit="S-TP")
// 별도 알람: W 패턴 감지 시
if w_bottom_signal
alert("W-Bottom Pattern Detected!", alert.freq_once_per_bar_close)
// ==========================================
// 4. 대시보드 시각화 (Dashboard Visualization)
// ==========================================
c_bg_head = color.new(color.black, 20)
c_bg_cell = color.new(color.black, 40)
c_text = color.white
c_bull = color.new(#00E676, 0)
c_bear = color.new(#FF5252, 0)
c_neu = color.new(color.gray, 30)
get_trend_color(is_bull) => is_bull ? c_bull : c_bear
get_pos_text() => strategy.position_size > 0 ? "LONG 🟢" : strategy.position_size < 0 ? "SHORT 🔴" : "FLAT ⚪"
get_pos_color() => strategy.position_size > 0 ? c_bull : strategy.position_size < 0 ? c_bear : c_neu
var table dash = table.new(position.top_right, 2, 7, border_width=1, border_color=color.gray, frame_color=color.gray, frame_width=1)
if show_dash and (barstate.islast or barstate.islastconfirmedhistory)
table.cell(dash, 0, 0, "METRIC", bgcolor=c_bg_head, text_color=c_text, text_size=size.small)
table.cell(dash, 1, 0, "STATUS", bgcolor=c_bg_head, text_color=c_text, text_size=size.small)
table.cell(dash, 0, 1, "GS Trend", bgcolor=c_bg_cell, text_color=c_text, text_halign=text.align_left, text_size=size.small)
table.cell(dash, 1, 1, gs_trend_bull ? "Bullish" : "Bearish", bgcolor=c_bg_cell, text_color=get_trend_color(gs_trend_bull), text_size=size.small)
rsi_col = rsi_val > 70 ? c_bear : rsi_val < 30 ? c_bull : c_neu
table.cell(dash, 0, 2, "RSI (14)", bgcolor=c_bg_cell, text_color=c_text, text_halign=text.align_left, text_size=size.small)
table.cell(dash, 1, 2, str.tostring(rsi_val, "#.##"), bgcolor=c_bg_cell, text_color=rsi_col, text_size=size.small)
table.cell(dash, 0, 3, "MACD", bgcolor=c_bg_cell, text_color=c_text, text_halign=text.align_left, text_size=size.small)
table.cell(dash, 1, 3, macd_bull ? "Bullish" : "Bearish", bgcolor=c_bg_cell, text_color=get_trend_color(macd_bull), text_size=size.small)
w_status = w_bottom_signal ? "DETECTED!" : is_w_setup ? "Setup Ready" : "Waiting"
w_col = w_bottom_signal ? c_bull : is_w_setup ? color.yellow : c_neu
table.cell(dash, 0, 4, "W-Bottoms", bgcolor=c_bg_cell, text_color=c_text, text_halign=text.align_left, text_size=size.small)
table.cell(dash, 1, 4, w_status, bgcolor=c_bg_cell, text_color=w_col, text_size=size.small)
table.cell(dash, 0, 5, "Position", bgcolor=c_bg_cell, text_color=c_text, text_halign=text.align_left, text_size=size.small)
table.cell(dash, 1, 5, get_pos_text(), bgcolor=c_bg_cell, text_color=get_pos_color(), text_size=size.small)
last_sig = long_cond ? "BUY SIGNAL" : short_cond ? "SELL SIGNAL" : "HOLD"
last_col = long_cond ? c_bull : short_cond ? c_bear : c_neu
table.cell(dash, 0, 6, "Signal", bgcolor=c_bg_cell, text_color=c_text, text_halign=text.align_left, text_size=size.small)
table.cell(dash, 1, 6, last_sig, bgcolor=c_bg_cell, text_color=last_col, text_size=size.small)
// ==========================================
// 5. 시각화 (Visualization)
// ==========================================
p_upper_B = plot(upper_B, "Upper B", color=color.new(color.red, 50))
p_upper_A = plot(upper_A, "Upper A", color=color.new(color.red, 0))
p_basis = plot(basis, "Basis", color=color.gray)
p_lower_A = plot(lower_A, "Lower A", color=color.new(color.green, 0))
p_lower_B = plot(lower_B, "Lower B", color=color.new(color.green, 50))
fill(p_upper_B, p_upper_A, color=color.new(color.red, 90))
fill(p_lower_A, p_lower_B, color=color.new(color.green, 90))
plotshape(long_cond, title="Long", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(short_cond, title="Short", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
james S/R Trend Pro v6//@version=6
strategy("james S/R Trend Pro v6", overlay=true,
initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
commission_type=strategy.commission.percent,
commission_value=0.05,
slippage=1)
// --- 사용자 입력 (Inputs) ---
group_date = "1. 백테스트 기간"
start_date = input.time(timestamp("2024-01-01 00:00:00"), "시작일", group=group_date)
end_date = input.time(timestamp("2026-12-31 23:59:59"), "종료일", group=group_date)
is_within_date = time >= start_date and time <= end_date
group_main = "2. 지표 설정 (S/R & Trend)"
lookback_sr = input.int(15, "지지/저항 탐색 기간", minval=5, group=group_main)
atr_period = input.int(14, "ATR 기간", group=group_main)
atr_mult = input.float(3.5, "추세선 민감도", step=0.1, group=group_main)
group_color = "3. 다크모드 색상 설정"
trend_up_color = input.color(color.rgb(200, 200, 200), "상승 추세선 (밝은 회색)", group=group_color)
trend_down_color = input.color(color.rgb(255, 255, 255), "하락 추세선 (흰색)", group=group_color)
res_color = input.color(#ff1100, "저항선 (네온 레드)", group=group_color)
sup_color = input.color(#00e1ff, "지지선 (네온 사이언)", group=group_color)
// --- 데이터 처리 (Calculations) ---
// 1. 추세선 (검은색 배경용 고대비 설정)
= ta.supertrend(atr_mult, atr_period)
// 2. 지지/저항선 (피벗 기반)
ph = ta.pivothigh(high, lookback_sr, lookback_sr)
pl = ta.pivotlow(low, lookback_sr, lookback_sr)
var float res_line = na
var float sup_line = na
if not na(ph)
res_line := high
if not na(pl)
sup_line := low
// --- 전략 로직 (Condition) ---
long_condition = direction < 0 and ta.crossover(close, sup_line)
short_condition = direction > 0 and ta.crossunder(close, res_line)
// --- 주문 실행 (Execution) ---
if is_within_date
if long_condition
strategy.entry("Long", strategy.long, comment="BUY")
if short_condition
strategy.entry("Short", strategy.short, comment="SHORT")
// 청산 로직
if strategy.position_size > 0
strategy.exit("TP-L", "Long", limit=res_line, qty_percent=50, comment="분할익절")
if ta.crossunder(close, trend_line)
strategy.close("Long", comment="추세이탈")
if strategy.position_size < 0
strategy.exit("TP-S", "Short", limit=sup_line, qty_percent=50, comment="분할익절")
if ta.crossover(close, trend_line)
strategy.close("Short", comment="추세이탈")
// --- 시각화 (Visualization - 다크 모드 최적화) ---
// 1. 추세선: 검은 배경에서 잘 보이도록 하얀색/회색 계열 사용
plot(trend_line, color=direction < 0 ? trend_up_color : trend_down_color, linewidth=2, title="Trend Line")
// 2. 지지/저항선: 네온 컬러로 시인성 극대화
plot(res_line, color=color.new(res_color, 0), style=plot.style_linebr, linewidth=2, title="Resistance")
plot(sup_line, color=color.new(sup_color, 0), style=plot.style_linebr, linewidth=2, title="Support")
// 3. 진입 시그널 라벨
plotshape(long_condition, style=shape.triangleup, location=location.belowbar, color=sup_color, size=size.small, title="Buy Label")
plotshape(short_condition, style=shape.triangledown, location=location.abovebar, color=res_color, size=size.small, title="Short Label")
// 4. 추세 배경색 (매우 옅게 설정하여 캔들을 방해하지 않음)
fill_color = direction < 0 ? color.new(sup_color, 90) : color.new(res_color, 90)
fill(plot(trend_line), plot(close), color=fill_color, title="Trend Fill")
Bar-Close Confirmed SupertrendOverview
This indicator is a Supertrend-style trend follower that confirms direction changes only after a bar closes. Trend flips are determined using the previous bar’s close relative to the bands, which helps avoid intrabar changes during live candles.
How it works
Computes ATR (Average True Range)
Builds upper/lower bands using ATR and a multiplier
Updates trend direction only when a prior candle confirms a break of the band
Confirmation logic (bar-close based)
Trend direction is updated using conditions based on the previous candle, such as:
close > upper → confirm uptrend
close < lower → confirm downtrend
Because signals are confirmed on the prior bar, trend changes and markers are displayed only when confirmation exists.
Signals
Uptrend confirmation: prior candle closes above the upper band → bullish marker
Downtrend confirmation: prior candle closes below the lower band → bearish marker
Inputs
ATR Length (default 10)
ATR Multiplier (default 3.0)
Notes
This script is intended for bar-close workflows. Behavior and responsiveness may differ across markets and timeframes depending on volatility and chosen settings.
15m Pivot HL/LH EMA + ATR StrategyFor Pivots Traders
I found that pivot trading make the BIG profits,
if you think so, use this script
UT Bot TP1 TP2 Optional BE 1min XAUUSD TradeThis custom trading bot is designed for scalping XAUUSD on the 1-minute timeframe. It uses a proprietary strategy combining momentum and volatility signals to identify short-term entry and exit opportunities. The bot aims to capture fast price movements while applying strict risk management rules. Optimized for high-frequency gold trading under real-time market conditions.
If you want, I can also give you a more aggressive, more professional, or more simple version.
OFM - ONE Trade Per Day MAXthis is helper to clarify the market trend and supply and demand zones to work with enjoy!
Strategy EMA trend & MACD 5m-15mStrategy using multiple EMAs as a trend & MACD as a signal, using 5m and 15m timeframe, 5m is a main timeframe.
SMA Crossover StrategyThis is a simple Multiple SMA Crossover strategy that works wonders with alpha stocks, ETF, Indices and Bees.
Apply on monthly and quarterly charts and reap better, bigger rewards - You will be able to beat the index returns.
Wish you all success
Do follow me in youtube channel name MyBillioninc
VWAP 2nd stdev Mean Reversion StrategyThis strategy is based on the daily WVAP 2nd dev reversion.
The idea is to take a trade on the 2nd dev touch with the WVAP itself as a target.
The WVAP should be flat.
For daily trade only.
Use for ES/MES on the 1-minute timeframe.
TJR asia session sweep//@version=5
strategy("TJR asia session sweep", "TJR Asia Sweep", overlay=true, max_lines_count=500, max_labels_count=500)
// Input settings
show_asian = input.bool(true, "Show Asian Session", group="Visual Settings")
show_london = input.bool(true, "Show London Session", group="Visual Settings")
show_swing_points = input.bool(true, "Show Asian Swing Points", group="Visual Settings")
show_market_structure = input.bool(true, "Show Market Structure", group="Visual Settings")
show_bos = input.bool(true, "Show Break of Structure", group="Visual Settings")
// Session Time Settings
asian_start_hour_input = input.int(22, "Asian Session Start Hour", minval=0, maxval=23, group="Session Times")
asian_end_hour_input = input.int(3, "Asian Session End Hour", minval=0, maxval=23, group="Session Times")
london_start_hour_input = input.int(3, "London Session Start Hour", minval=0, maxval=23, group="Session Times")
london_end_hour_input = input.int(8, "London Session End Hour", minval=0, maxval=23, group="Session Times")
session_timezone = input.string("America/New_York", "Session Timezone", options= , group="Session Times")
// Risk Management Settings
use_atr_sl = input.bool(false, "Use ATR Multiplier for Stop Loss", group="Risk Management")
atr_length = input.int(14, "ATR Length", minval=1, maxval=50, group="Risk Management")
atr_multiplier = input.float(2.0, "ATR Multiplier for Stop Loss", minval=0.5, maxval=10.0, group="Risk Management")
force_london_close = input.bool(true, "Force Close at London Session End", group="Risk Management")
cutoff_minutes = input.int(60, "Minutes Before Session End to Stop New Trades", minval=0, maxval=300, group="Risk Management")
// Position Sizing Settings
position_sizing_method = input.string("USD Risk", "Position Sizing Method", options= , group="Position Sizing")
usd_risk_per_trade = input.float(100.0, "USD Risk Per Trade", minval=1.0, maxval=10000.0, group="Position Sizing")
fixed_contracts = input.float(1.0, "Fixed Number of Contracts", minval=0.01, maxval=1000.0, step=0.01, group="Position Sizing")
// Color settings
asian_color = input.color(color.red, "Asian Session Color")
london_color = input.color(color.blue, "London Session Color")
swing_high_color = input.color(color.orange, "Swing High Color")
swing_low_color = input.color(color.lime, "Swing Low Color")
bullish_structure_color = input.color(color.green, "Bullish Structure Color")
bearish_structure_color = input.color(color.red, "Bearish Structure Color")
bos_color = input.color(color.orange, "Break of Structure Color")
// Line settings
line_width = input.int(2, "Line Width", minval=1, maxval=5)
// ATR calculation for stop loss
atr = ta.atr(atr_length)
// Position size calculation function
calculate_position_size(entry_price, stop_loss_price) =>
var float position_size = na
if position_sizing_method == "Fixed Contracts"
position_size := fixed_contracts
else // USD Risk method
stop_distance = math.abs(entry_price - stop_loss_price)
if stop_distance > 0
// Calculate position size based on USD risk per trade
// For forex: position_size = risk_amount / (stop_distance * point_value)
// For most forex pairs, point value = 1 (since we're dealing with price differences directly)
position_size := usd_risk_per_trade / stop_distance
else
position_size := fixed_contracts // Fallback to fixed contracts if stop distance is 0
position_size
// Session time definitions (using input variables)
asian_start_hour = asian_start_hour_input
asian_end_hour = asian_end_hour_input
london_start_hour = london_start_hour_input
london_end_hour = london_end_hour_input
// Get current hour using selected timezone
current_hour = hour(time, session_timezone)
// Previous hour for transition detection
prev_hour = hour(time , session_timezone)
// Session transition detection
asian_start = current_hour == asian_start_hour and prev_hour != asian_start_hour
asian_end = current_hour == asian_end_hour and prev_hour != asian_end_hour
london_start = current_hour == london_start_hour and prev_hour != london_start_hour
london_end = current_hour == london_end_hour and prev_hour != london_end_hour
// Session activity detection
asian_active = (current_hour >= asian_start_hour) or (current_hour < asian_end_hour)
london_active = (current_hour >= london_start_hour) and (current_hour < london_end_hour)
// Session boxes - keep previous sessions visible
var box asian_session_box = na
var box london_session_box = na
// Create Asian session box
if show_asian and asian_start
// Create new box at session start (previous box remains visible)
asian_session_box := box.new(bar_index, high, bar_index + 1, low,
border_color=asian_color, bgcolor=color.new(asian_color, 90),
border_width=2, border_style=line.style_solid)
// Pre-calculate session highs and lows for consistency
asian_session_length = asian_active and not na(asian_session_box) ? bar_index - box.get_left(asian_session_box) + 1 : 1
current_asian_high = ta.highest(high, asian_session_length)
current_asian_low = ta.lowest(low, asian_session_length)
// Update Asian session box continuously during session
if show_asian and asian_active and not na(asian_session_box)
box.set_right(asian_session_box, bar_index)
// Update box to contain session highs and lows
box.set_top(asian_session_box, current_asian_high)
box.set_bottom(asian_session_box, current_asian_low)
// Create London session box
if show_london and london_start
// Create new box at session start (previous box remains visible)
london_session_box := box.new(bar_index, high, bar_index + 1, low,
border_color=london_color, bgcolor=color.new(london_color, 90),
border_width=2, border_style=line.style_solid)
// Pre-calculate London session highs and lows for consistency
london_session_length = london_active and not na(london_session_box) ? bar_index - box.get_left(london_session_box) + 1 : 1
current_london_high = ta.highest(high, london_session_length)
current_london_low = ta.lowest(low, london_session_length)
// Update London session box continuously during session
if show_london and london_active and not na(london_session_box)
box.set_right(london_session_box, bar_index)
// Update box to contain session highs and lows
box.set_top(london_session_box, current_london_high)
box.set_bottom(london_session_box, current_london_low)
// Asian Session Swing Points Detection
var float asian_session_high = na
var float asian_session_low = na
var int asian_high_bar = na
var int asian_low_bar = na
// Asian Session Absolute High/Low for TP levels
var float asian_absolute_high = na
var float asian_absolute_low = na
var line asian_high_line = na
var line asian_low_line = na
var label asian_high_label = na
var label asian_low_label = na
var bool high_broken = false
var bool low_broken = false
// London Session High/Low tracking for stop loss
var float london_session_high = na
var float london_session_low = na
// Market structure tracking variables
var string breakout_direction = na // "bullish" or "bearish"
var float last_hh_level = na // Last Higher High level
var float last_hl_level = na // Last Higher Low level
var float last_ll_level = na // Last Lower Low level
var float last_lh_level = na // Last Lower High level
var int structure_count = 0
var string last_structure_type = na // "HH", "HL", "LL", "LH"
// Legacy variables for compatibility
var float last_swing_high = na
var float last_swing_low = na
var int last_high_bar = na
var int last_low_bar = na
// Market structure state tracking
var float pending_high = na
var float pending_low = na
var int pending_high_bar = na
var int pending_low_bar = na
var bool waiting_for_confirmation = false
// Break of Structure tracking variables
var float most_recent_hl = na
var float most_recent_lh = na
var int most_recent_hl_bar = na
var int most_recent_lh_bar = na
var bool bos_detected = false
// Trading variables
var bool trade_taken = false
// Trade visualization boxes (based on Casper strategy approach)
var box current_profit_box = na
var box current_sl_box = na
// Update swing points during Asian session
if asian_active and show_swing_points
// Always track absolute high/low for both TP levels and breakout detection
if na(asian_absolute_high) or high > asian_absolute_high
asian_absolute_high := high
if na(asian_absolute_low) or low < asian_absolute_low
asian_absolute_low := low
// Use absolute high/low for breakout levels (simplified logic)
if na(asian_session_high) or high > asian_session_high
asian_session_high := high
asian_high_bar := bar_index
if na(asian_session_low) or low < asian_session_low
asian_session_low := low
asian_low_bar := bar_index
// Track London session high/low for stop loss levels
if london_active
if na(london_session_high) or high > london_session_high
london_session_high := high
if na(london_session_low) or low < london_session_low
london_session_low := low
// Draw initial lines when Asian session ends
if asian_end and show_swing_points
if not na(asian_session_high) and not na(asian_high_bar)
// Draw extending line for high
asian_high_line := line.new(asian_high_bar, asian_session_high, bar_index + 200, asian_session_high,
color=swing_high_color, width=2, style=line.style_dashed, extend=extend.right)
asian_high_label := label.new(bar_index + 5, asian_session_high, "Asian High: " + str.tostring(asian_session_high, "#.####"), style=label.style_label_left, color=swing_high_color, textcolor=color.white, size=size.small)
if not na(asian_session_low) and not na(asian_low_bar)
// Draw extending line for low
asian_low_line := line.new(asian_low_bar, asian_session_low, bar_index + 200, asian_session_low,
color=swing_low_color, width=2, style=line.style_dashed, extend=extend.right)
asian_low_label := label.new(bar_index + 5, asian_session_low, "Asian Low: " + str.tostring(asian_session_low, "#.####"), style=label.style_label_left, color=swing_low_color, textcolor=color.white, size=size.small)
// Reset break flags for new session
high_broken := false
low_broken := false
// Check for breakouts during London session
if london_active and show_swing_points and not na(asian_session_high) and not na(asian_session_low)
// Check if Asian high is broken
if not high_broken and not low_broken and high > asian_session_high
high_broken := true
// Update high line to end at break point
if not na(asian_high_line)
line.set_x2(asian_high_line, bar_index)
line.set_extend(asian_high_line, extend.none)
// Remove the low line (first break wins)
if not na(asian_low_line)
line.delete(asian_low_line)
if not na(asian_low_label)
label.delete(asian_low_label)
// Add break marker
label.new(bar_index, asian_session_high * 1.001, "HIGH BREAK!",
style=label.style_label_down, color=color.red, textcolor=color.white, size=size.normal)
// Set breakout direction and initialize structure tracking
breakout_direction := "bullish"
last_swing_high := asian_session_high
last_swing_low := asian_session_low
last_high_bar := bar_index
structure_count := 0
// Check if Asian low is broken
if not low_broken and not high_broken and low < asian_session_low
low_broken := true
// Update low line to end at break point
if not na(asian_low_line)
line.set_x2(asian_low_line, bar_index)
line.set_extend(asian_low_line, extend.none)
// Remove the high line (first break wins)
if not na(asian_high_line)
line.delete(asian_high_line)
if not na(asian_high_label)
label.delete(asian_high_label)
// Add break marker
label.new(bar_index, asian_session_low * 0.999, "LOW BREAK!",
style=label.style_label_up, color=color.red, textcolor=color.white, size=size.normal)
// Set breakout direction and initialize structure tracking
breakout_direction := "bearish"
last_swing_high := asian_session_high
last_swing_low := asian_session_low
last_low_bar := bar_index
structure_count := 0
// Stop extending lines when London session ends (if not already broken)
if london_end and show_swing_points
if not high_broken and not na(asian_high_line)
line.set_x2(asian_high_line, bar_index)
line.set_extend(asian_high_line, extend.none)
if not low_broken and not na(asian_low_line)
line.set_x2(asian_low_line, bar_index)
line.set_extend(asian_low_line, extend.none)
// Force close all trades at London session end (if enabled)
if london_end and force_london_close
if strategy.position_size != 0
// Extend boxes immediately before session close to prevent timing issues
if not na(current_profit_box)
// Ensure minimum 8 bars width or extend to current bar, whichever is longer
box_left = box.get_left(current_profit_box)
min_right = box_left + 8
final_right = math.max(min_right, bar_index)
box.set_right(current_profit_box, final_right)
current_profit_box := na // Clear reference after extending
if not na(current_sl_box)
// Ensure minimum 8 bars width or extend to current bar, whichever is longer
box_left = box.get_left(current_sl_box)
min_right = box_left + 8
final_right = math.max(min_right, bar_index)
box.set_right(current_sl_box, final_right)
current_sl_box := na // Clear reference after extending
strategy.close_all(comment="London Close")
trade_taken := false // Reset trade flag for next session
// Market structure detection after breakout (only during London session and before first BoS)
if show_market_structure and not na(breakout_direction) and london_active and not bos_detected
// Bullish structure tracking (HH, HL alternating)
if breakout_direction == "bullish"
// Check for Higher High pattern: Bullish candle followed by bearish candle
pattern_high = math.max(high , high)
prev_hh = na(last_hh_level) ? last_swing_high : last_hh_level
// HH Detection: Only if we expect HH next (no last structure or last was HL)
if (na(last_structure_type) or last_structure_type == "HL") and close > open and close < open and pattern_high > prev_hh and close > prev_hh
// Check consolidation
is_too_close = not na(last_high_bar) and (bar_index - last_high_bar) <= 4
should_create_hh = true
if is_too_close and structure_count > 0 and pattern_high <= last_hh_level
should_create_hh := false
if should_create_hh
structure_count := structure_count + 1
label.new(bar_index - 1, high + (high * 0.0003), "HH" + str.tostring(structure_count),
style=label.style_none, color=color.new(color.white, 100),
textcolor=color.white, size=size.small)
last_hh_level := pattern_high
last_swing_high := pattern_high
last_high_bar := bar_index
last_structure_type := "HH"
// HL Detection: Only if we expect HL next (last was HH)
pattern_low = math.min(low , low)
prev_hl = na(last_hl_level) ? last_swing_low : last_hl_level
if last_structure_type == "HH" and close < open and close > open and pattern_low > prev_hl and close > prev_hl
// Check consolidation
is_too_close = not na(last_low_bar) and (bar_index - last_low_bar) <= 4
should_create_hl = true
if is_too_close and pattern_low <= last_hl_level
should_create_hl := false
if should_create_hl
structure_count := structure_count + 1
label.new(bar_index - 1, low - (low * 0.0003), "HL" + str.tostring(structure_count),
style=label.style_none, color=color.new(color.white, 100),
textcolor=color.white, size=size.small)
last_hl_level := pattern_low
most_recent_hl := pattern_low // Update most recent HL for BoS detection
most_recent_hl_bar := bar_index - 1 // Store HL bar position
last_low_bar := bar_index
last_structure_type := "HL"
// Bearish structure tracking (LL, LH alternating)
if breakout_direction == "bearish"
// Check for Lower Low pattern: Bearish candle followed by bullish candle
pattern_low = math.min(low , low)
prev_ll = na(last_ll_level) ? last_swing_low : last_ll_level
// LL Detection: Only if we expect LL next (no last structure or last was LH)
if (na(last_structure_type) or last_structure_type == "LH") and close < open and close > open and pattern_low < prev_ll and close < prev_ll
// Check consolidation
is_too_close = not na(last_low_bar) and (bar_index - last_low_bar) <= 4
should_create_ll = true
if is_too_close and structure_count > 0 and pattern_low >= last_ll_level
should_create_ll := false
if should_create_ll
structure_count := structure_count + 1
label.new(bar_index - 1, low - (low * 0.0003), "LL" + str.tostring(structure_count),
style=label.style_none, color=color.new(color.white, 100),
textcolor=color.white, size=size.small)
last_ll_level := pattern_low
last_swing_low := pattern_low
last_low_bar := bar_index
last_structure_type := "LL"
// LH Detection: Only if we expect LH next (last was LL)
pattern_high = math.max(high , high)
prev_lh = na(last_lh_level) ? last_swing_high : last_lh_level
if last_structure_type == "LL" and close > open and close < open and pattern_high < prev_lh and close < prev_lh
// Check consolidation
is_too_close = not na(last_high_bar) and (bar_index - last_high_bar) <= 4
should_create_lh = true
if is_too_close and pattern_high >= last_lh_level
should_create_lh := false
if should_create_lh
structure_count := structure_count + 1
label.new(bar_index - 1, high + (high * 0.0003), "LH" + str.tostring(structure_count),
style=label.style_none, color=color.new(color.white, 100),
textcolor=color.white, size=size.small)
last_lh_level := pattern_high
most_recent_lh := pattern_high // Update most recent LH for BoS detection
most_recent_lh_bar := bar_index - 1 // Store LH bar position
last_high_bar := bar_index
last_structure_type := "LH"
// Check if we're within the cutoff period before London session end
current_minute = minute(time, session_timezone)
london_end_time_minutes = london_end_hour * 60 // Convert London end hour to minutes
current_time_minutes = current_hour * 60 + current_minute // Current time in minutes
// Calculate minutes remaining in London session
london_session_minutes_remaining = london_end_time_minutes - current_time_minutes
// Handle day rollover case (e.g., if london_end is 8:00 (480 min) and current is 23:30 (1410 min))
if london_session_minutes_remaining < 0
london_session_minutes_remaining := london_session_minutes_remaining + (24 * 60) // Add 24 hours in minutes
// Only allow trades if more than cutoff_minutes remaining in London session
allow_new_trades = london_session_minutes_remaining > cutoff_minutes
// Break of Structure (BoS) Detection and Trading Logic - Only first BoS per London session and outside cutoff period
if show_bos and london_active and show_market_structure and not bos_detected and not trade_taken and allow_new_trades
// Bullish BoS: Price closes below the most recent HL (after bullish breakout) - SELL SIGNAL
if breakout_direction == "bullish" and not na(most_recent_hl) and not na(most_recent_hl_bar)
// Check minimum distance requirement (at least 4 candles between BoS and HL)
if close < most_recent_hl and (bar_index - most_recent_hl_bar) >= 4
// Draw dotted line from HL position to BoS point
line.new(most_recent_hl_bar, most_recent_hl, bar_index, most_recent_hl,
color=bos_color, width=2, style=line.style_dotted, extend=extend.none)
// Calculate center position for BoS label
center_bar = math.round((most_recent_hl_bar + bar_index) / 2)
// Draw BoS label below the line for HL break
label.new(center_bar, most_recent_hl - (most_recent_hl * 0.0005), "BoS",
style=label.style_none, color=color.new(color.white, 100),
textcolor=bos_color, size=size.normal)
// SELL ENTRY
if not na(london_session_high) and not na(asian_absolute_low)
// Calculate stop loss based on settings
stop_loss_level = use_atr_sl ? close + (atr * atr_multiplier) : london_session_high
take_profit_level = asian_absolute_low
entry_price = close
// Calculate position size based on user settings
position_size = calculate_position_size(entry_price, stop_loss_level)
strategy.entry("SELL", strategy.short, qty=position_size, comment="BoS Sell")
strategy.exit("SELL EXIT", "SELL", stop=stop_loss_level, limit=take_profit_level, comment="SL/TP")
// Create trade visualization boxes (TradingView style) - minimum 8 bars width
// Blue profit zone box (from entry to take profit)
current_profit_box := box.new(left=bar_index, top=take_profit_level, right=bar_index + 8, bottom=entry_price,
bgcolor=color.new(color.blue, 70), border_width=0)
// Red stop loss zone box (from entry to stop loss)
current_sl_box := box.new(left=bar_index, top=entry_price, right=bar_index + 8, bottom=stop_loss_level,
bgcolor=color.new(color.red, 70), border_width=0)
trade_taken := true
bos_detected := true // Mark BoS as detected for this session
// Bearish BoS: Price closes above the most recent LH (after bearish breakout) - BUY SIGNAL
if breakout_direction == "bearish" and not na(most_recent_lh) and not na(most_recent_lh_bar)
// Check minimum distance requirement (at least 4 candles between BoS and LH)
if close > most_recent_lh and (bar_index - most_recent_lh_bar) >= 4
// Draw dotted line from LH position to BoS point
line.new(most_recent_lh_bar, most_recent_lh, bar_index, most_recent_lh,
color=bos_color, width=1, style=line.style_dotted, extend=extend.none)
// Calculate center position for BoS label
center_bar = math.round((most_recent_lh_bar + bar_index) / 2)
// Draw BoS label above the line for LH break
label.new(center_bar, most_recent_lh + (most_recent_lh * 0.0005), "BoS",
style=label.style_none, color=color.new(color.white, 100),
textcolor=bos_color, size=size.normal)
// BUY ENTRY
if not na(london_session_low) and not na(asian_absolute_high)
// Calculate stop loss based on settings
stop_loss_level = use_atr_sl ? close - (atr * atr_multiplier) : london_session_low
take_profit_level = asian_absolute_high
entry_price = close
// Calculate position size based on user settings
position_size = calculate_position_size(entry_price, stop_loss_level)
strategy.entry("BUY", strategy.long, qty=position_size, comment="BoS Buy")
strategy.exit("BUY EXIT", "BUY", stop=stop_loss_level, limit=take_profit_level, comment="SL/TP")
// Create trade visualization boxes (TradingView style) - minimum 8 bars width
// Blue profit zone box (from entry to take profit)
current_profit_box := box.new(left=bar_index, top=entry_price, right=bar_index + 8, bottom=take_profit_level,
bgcolor=color.new(color.blue, 70), border_width=0)
// Red stop loss zone box (from entry to stop loss)
current_sl_box := box.new(left=bar_index, top=stop_loss_level, right=bar_index + 8, bottom=entry_price,
bgcolor=color.new(color.red, 70), border_width=0)
trade_taken := true
bos_detected := true // Mark BoS as detected for this session
// Position close detection for extending boxes (based on Casper strategy)
if barstate.isconfirmed and strategy.position_size == 0 and strategy.position_size != 0
// Extend trade visualization boxes to exact exit point when position closes
if not na(current_profit_box)
// Ensure minimum 8 bars width or extend to current bar, whichever is longer
box_left = box.get_left(current_profit_box)
min_right = box_left + 8
final_right = math.max(min_right, bar_index)
box.set_right(current_profit_box, final_right)
current_profit_box := na // Clear reference after extending
if not na(current_sl_box)
// Ensure minimum 8 bars width or extend to current bar, whichever is longer
box_left = box.get_left(current_sl_box)
min_right = box_left + 8
final_right = math.max(min_right, bar_index)
box.set_right(current_sl_box, final_right)
current_sl_box := na // Clear reference after extending
// Backup safety check - extend boxes if position is closed but boxes still active
if not na(current_profit_box) and strategy.position_size == 0
box_left = box.get_left(current_profit_box)
min_right = box_left + 8
final_right = math.max(min_right, bar_index)
box.set_right(current_profit_box, final_right)
current_profit_box := na
if not na(current_sl_box) and strategy.position_size == 0
box_left = box.get_left(current_sl_box)
min_right = box_left + 8
final_right = math.max(min_right, bar_index)
box.set_right(current_sl_box, final_right)
current_sl_box := na
// Reset everything when new Asian session starts
if asian_start and show_swing_points
asian_session_high := na
asian_session_low := na
asian_high_bar := na
asian_low_bar := na
// Reset absolute levels
asian_absolute_high := na
asian_absolute_low := na
asian_high_line := na
asian_low_line := na
asian_high_label := na
asian_low_label := na
high_broken := false
low_broken := false
// Reset London session levels
london_session_high := na
london_session_low := na
// Reset market structure tracking
breakout_direction := na
last_hh_level := na
last_hl_level := na
last_ll_level := na
last_lh_level := na
last_swing_high := na
last_swing_low := na
last_high_bar := na
last_low_bar := na
structure_count := 0
last_structure_type := na
pending_high := na
pending_low := na
pending_high_bar := na
pending_low_bar := na
waiting_for_confirmation := false
// Reset BoS tracking
most_recent_hl := na
most_recent_lh := na
most_recent_hl_bar := na
most_recent_lh_bar := na
bos_detected := false
// Reset trading
trade_taken := false
// Reset current trade boxes
current_profit_box := na
current_sl_box := na
// Debug info (optional)
show_debug = input.bool(false, "Show Debug Info")
if show_debug
var table debug_table = table.new(position.top_right, 2, 3, bgcolor=color.white, border_width=1)
if barstate.islast
table.cell(debug_table, 0, 0, "Current Hour:", text_color=color.black)
table.cell(debug_table, 1, 0, str.tostring(current_hour), text_color=color.black)
table.cell(debug_table, 0, 1, "Asian Active:", text_color=color.black)
table.cell(debug_table, 1, 1, str.tostring((current_hour >= asian_start_hour) or (current_hour < asian_end_hour)), text_color=color.black)
table.cell(debug_table, 0, 2, "London Active:", text_color=color.black)
table.cell(debug_table, 1, 2, str.tostring((current_hour >= london_start_hour) and (current_hour < london_end_hour)), text_color=color.black)
RSI + Smoothed HA Strategy 🚀 RSI + SMOOTHED HEIKEN ASHI STRATEGY (TRAILING TP, 1% SL) 📊
🎯 STRATEGY OVERVIEW
This professional trading strategy combines MOMENTUM ANALYSIS with TREND CONFIRMATION using two powerful technical indicators. The system executes LONG-ONLY POSITIONS when bullish conditions align, featuring AUTOMATED RISK MANAGEMENT with a fixed stop loss and dynamic trailing exit.
⚙️ CORE COMPONENTS
📈 INDICATOR 1: RELATIVE STRENGTH INDEX (RSI)
CALCULATION: Standard 14-period RSI (configurable)
ENTRY THRESHOLD: 55 LEVEL (adjustable parameter)
PURPOSE: Identifies MOMENTUM STRENGTH and OVERBOUGHT CONDITIONS
VISUAL: Blue RSI line with gray threshold level plotted separately
🕯️ INDICATOR 2: DOUBLE-SMOOTHED HEIKEN ASHI
UNIQUE FEATURE: DOUBLE EMA SMOOTHING applied to Heiken Ashi candles
SMOOTHING LAYERS:
FIRST LAYER: EMA applied to raw OHLC data (default: 10 periods)
SECOND LAYER: EMA applied to Heiken Ashi values (default: 10 periods)
COLOR SCHEME:
🟢 LIME GREEN: Bullish candle (close > open)
🔴 RED: Bearish candle (close < open)
BENEFIT: REDUCES MARKET NOISE while maintaining trend clarity
🎮 ENTRY CONDITIONS
📈 LONG POSITIONS ACTIVATE WHEN ALL THREE CONDITIONS CONVERGE:
RSI MOMENTUM: RSI ≥ 55 (configurable level)
TREND CONFIRMATION: Current smoothed Heiken Ashi candle is GREEN
TREND REVERSAL SIGNAL: Previous smoothed Heiken Ashi candle was RED
✅ ENTRY LOGIC: This triple-filter approach ensures trades are taken only during CONFIRMED BULLISH SHIFTS with underlying momentum strength.
🛡️ RISK MANAGEMENT SYSTEM
⛔ STOP LOSS PROTECTION
FIXED 1% RISK PER TRADE
AUTOMATIC CALCULATION: Stop placed at 99% of entry price
IMMEDIATE ACTIVATION: Engages upon position entry
BENEFIT: CAPS MAXIMUM LOSS regardless of market volatility
💰 TRAILING TAKE-PROFIT MECHANISM
DYNAMIC EXIT STRATEGY: Tracks trend continuation
EXIT CONDITION: Closes position when smoothed Heiken Ashi turns RED
ADVANTAGE: LOCKS IN PROFITS during trend reversals
LOGIC: Allows winners to run while protecting gains
💼 POSITION SIZING
CAPITAL ALLOCATION: 10% of equity per trade (fully customizable)
INITIAL CAPITAL: $10,000 (user-adjustable)
FLEXIBILITY: Compatible with various account sizes
✨ KEY ADVANTAGES
🎯 PRECISE TIMING
Combines MOMENTUM FILTER (RSI) with TREND FILTER (Heiken Ashi)
Reduces false signals through CONFIRMATION SEQUENCE
🛡️ DISCIPLINED RISK CONTROL
PREDEFINED 1% STOP LOSS eliminates emotional decisions
SYSTEMATIC EXITS remove subjective profit-taking
👁️ VISUAL CLARITY
CLEAN CHART PLOTTING with color-coded candles
SEPARATE RSI DISPLAY for momentum monitoring
REAL-TIME SIGNALS directly on price chart
⚡ OPTIMIZATION TIPS
ADJUST RSI LEVEL based on asset volatility (55-70 range)
MODIFY SMOOTHING PERIODS for different timeframes
TEST POSITION SIZE according to risk tolerance
COMBINE WITH VOLUME CONFIRMATION for enhanced accuracy
📊 RECOMMENDED MARKETS
TRENDING FOREX PAIRS (EUR/USD, GBP/USD)
LIQUID INDICES (S&P 500, NASDAQ)
HIGH-CAP CRYPTO (BTC/USD, ETH/USD)
TIME FRAMES: 1-hour to daily charts
⚠️ RISK DISCLAIMER
This strategy is a TOOL FOR ANALYSIS, not financial advice. Always:
BACKTEST extensively before live trading
START WITH SMALL CAPITAL
USE PROPER RISK MANAGEMENT
CONSULT FINANCIAL PROFESSIONALS
yaman short longThis indicator provides clear Long and Short signals to help traders identify potential market direction and trading opportunities with higher confidence.
It is designed to follow price momentum and trend strength, allowing traders to enter trades when the market shows clear directional bias. The indicator focuses on clean signals and avoids unnecessary noise, making it suitable for both beginners and experienced traders.
Key Features:
Clear Long and Short signals displayed on the chart
Helps identify potential trend continuation and reversals
Designed to reduce false signals during choppy market conditions
Suitable for scalping, intraday, and swing trading
Works across multiple markets and timeframes
How to Use:
Long Signal: Indicates potential upward movement when bullish conditions align
Short Signal: Indicates potential downward movement when bearish conditions align
Best used with proper stop-loss and risk management rules
Can be combined with support/resistance or higher timeframe confirmation
Best Markets:
Forex pairs
Gold (XAUUSD)
Cryptocurrencies
Indices
Notes:
Signals are generated after candle close
The indicator does not repaint
This tool is meant to assist decision-making, not guarantee profits
Williams Fractal MA Pullback Strategy (1.5 RR) - BY DANISHOverview
This strategy is a price action and moving average-based scalping strategy designed for low timeframes (1m, 5m, 15m). It combines trend alignment with pullbacks to key moving averages and uses Williams Fractals as entry triggers.
It aims to catch high-probability scalping trades in the direction of the prevailing trend while keeping strict risk management with a 1.5:1 risk-to-reward ratio.
Indicators Used
Three Simple Moving Averages (SMA):
Fast SMA: 20 periods (Green)
Medium SMA: 50 periods (Yellow)
Slow SMA: 100 periods (Red)
Williams Fractals (Period 2):
Identifies short-term local highs (red) and lows (green) for potential reversal or continuation setups.
Trend Rules
Bullish Trend (Long Setup):
Fast SMA (20) > Medium SMA (50) > Slow SMA (100)
Moving averages must not be crossing
Bearish Trend (Short Setup):
Slow SMA (100) > Medium SMA (50) > Fast SMA (20)
Moving averages must not be crossing
This ensures trades are only taken in the direction of the prevailing trend.
Entry Rules
Long Entry (Buy):
Price pulls back to either the 20 SMA (fast) or 50 SMA (medium) without closing below the 100 SMA (slow).
A green Williams Fractal forms after the pullback.
Confirm all trend alignment rules (20>50>100).
Enter a long position at the close of the candle that confirms the fractal.
Short Entry (Sell):
Price pulls back to either the 20 SMA (fast) or 50 SMA (medium) without closing above the 100 SMA (slow).
A red Williams Fractal forms after the pullback.
Confirm all trend alignment rules (100>50>20).
Enter a short position at the close of the candle that confirms the fractal.
Risk Management & Stop Loss
Long Trades:
If price stayed above 50 SMA during pullback → SL is just below 50 SMA
If price dipped below 50 SMA but stayed above 100 SMA → SL is just below 100 SMA
Short Trades:
If price stayed below 50 SMA during pullback → SL is just above 50 SMA
If price rose above 50 SMA but stayed below 100 SMA → SL is just above 100 SMA
Take Profit (TP)
Fixed 1.5 Risk-to-Reward ratio
TP = Risk × 1.5
This ensures each trade has a positive expectancy and follows consistent risk-reward management.
Additional Rules
Fractals Confirmation:
The strategy waits for 2 bars to close before confirming the fractal signal to avoid repainting.
No trades are taken if the price violates the 100-period SMA during the pullback.
Designed for scalping on low timeframes: 1m, 5m, or 15m charts.
Visuals on Chart
SMA Lines:
20 SMA (Green)
50 SMA (Yellow)
100 SMA (Red)
Fractal Arrows:
Green fractal → potential long entry
Red fractal → potential short entry
Trade Highlights: Strategy plots entries and exit levels automatically with stop loss and take profit.
How to Use
Add the script to a 1m, 5m, or 15m chart.
Enable the strategy tester to see backtesting results.
Follow the trend alignment rules strictly for high-probability scalping trades.
Optionally, combine with volume filters or market structure analysis for better performance.
Benefits
Trades only in aligned trend direction, avoiding counter-trend traps.
Pullback + fractal logic provides high-probability entries.
Risk-to-reward of 1.5:1 ensures good risk management.
Avoids fractal repainting by waiting for candle close.
Ideal Conditions
Works best on volatile assets like crypto or forex pairs with clear trending moves.
Best applied to liquid markets with tight spreads for scalping.
✅ Summary:
Trend-aligned scalping strategy
Pullback to MA + fractal confirmation
Fixed 1.5 RR risk management
Works on low timeframes (1m, 5m, 15m)
Clean visual signals with SMMAs and fractals
VWAP x EMA9 Crossover (FLIP BUY/SELL)Another simple script, please use as needed and provide any feedback back or recommendations
EMA + VWAP Strategy# EMA + VWAP Crossover Strategy
## Overview
This is a trend-following intraday strategy that combines fast and slow EMAs with VWAP to identify high-probability entries. It's designed primarily for 5-15 minute charts and includes a smart filter to avoid trading when VWAP is ranging flat.
## How It Works
### Core Concept
The strategy uses three main components working together:
- **Fast EMA (9)** - Responds quickly to price changes and generates entry signals
- **Slow EMA (21)** - Acts as a trend filter to keep you on the right side of the market
- **VWAP** - Serves as a dynamic support/resistance level and the primary trigger for entries
### Entry Rules
**Long Entry:**
- EMA 9 crosses above VWAP (bullish momentum)
- EMA 9 is above EMA 21 (confirming uptrend)
- VWAP has a clear directional slope (not flat/ranging)
- Only during weekdays (Monday-Friday)
**Short Entry:**
- EMA 9 crosses below VWAP (bearish momentum)
- EMA 9 is below EMA 21 (confirming downtrend)
- VWAP has a clear directional slope (not flat/ranging)
- Only during weekdays (Monday-Friday)
### The VWAP Flat Filter
One of the key features is the VWAP slope filter. When VWAP is moving sideways (flat), it indicates the market is likely consolidating or ranging. The strategy skips these periods because crossover signals tend to be less reliable in choppy conditions. You'll see small gray diamonds at the top of the chart when VWAP is considered flat.
### Risk Management
The strategy uses a proper risk-reward approach with multiple stop loss options:
1. **ATR-Based (Recommended)** - Adapts to market volatility automatically. Default is 1.5x ATR(14), which gives your trades room to breathe while protecting capital.
2. **Swing Low/High** - Places stops at recent price structure points for a more technical approach.
3. **Slow EMA** - Uses the trend-defining EMA as your stop level, good for trend-following with wider stops.
4. **Fixed Percentage** - Simple percentage-based stops if you prefer consistency.
Take profits are automatically calculated based on your risk-reward ratio (default 2:1), meaning if you risk $100, you're aiming to make $200.
### Weekday Trading Filter
The strategy includes an option to trade only Monday through Friday. This is particularly useful for crypto markets where weekend liquidity can be thin and price action more erratic. You can toggle this on/off to test whether avoiding weekends improves your results.
### Visual Features
- **Color-coded background** - Green tint when EMA 9 is above EMA 21 (bullish bias), red tint when below (bearish bias)
- **ATR bands** - Dotted lines showing where stops would be placed (when using ATR stops)
- **Active trade levels** - Solid red line for your stop loss, green line for your take profit when you're in a position
- **Weekend highlighting** - Gray background on Saturdays and Sundays when weekday filter is active
## Best Practices
**Timeframe:** Designed for 5-minute charts but can be adapted to other intraday timeframes.
**Markets:** Works on any liquid market - stocks, forex, crypto, futures. Just make sure there's enough volume.
**Position Sizing:** The strategy uses percentage of equity by default. Adjust based on your risk tolerance.
**Backtesting Tips:**
- Test with and without the weekday filter to see which performs better on your instrument
- Try different ATR multipliers (1.0-2.5) to find the sweet spot between stop-outs and letting profits run
- Experiment with risk-reward ratios (1.5R, 2R, 3R) to optimize for your win rate
**What to Watch:**
- Win rate vs. profit factor balance
- How many trades are filtered out by the VWAP flat condition
- Performance difference between weekdays and weekends
- Whether the trend filter (EMA 21) is keeping you out of bad trades
## Parameters You Can Adjust
- Fast EMA length (default 9)
- Slow EMA length (default 21)
- VWAP flat threshold (default 0.01%)
- Stop loss type and parameters
- Risk-reward ratio
- Weekday trading on/off
- ATR length and multiplier
## Disclaimer
This strategy is for educational purposes. Past performance doesn't guarantee future results. Always test thoroughly on historical data and paper trade before risking real money. Use proper position sizing and never risk more than you can afford to lose.
---
*Built with Pine Script v5 for TradingView*
Big Trend Catcher: Dual-Gate EMA & ATR Trailing Swing TraderThe Big Trend Catcher: Long-Only Progressive Swing System
OVERVIEW
The Big Trend Catcher is a high-conviction, long-only swing trading strategy designed to identify and ride sustained market moves. Unlike traditional trend-following systems that often get "chopped out" during sideways consolidation, this strategy utilizes a Dual-Gate Filter to ensure you only enter when short-term momentum and the long-term trend are in total alignment.
It is specifically tuned for high-growth stocks and ETFs where capturing the lion’s share of a multi-week or multi-month move is the primary objective.
CORE LOGIC: THE DUAL-GATE SYSTEM
To maintain a high quality of entries, the strategy requires a "confirmed launch" through two distinct filters:
The Momentum Gate (20 EMA): Identifies immediate price acceleration and volume-backed impulse.
The Long-Term Gate (100 EMA): Acts as the ultimate trend filter. The script utilizes a "Signal Memory" logic—if an impulse happens while price is still below the 100 EMA, the trade is held in a "Pending" state. The entry only triggers once the price closes firmly above the 100 EMA.
Goal: This prevents "bottom fishing" in established downtrends and keeps you in cash during sideways "death loops" when the long-term direction is unclear.
KEY FEATURES
1. Progressive Pyramiding (Scale-In)
The biggest profits in swing trading are often made by adding to winners. This system features two automated scale-in triggers:
Velocity Adds (VOLC): Adds to the position if the stock is up >10% and moving with rising momentum, allowing you to build a larger position as the trend proves its strength.
Pullback Adds: Adds to the position when the price tests the 20 EMA and holds, allowing you to buy the "dip" within a healthy uptrend.
2. The Phoenix Re-Entry
This logic is designed to catch "V-shaped" recoveries. If the strategy exits on a trend break but the price aggressively reclaims the 20 EMA on massive volume shortly after, it re-enters the trade. This ensures you aren't left behind during the second leg of a major run after a temporary shakeout.
3. Iron-Floor ATR Exit
We use a 3.5x ATR Trailing Stop combined with the 100 EMA. This wider-than-average "breathing room" is designed to keep you in for significant gains while ignoring the minor daily volatility that often shakes out traders with tighter stops.
HOW TO USE
Best Timeframes: Daily (D) is recommended for identifying major cycles, but it can be applied to the 4-Hour (4H) for more active swing trading.
Settings:
* 20 EMA: Your short-term momentum guide.
* 100 EMA: Your long-term trend guide.
* ATR Multiplier: Set to 3.5 for maximum "trend hugging."
SUMMARY OF VISUALS
Blue Line (100 EMA): The Long-Term Trend.
Yellow Line (20 EMA): The Short-Term Momentum.
Red Stepped Line: Your ATR Trailing Floor (The "Iron Floor").
Lime Triangle: Initial Trade Entry.
Blue/Orange Shapes: Progressive Scale-in points.






















