TradingView
SeaSide420
15 Th02 2019 22:47

Hull MA & Pivot Strategy 

Bitcoin / US Dollar Perpetual Inverse Swap ContractBitMEX

Mô tả

Pivot points combined with HMA x2 crossover
(Hull moving average, 2 of them, if the price hits a pivot point in combination with the hull crossover being the same way, order entry)

Phát hành các Ghi chú

lagged 1 candle, to stop repainting
Bình luận
pouyakhalili
@SeaSide420 hello my friend, I'm new to writhing script and I need to know how can I fill background in hma, so can you help me and share this part of code to me?
i appreciate you
SeaSide420
@pouyakhalili,
//@version=3
// Pivot Profit Taker
strategy("Hull MA & Pivot Strategy", shorttitle="HMA_PVT", overlay=true, commission_type=strategy.commission.percent, commission_value=0.075, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_order_fills= false, calc_on_every_tick=true, pyramiding=0)
keh=input(title="Hull MA Period",type=integer,defval=8)
SL = input(defval=-9999999999, title="Stop Loss in $", type=float, step=1)
TP = input(defval=9999999999, title="Target Point in $", type=float, step=1)
price = input(ohlc4,type=source,title="Price data")
leftBars = input(3, title="Pivot LeftBars")
rightBars = input(2, title="Pivot RightBars")
FromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2017, title = "From Year", minval = 2017)
ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2017)
start = timestamp(FromYear, FromMonth, FromDay, 00, 00)
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)
window() => time >= start and time <= finish ? true : false
p=price
a2ma=2*wma(p,round(keh/2))
ama=wma(p,keh)
adiff=a2ma-ama
sqn=round(sqrt(keh))
a2ma1=2*wma(p[1],round(keh/2))
ama1=wma(p[1],keh)
adiff1=a2ma1-ama1
sqn1=round(sqrt(keh))
a1=wma(adiff,sqn)
a2=wma(adiff1,sqn)
c=a1<p?green:red
d=plot(a1, style = line, color=c, linewidth = 1, title='HMA1')
e=plot(a2, style = line, color=c, linewidth = 1, title='HMA2')
fill(d,e,color=c, transp=0, title='cloud')
bgcolor(color = c)
swh = pivothigh(leftBars, rightBars)
swl = pivotlow(leftBars, rightBars)
swh_cond = not na(swh)
hprice = 0.0
hprice := swh_cond ? swh : hprice[1]
le = false
le := swh_cond ? true : (le[1] and high[1] > hprice ? false : le[1])
if (le and a1[1]>a2[1])
strategy.entry("buy", strategy.long, comment="BUY", when=window(), stop=hprice + syminfo.mintick)
swl_cond = not na(swl)
lprice = 0.0
lprice := swl_cond ? swl : lprice[1]
se = false
se := swl_cond ? true : (se[1] and low[1] < lprice ? false : se[1])
if (se and a1[1]<a2[1])
strategy.entry("sell", strategy.short, comment="SELL", when=window(), stop=lprice - syminfo.mintick)
strategy.close_all(when = strategy.openprofit<SL or strategy.openprofit>TP)
//buy = price > price[1] and strategy.openprofit>0
//buy2 = price > price[1] and strategy.opentrades<1
//sell = price < price[1] and strategy.openprofit>0
//strategy.entry("buy", true, 1, when=buy2)
//strategy.entry("buy", true, 1, when=buy)
//strategy.entry("sell", false, 1, when=sell)
//alertlong = long?1:0
//alertshort = short?1:0
//plot(alertlong, color=green)
//plot(alertshort, color=red)
//alertcondition(long, "Long")
//alertcondition(short, "Short")
pouyakhalili
@SeaSide420, thanks a lot bro.
Msparky
send me your signals... I would like to follow
SeaSide420
Thêm nữa