Search
Products
Community
Markets
News
Brokers
More
IN
Get started
Community
/
Ideas
/
ReversalBreakout Strategy
Bitcoin
ReversalBreakout Strategy
By passaro.mail
Follow
Follow
Sep 4, 2018
1
Sep 4, 2018
//
version
=2
strategy("ReversalBreakout Strategy", overlay=true)
testStartYear = input(2018, "Backtest Start Year")
testStartMonth = input(03, "Backtest Start Month")
testStartDay = input(01, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear, testStartMonth, testStartDay, 0, 0)
len = input(24,minval=1, title = "Periodo")
ShFL = input(true, type=bool, title = "Show Fractal lines?")
lowline = lowest(close, len)
plot(ShFL ? lowline[1] : na, style=line, linewidth=1, color=green)
highline=highest(close, len)
plot(ShFL ? highline[1] : na, style=line, linewidth=1, color=red)
MidLine = (highline+lowline)/2
plot(ShFL ? MidLine[1] : na, style=line, linewidth=1)
//----------------------------------------------------------------------------------
// === INPUTS RISK MANAGEMENT===
inpTakeProfit = input(defval = 1000, title = "Take Profit", minval = 0)
inpStopLoss = input(defval = 200, title = "Stop Loss", minval = 0)
inpTrailStop = input(defval = 200, title = "Trailing Stop Loss", minval = 0)
inpTrailOffset = input(defval = 0, title = "Trailing Stop Loss Offset", minval = 0)
// === RISK MANAGEMENT VALUE PREP ===
//Se l'input è <1 viene disabilitato
useTakeProfit = inpTakeProfit >= 1 ? inpTakeProfit : na
useStopLoss = inpStopLoss >= 1 ? inpStopLoss : na
useTrailStop = inpTrailStop >= 1 ? inpTrailStop : na
useTrailOffset = inpTrailOffset >= 1 ? inpTrailOffset : na
// === CONDIZIONI LOGICHE ===
aboveHLine = (close>highline[1] and time >= testPeriodStart) ? true : false
belowLLine = (close<lowline[1] and time >= testPeriodStart) ? true : false
// === STRATEGY - LONG POSITION===
strategy.entry(id = "Long", long = true, when = aboveHLine)
// === STRATEGY - SHORT POSITION===
strategy.entry(id = "Short", long = false, when = belowLLine)
// === STRATEGY RISK MANAGEMENT EXECUTION ===
strategy.exit("Exit Long", from_entry = "Long", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
strategy.exit("Exit Short", from_entry = "Short", profit = useTakeProfit, loss = useStopLoss, trail_points = useTrailStop, trail_offset = useTrailOffset)
Beyond Technical Analysis
breakout
Technical Indicators
LONG
short
stoploss
strategy
takeprofit
trailingstop
Trend Analysis
passaro.mail
Follow
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the
Terms of Use
.