You are on page 1of 2

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
https://mozilla.org/MPL/2.0/
// © Cbgbm788

//@version=4
strategy("Break out sell strategy SR", shorttitle="BREAK sell FP",pyramiding = 0,
overlay=true)
//input
//input
HLPeriod = input(0.382, title="HighLow Period", type=input.float)
SK = input(2, title="SK", type=input.float)*0.001
SLL = input(10, title="SL", type=input.float)*0.001
TPP = input(20, title="TP", type=input.float)*0.001
res = input(title="Timeframe", type=input.resolution, defval="M")
montha = input(title='Montha', defval=1, minval=0, maxval=12,type=input.integer)
startY = input(title='Start Year', defval=2011)
startM = input(title='Start Month', defval=1, minval=1,
maxval=12,type=input.integer)
startD = input(title='Start Day', defval=1, minval=1, maxval=31,
type=input.integer)
finishY = input(title='Finish Year', defval=2050, type=input.integer)
finishM = input(title='Finish Month', defval=12, minval=1,
maxval=12,type=input.integer)
finishD = input(title='Finish Day', defval=31, minval=1,
maxval=31,type=input.integer)
//finish = input(2019, 02, 28, 00, 00)
timestart = timestamp(startY, startM, startD, 00, 00)
timefinish = timestamp(finishY, finishM, finishD, 23, 59)
window = time >= timestart and time <= timefinish ? true : false // Lenghth
strategy
//Highest Lowest
//Pivot
H = security(syminfo.tickerid,res,high[1],barmerge.gaps_off, barmerge.lookahead_on)
L = security(syminfo.tickerid,res,low[1],barmerge.gaps_off, barmerge.lookahead_on)
C = security(syminfo.tickerid,res,close[1],barmerge.gaps_off,
barmerge.lookahead_on)

// Fibonacci Pivots
pivot = (H + L + C)/3
R = pivot + (H - L) * HLPeriod
S = pivot - (H - L) * HLPeriod

shortCondition = high > S and close < S

LO = valuewhen(shortCondition,close,0) + SK
SL = LO + SLL
TP = LO - TPP

shortcon = shortCondition and month==montha and window


//entry
if shortcon and strategy.position_size == 0
strategy.entry("My Short Entry Id", strategy.short,limit=LO)
strategy.exit("close",stop=SL,limit=TP, comment="close")
//cancel

if change(time(res))
strategy.cancel_all()
strategy.close_all()

//for debug
plot(R, style=plot.style_stepline)
plot(S, style=plot.style_stepline)
plot(strategy.position_size < 0 ? SL : na, style=plot.style_linebr,
color=color.red, linewidth=1, title="Short Fixed SL")

plot(strategy.position_size < 0 ? TP : na, style=plot.style_linebr,


color=color.green, linewidth=1, title="Short Take Profit")

You might also like