OPEN-SOURCE SCRIPT
LW Outside Day Strategy[SpeculationLab]

This strategy is inspired by the “Outside Day” concept introduced by Larry Williams in Long-Term Secrets to Short-Term Trading, and has been extended with configurable risk management tools and realistic backtesting parameters.
Concept
The “Outside Day” is a classic price action pattern that reflects strong market rejection or continuation pressure.
An Outside Bar occurs when the current bar’s high exceeds the previous high and the low falls below the previous low.
A body-size filter ensures only significant candles are included.
Entry Logic
Buy setup: Price closes below the previous low (bullish rejection).
Sell setup: Price closes above the previous high (bearish rejection).
Only confirmed bars are used (no intrabar signals).
Stop-Loss Modes
Prev Low/High: Uses the previous swing point ± ATR-based buffer.
ATR: Dynamic stop based on Average True Range × multiplier.
Fixed Pips: User-defined fixed distance (for forex testing).
Take-Profit Modes
Prev High/Low (PHL): Exits near the opposite swing.
Risk-Reward (RR): Targets a user-defined multiple of the stop distance (default = 2 : 1).
Following Price Open (FPO): Exits on the next bar’s open if price opens in profit (used to test overnight price continuation).
Risk Management & Backtest Settings
Default risk per trade is set at 10% of account equity (user-adjustable).
Commission = 0.1% and slippage = 2 ticks are applied to simulate realistic conditions.
For reliable statistics, test on data that yields over 100 trades.
Suitable for daily and 4-hour timeframes across stocks, forex, and crypto markets.
Visual Elements
Green and red triangles show entry signals.
Stop-loss (red) and take-profit (green) reference lines are drawn for clarity.
Optional alerts notify when a valid setup forms.
Disclaimer
This script is for educational and research purposes only.
It does not constitute financial advice or guarantee profits.
Always backtest thoroughly and manage your own risk.
Enhancements over Classic Outside Bar Models
Adjustable stop and target logic with ATR and buffer multipliers.
“Following Price Open” exit logic for realistic day-end management.
Optimized to avoid repainting and bar-confirmation issues.
Built with realistic trading costs and position sizing.
策略逻辑
外包线识别
当日最高价高于前一日最高价,且当日最低价低于前一日最低价,即形成外包线。
同时过滤掉较小实体的 K 线,仅保留实体显著大于前一根的形态。
方向过滤
收盘价低于前一日最低价 → 视为买入信号。
收盘价高于前一日最高价 → 视为卖出信号。
止损设置(可选参数)
前低/高止损:以形态前低/前高为止损,带有缓冲倍数。
ATR 止损:根据平均波动率(ATR)动态调整。
固定点数止损:按照用户设定的点数作为止损范围。
止盈设置(可选参数)
前高/低止盈(PHL):以前高/前低为目标。
固定盈亏比(RR):根据用户设定的风险回报比自动计算。
隔夜开盘(FPO):若次日开盘价高于进场价(多单)或低于进场价(空单),则平仓。
信号标记
在图表中标注买入/卖出信号(三角形标记)。
绘制止损与目标位参考线。
使用说明
适用周期:建议用于 日线图(Daily)。
适用市场:股票、外汇、加密货币等各类市场均可。
提示:此策略为历史研究与学习用途,不构成投资建议。实际交易请结合自身风险管理。
Concept
The “Outside Day” is a classic price action pattern that reflects strong market rejection or continuation pressure.
An Outside Bar occurs when the current bar’s high exceeds the previous high and the low falls below the previous low.
A body-size filter ensures only significant candles are included.
Entry Logic
Buy setup: Price closes below the previous low (bullish rejection).
Sell setup: Price closes above the previous high (bearish rejection).
Only confirmed bars are used (no intrabar signals).
Stop-Loss Modes
Prev Low/High: Uses the previous swing point ± ATR-based buffer.
ATR: Dynamic stop based on Average True Range × multiplier.
Fixed Pips: User-defined fixed distance (for forex testing).
Take-Profit Modes
Prev High/Low (PHL): Exits near the opposite swing.
Risk-Reward (RR): Targets a user-defined multiple of the stop distance (default = 2 : 1).
Following Price Open (FPO): Exits on the next bar’s open if price opens in profit (used to test overnight price continuation).
Risk Management & Backtest Settings
Default risk per trade is set at 10% of account equity (user-adjustable).
Commission = 0.1% and slippage = 2 ticks are applied to simulate realistic conditions.
For reliable statistics, test on data that yields over 100 trades.
Suitable for daily and 4-hour timeframes across stocks, forex, and crypto markets.
Visual Elements
Green and red triangles show entry signals.
Stop-loss (red) and take-profit (green) reference lines are drawn for clarity.
Optional alerts notify when a valid setup forms.
Disclaimer
This script is for educational and research purposes only.
It does not constitute financial advice or guarantee profits.
Always backtest thoroughly and manage your own risk.
Enhancements over Classic Outside Bar Models
Adjustable stop and target logic with ATR and buffer multipliers.
“Following Price Open” exit logic for realistic day-end management.
Optimized to avoid repainting and bar-confirmation issues.
Built with realistic trading costs and position sizing.
策略逻辑
外包线识别
当日最高价高于前一日最高价,且当日最低价低于前一日最低价,即形成外包线。
同时过滤掉较小实体的 K 线,仅保留实体显著大于前一根的形态。
方向过滤
收盘价低于前一日最低价 → 视为买入信号。
收盘价高于前一日最高价 → 视为卖出信号。
止损设置(可选参数)
前低/高止损:以形态前低/前高为止损,带有缓冲倍数。
ATR 止损:根据平均波动率(ATR)动态调整。
固定点数止损:按照用户设定的点数作为止损范围。
止盈设置(可选参数)
前高/低止盈(PHL):以前高/前低为目标。
固定盈亏比(RR):根据用户设定的风险回报比自动计算。
隔夜开盘(FPO):若次日开盘价高于进场价(多单)或低于进场价(空单),则平仓。
信号标记
在图表中标注买入/卖出信号(三角形标记)。
绘制止损与目标位参考线。
使用说明
适用周期:建议用于 日线图(Daily)。
适用市场:股票、外汇、加密货币等各类市场均可。
提示:此策略为历史研究与学习用途,不构成投资建议。实际交易请结合自身风险管理。
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.