passaro.mail

ReversalBreakout Strategy

BITFINEX:BTCUSD   Bitcoin / Dollaro
//@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 : na, style=line, linewidth=1, color=green)

highline=highest(close, len )
plot(ShFL ? highline : na, style=line, linewidth=1, color=red)

MidLine = (highline+lowline)/2
plot(ShFL ? MidLine : 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 and time >= testPeriodStart) ? true : false
belowLLine = (close<lowline 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)
Home Screener azioni Screener forex Screener cripto Calendario economico Come funziona Caratteristiche Grafico Costi Regolamento Moderatori Soluzioni per broker & siti web Widget Librerie grafiche Centro di supporto Suggerisci funzionalità Blog & Novità FAQ Wiki Twitter
Profilo Impostazioni profilo Account e fatturazione TradingView Coin I miei ticket di supporto Centro di supporto Idee pubblicate Follower Seguiti Messaggi Privati Chat Esci