Trader avec la moyenne de hull pour détecter les retournements
Descriptif issue de la plateforme:
Hull Moving Average Strategy
2 X HMA’s,
1st HMA on current price (recommended source OPEN)
2nd HMA on previous candle. signal on crossover.
Buy and Sell signals on chart, red & green view pane (Green Buy, Red Sell)
Code issue de la plateforme :
Hull Moving Average Swing Trader
strategy(“Hull Moving Average Swing Trader”, shorttitle=”HMA_Swing_Trader”, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_order_fills=true, calc_on_every_tick=true, pyramiding=0)
hullperiod = input(title=”HullMA Period”, type=input.integer, defval=210, minval=1)
price = input(open, type=input.source, title=”Price data”)
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=2020, 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 n2ma = 2 * wma(price, round(hullperiod / 2)) nma = wma(price, hullperiod) diff = n2ma – nma sqn = round(sqrt(hullperiod)) n2ma1 = 2 * wma(price[1], round(hullperiod / 2)) nma1 = wma(price[1], hullperiod) diff1 = n2ma1 – nma1 n1 = wma(diff, sqn) n2 = wma(diff1, sqn) Hull_Line = n1 / n1 * n2 Hull_retracted = if n1 > n2
Hull_retracted = Hull_Line – 2
else
Hull_retracted = Hull_Line + 2
c1 = Hull_retracted + n1 – price
c2 = Hull_retracted – n2 + price
c4 = n1 > n2 ? color.green : color.red
c2p = plot(c2, color=color.black, linewidth=1)
c3p = plot(price, color=color.black, linewidth=1)
fill(c3p, c2p, color=c4, transp=75)
//plot(cross(c1, c2) ? c1 : na, style=plot.style_circles, color=c4, linewidth=4)
if price < c2 strategy.close(“BUY”, when=window()) if price > c2
strategy.close(“SELL”, when=window())
if price > c2 and price[1] > c1
strategy.entry(“BUY”, strategy.long, when=window())
if price < c1 and price[1] < c2
strategy.entry(“SELL”, strategy.short, when=window()) //
lIEN :
https://fr.tradingview.com/script/j60hYGuY-Hull-Moving-Average-Swing-Trader/
Merci pour votre aide