An indicator version of a multi-timeframe breakout idea that checks 9 and 18 period EMA direction on three higher timeframes, with the chart timeframe optional.
//@version=4
//IWBDT Strategy - Indicator
study("IWBDT Strategy Indicator", "IWBDT Indicator", overlay=true)
// ################################################################################################################################################################
// IWBDT Strategy - It Will Break Down/Through
// Multi-Timeframe Fractal Breakout System
// ################################################################################################################################################################
// Input Parameters
FirstAddTF = input(title="First additional Timeframe", type=input.resolution, defval="60")
SecondAddTF = input(title="Second additional Timeframe", type=input.resolution, defval="240")
ThirdAddTF = input(title="Third additional Timeframe", type=input.resolution, defval="D")
EMA_Short_period = input(defval=9, title="EMA Period Short", type=input.integer)
EMA_Long_period = input(defval=18, title="EMA Period Long", type=input.integer)
// Risk Management
rr = input(defval=2, title="Risk Reward Target", type=input.integer)
USDRiskPerTrade = input(defval=20, title="Fixed risk amount per trade in USD", type=input.integer)
// Trend Options
IncludeCT = input(defval=false, title="Include Current Time Frame EMA-cross in trend definition", type=input.bool)
// Visual Settings
HideBackground = input(defval=false, title="Hide colored background", type=input.bool)
bgcolorBullTransp = input(defval=55, title="All TF Bull Color Transparency", type=input.integer)
bgcolorBearTransp = input(defval=55, title="All TF Bear Color Transparency", type=input.integer)
bgcolorBullPartialTransp = input(defval=70, title="Partial TF Bull Color Transparency", type=input.integer)
bgcolorBearPartialTransp = input(defval=70, title="Partial TF Bear Color Transparency", type=input.integer)
// Statistics
HideStatistics = input(false, title="Hide Statistics")
DisplayEquityCurve = input(false, title="Display Equity Curve")
commission = input(title="Estimated commission per round-turn in USD", defval=0.1744)
// ################################################################################################################################################################
// Multi-Timeframe Trend Analysis
// ################################################################################################################################################################
// Get EMA data for all timeframes
FirstAddTF_ema_short = security(syminfo.tickerid, FirstAddTF, ema(close, EMA_Short_period))
FirstAddTF_ema_long = security(syminfo.tickerid, FirstAddTF, ema(close, EMA_Long_period))
SecondAddTF_ema_short = security(syminfo.tickerid, SecondAddTF, ema(close, EMA_Short_period))
SecondAddTF_ema_long = security(syminfo.tickerid, SecondAddTF, ema(close, EMA_Long_period))
ThirdAddTF_ema_short = security(syminfo.tickerid, ThirdAddTF, ema(close, EMA_Short_period))
ThirdAddTF_ema_long = security(syminfo.tickerid, ThirdAddTF, ema(close, EMA_Long_period))
// Current timeframe EMAs
ctf_ema_short = ema(close, EMA_Short_period)
ctf_ema_long = ema(close, EMA_Long_period)
// Calculate trend direction for each timeframe
FirstAddTF_Bull = FirstAddTF_ema_short > FirstAddTF_ema_long ? 1 : 0
SecondAddTF_Bull = SecondAddTF_ema_short > SecondAddTF_ema_long ? 1 : 0
ThirdAddTF_Bull = ThirdAddTF_ema_short > ThirdAddTF_ema_long ? 1 : 0
FirstAddTF_Bear = FirstAddTF_ema_short < FirstAddTF_ema_long ? 1 : 0
SecondAddTF_Bear = SecondAddTF_ema_short < SecondAddTF_ema_long ? 1 : 0
ThirdAddTF_Bear = ThirdAddTF_ema_short < ThirdAddTF_ema_long ? 1 : 0
// Full trend alignment (3/3 timeframes)
L_TF_Bull = FirstAddTF_Bull + SecondAddTF_Bull + ThirdAddTF_Bull == 3
L_TF_Bear = FirstAddTF_Bear + SecondAddTF_Bear + ThirdAddTF_Bear == 3
// Partial trend alignment (2/3 timeframes)
L_TF_Bull_partial = FirstAddTF_Bull + SecondAddTF_Bull + ThirdAddTF_Bull == 2
L_TF_Bear_partial = FirstAddTF_Bear + SecondAddTF_Bear + ThirdAddTF_Bear == 2
// Current timeframe trend
CT_Bull = ctf_ema_short > ctf_ema_long ? 1 : 0
CT_Bear = ctf_ema_short < ctf_ema_long ? 1 : 0
// All timeframes including current (4/4)
All_TF_Bull = FirstAddTF_Bull + SecondAddTF_Bull + ThirdAddTF_Bull + CT_Bull == 4
All_TF_Bear = FirstAddTF_Bear + SecondAddTF_Bear + ThirdAddTF_Bear + CT_Bear == 4
// Final trend determination
BullTrend = IncludeCT ? All_TF_Bull : L_TF_Bull
BearTrend = IncludeCT ? All_TF_Bear : L_TF_Bear
// ################################################################################################################################################################
// ATR-based Risk Management
// ################################################################################################################################################################
Min_Trade_Risk = atr(14)
Max_Trade_Risk = 2 * atr(14)
// ################################################################################################################################################################
// Fractal Detection
// ################################################################################################################################################################
// Basic fractal patterns
topfractal = high[3] < high[2] and high[2] > high[1] and BearTrend == true
botfractal = low[3] > low[2] and low[2] < low[1] and BullTrend == true
// Trade state management
var bool tradeactive = false
var bool Longtradeactive = false
var bool Shorttradeactive = false
var bool Breakevenactive = false
// Fractal confirmation with risk filters
topfractalconfirmed = high[3] < high[2] and high[2] > high[1] and BearTrend == true and
low < low[1] and tradeactive == false and
(high[2] - low[1]) > Min_Trade_Risk and (high[2] - low[1]) < Max_Trade_Risk
botfractalconfirmed = low[3] > low[2] and low[2] < low[1] and BullTrend == true and
high > high[1] and tradeactive == false and
(high[1] - low[2]) > Min_Trade_Risk and (high[1] - low[2]) < Max_Trade_Risk
// ################################################################################################################################################################
// Trade Level Management
// ################################################################################################################################################################
var float StopLevel = 0.0
var float EntryLevel = 0.0
var float TPLevel = 0.0
var float BELevel = 0.0
var float stopdistance = 0.0
// Position sizing variables
var float TradeSizeInXBT = 0.0
var int TradeSizeInUSD = 0
// ################################################################################################################################################################
// Trade Entry Logic
// ################################################################################################################################################################
// Short trade trigger
if topfractalconfirmed and not tradeactive
StopLevel := high[2]
EntryLevel := close
TPLevel := EntryLevel - (rr * (StopLevel - EntryLevel))
BELevel := EntryLevel - (StopLevel - EntryLevel)
stopdistance := StopLevel - EntryLevel
TradeSizeInXBT := USDRiskPerTrade / stopdistance
TradeSizeInUSD := int(EntryLevel * TradeSizeInXBT)
tradeactive := true
Shorttradeactive := true
// Long trade trigger
if botfractalconfirmed and not tradeactive
StopLevel := low[2]
EntryLevel := close
TPLevel := EntryLevel + (rr * (EntryLevel - StopLevel))
BELevel := EntryLevel + (EntryLevel - StopLevel)
stopdistance := EntryLevel - StopLevel
TradeSizeInXBT := USDRiskPerTrade / stopdistance
TradeSizeInUSD := int(EntryLevel * TradeSizeInXBT)
tradeactive := true
Longtradeactive := true
// ################################################################################################################################################################
// Breakeven Management
// ################################################################################################################################################################
// 1-minute data for precise breakeven
low_m1 = security(syminfo.tickerid, "1", low)
high_m1 = security(syminfo.tickerid, "1", high)
// Breakeven activation
shorttradeBElevelactivation = (low < BELevel) and not (low_m1 < TPLevel)
longtradeBElevelactivation = (high > BELevel) and not (high_m1 > TPLevel)
if Shorttradeactive and shorttradeBElevelactivation
Breakevenactive := true
if Longtradeactive and longtradeBElevelactivation
Breakevenactive := true
// ################################################################################################################################################################
// Trade Exit Logic
// ################################################################################################################################################################
// Performance counters
var int PlotWinCounter = 0
var int PlotLossCounter = 0
var int PlotBreakEvenCounter = 0
// Loss trades
plotlosshort = Shorttradeactive and high > StopLevel and not Breakevenactive
plotlosslong = Longtradeactive and low < StopLevel and not Breakevenactive
if plotlosshort
tradeactive := false
Shorttradeactive := false
Breakevenactive := false
PlotLossCounter := PlotLossCounter + 1
if plotlosslong
tradeactive := false
Longtradeactive := false
Breakevenactive := false
PlotLossCounter := PlotLossCounter + 1
// Breakeven trades
plotBreakevenshort = Shorttradeactive and high > EntryLevel and Breakevenactive
plotBreakevenlong = Longtradeactive and low < EntryLevel and Breakevenactive
if plotBreakevenshort
tradeactive := false
Shorttradeactive := false
Breakevenactive := false
PlotBreakEvenCounter := PlotBreakEvenCounter + 1
if plotBreakevenlong
tradeactive := false
Longtradeactive := false
Breakevenactive := false
PlotBreakEvenCounter := PlotBreakEvenCounter + 1
// Win trades
plotWinshort = Shorttradeactive and low < TPLevel
plotWinlong = Longtradeactive and high > TPLevel
if plotWinshort
tradeactive := false
Shorttradeactive := false
Breakevenactive := false
PlotWinCounter := PlotWinCounter + 1
if plotWinlong
tradeactive := false
Longtradeactive := false
Breakevenactive := false
PlotWinCounter := PlotWinCounter + 1
// ################################################################################################################################################################
// Visualization
// ################################################################################################################################################################
// Background colors
BGColorBull = color.green
BGColorBear = color.red
BGColorBullPartial = color.teal
BGColorBearPartial = color.maroon
BGColor0 = BullTrend and not HideBackground ? BGColorBull : na
BGColor1 = BearTrend and not HideBackground ? BGColorBear : na
BGColor2 = L_TF_Bull_partial and not HideBackground ? BGColorBullPartial : na
BGColor3 = L_TF_Bear_partial and not HideBackground ? BGColorBearPartial : na
bgcolor(BGColor0, bgcolorBullTransp)
bgcolor(BGColor1, bgcolorBearTransp)
bgcolor(BGColor2, bgcolorBullPartialTransp)
bgcolor(BGColor3, bgcolorBearPartialTransp)
// Fractal markers
plotchar(topfractal, char="ˆ", location=location.abovebar, color=color.red, transp=0, offset=-2, size=size.small)
plotchar(botfractal, char="ˬ", location=location.belowbar, color=color.lime, transp=0, offset=-2, size=size.small)
// Entry confirmation markers
plotchar(topfractalconfirmed, char="↓", location=location.abovebar, color=color.yellow, transp=0, offset=0, size=size.small)
plotchar(botfractalconfirmed, char="↑", location=location.belowbar, color=color.white, transp=0, offset=0, size=size.small)
// Trade outcome markers
plotchar(plotlosshort or plotlosslong, char="X", location=location.abovebar, color=color.fuchsia, transp=0, offset=0, size=size.small)
plotchar(plotBreakevenshort or plotBreakevenlong, char="0", location=location.belowbar, color=color.blue, transp=0, offset=0, size=size.small)
plotchar(plotWinshort or plotWinlong, char="1", location=location.belowbar, color=color.green, transp=0, offset=0, size=size.small)
// Trade levels
p1 = plot(StopLevel, title="Stop Level", color=color.red, linewidth=2)
p2 = plot(EntryLevel, title="Entry Level", color=color.white, linewidth=2)
p3 = plot(BELevel, title="Breakeven Level", color=color.blue, linewidth=1)
p4 = plot(TPLevel, title="TP Level", color=color.green, linewidth=2)
// Fill zones
fill(p1, p2, color=color.red, transp=65)
fill(p2, p3, color=color.blue, transp=65)
fill(p3, p4, color=color.green, transp=65)
// ################################################################################################################################################################
// Statistics and Performance
// ################################################################################################################################################################
// Calculate performance metrics
EquityCurve = PlotWinCounter * 2 * USDRiskPerTrade - PlotLossCounter * USDRiskPerTrade -
(PlotWinCounter + PlotLossCounter + PlotBreakEvenCounter) * commission
totalTrades = PlotWinCounter + PlotLossCounter + PlotBreakEvenCounter
winpercent = totalTrades > 0 ? round((PlotWinCounter / totalTrades) * 100) : 0
losspercent = totalTrades > 0 ? round((PlotLossCounter / totalTrades) * 100) : 0
bepercent = totalTrades > 0 ? round((PlotBreakEvenCounter / totalTrades) * 100) : 0
totalWinLoss = PlotWinCounter + PlotLossCounter
rrpercent = totalWinLoss > 0 ? round((PlotWinCounter / totalWinLoss) * 100) : 0
// Display statistics
StatisticsVerticalOffset = atr(14)
if (plotWinlong or plotWinshort or plotBreakevenlong or plotBreakevenshort or plotlosslong or plotlosshort) and not HideStatistics
statsText = "Win: " + tostring(PlotWinCounter) + " (" + tostring(winpercent) + "%)" +
"\nLoss: " + tostring(PlotLossCounter) + " (" + tostring(losspercent) + "%)" +
"\nBE: " + tostring(PlotBreakEvenCounter) + " (" + tostring(bepercent) + "%)" +
"\nRate: " + tostring(rrpercent) + "%"
l = label.new(bar_index, high + StatisticsVerticalOffset, style=label.style_none,
text=statsText, color=color.white, textcolor=color.white)
// Equity curve
plot(DisplayEquityCurve ? EquityCurve : na, title="Profit and Loss", color=color.yellow, linewidth=3)
// ################################################################################################################################################################
// Alerts
// ################################################################################################################################################################
// Trend alerts
alertcondition(BullTrend, title='IWBDT Trend Alert Bull', message='IWBDT Bull-Trend Activated')
alertcondition(BearTrend, title='IWBDT Trend Alert Bear', message='IWBDT Bear-Trend Activated')
// Fractal alerts
alertcondition(topfractal, title='IWBDT Fractal Alert Top', message='Top Fractal Alert')
alertcondition(botfractal, title='IWBDT Fractal Alert Bottom', message='Bottom Fractal Alert')
// Entry alerts
alertcondition(topfractalconfirmed, title='IWBDT Entry Alert Short', message='IWBDT Short Entry Signal')
alertcondition(botfractalconfirmed, title='IWBDT Entry Alert Long', message='IWBDT Long Entry Signal')
// Exit alerts
alertcondition(plotlosshort or plotlosslong or plotBreakevenshort or plotBreakevenlong,
title='IWBDT Exit Alert BE/Stop', message='IWBDT Exit at Breakeven or Stop')
alertcondition(plotWinshort or plotWinlong, title='IWBDT Exit Alert Win', message='IWBDT Exit at Take Profit')
// ################################################################################################################################################################
// Information Display
// ################################################################################################################################################################
// Display current trend status
var string trendStatus = ""
if BullTrend
trendStatus := "BULL TREND"
else if BearTrend
trendStatus := "BEAR TREND"
else if L_TF_Bull_partial
trendStatus := "BULL PARTIAL"
else if L_TF_Bear_partial
trendStatus := "BEAR PARTIAL"
else
trendStatus := "NO TREND"
// Display trade status
var string tradeStatus = ""
if Longtradeactive
tradeStatus := "LONG ACTIVE"
else if Shorttradeactive
tradeStatus := "SHORT ACTIVE"
else
tradeStatus := "NO TRADE"
// Create info table
var table infoTable = table.new(position.top_right, 2, 4, bgcolor=color.white, border_width=1)
if barstate.islast
table.cell(infoTable, 0, 0, "Trend:", text_color=color.black, text_size=size.small)
table.cell(infoTable, 1, 0, trendStatus, text_color=color.black, text_size=size.small)
table.cell(infoTable, 0, 1, "Trade:", text_color=color.black, text_size=size.small)
table.cell(infoTable, 1, 1, tradeStatus, text_color=color.black, text_size=size.small)
table.cell(infoTable, 0, 2, "Trades:", text_color=color.black, text_size=size.small)
table.cell(infoTable, 1, 2, tostring(totalTrades), text_color=color.black, text_size=size.small)
table.cell(infoTable, 0, 3, "Win Rate:", text_color=color.black, text_size=size.small)
table.cell(infoTable, 1, 3, tostring(rrpercent) + "%", text_color=color.black, text_size=size.small)
Overview
Trend agreement is shown through background colours with adjustable transparency. Inputs set a risk-to-reward target, a fixed dollar risk, estimated commission, and toggles for statistics and an equity curve. It draws on the price chart, and higher-timeframe values can shift until their bars close.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
First additional Timeframe
timeframe
60
FirstAddTF
Second additional Timeframe
timeframe
240
SecondAddTF
Third additional Timeframe
timeframe
D
ThirdAddTF
EMA Period Short
int
9
EMA_Short_period
EMA Period Long
int
18
EMA_Long_period
Risk Reward Target
int
2
rr
Fixed risk amount per trade in USD
int
20
USDRiskPerTrade
Include Current Time Frame EMA-cross in trend definition
bool
false
IncludeCT
Hide colored background
bool
false
HideBackground
All TF Bull Color Transparency
int
55
bgcolorBullTransp
All TF Bear Color Transparency
int
55
bgcolorBearTransp
Partial TF Bull Color Transparency
int
70
bgcolorBullPartialTransp
Show all 16 settings
Setting
Type
Default
Variable
Partial TF Bear Color Transparency
int
70
bgcolorBearPartialTransp
Hide Statistics
bool
false
HideStatistics
Display Equity Curve
bool
false
DisplayEquityCurve
Estimated commission per round-turn in USD
float
0.1744
commission
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator plots Donchian Channels alongside fast and slow simple moving averages directly on the price chart. It generates bullish breakout signals when the high reaches the upper channel while the close is above the 50 SMA (and optionally the 200 SMA). B
This indicator classifies market trends into structured stages based on moving average alignments, compression, and ATR distance from the 50-period SMA. It tracks multiple exponential moving averages against the 50 SMA to detect basing phases, breakouts, trend
This technical indicator combines SuperTrend signals, moving average trend clouds, pivot points, and daily range breakout targets directly on the price chart. It generates Buy, Strong Buy, Sell, and Strong Sell labels when price crosses the SuperTrend level in
This indicator calculates the relative strength of a chart symbol relative to a benchmark index and plots the resulting line directly over the price chart. It highlights new relative strength highs, new lows, and instances where relative strength reaches a new
Calculates short and long Exponential Moving Averages alongside pivot high and low levels to identify breakout signals. The indicator plots a 20 EMA and a 50 EMA on the main price chart. It evaluates trend direction based on EMA crossover alignment, checks for
CSW Breakout Signals plots breakout buy and sell labels on the price chart when price breaks support or resistance after a trend change. Each signal can show a numbered confirmation score built from a moving-average cross, momentum, opening-range alignment, re