657 8 72
Two Moving_Average cross's & Daily_Candle cross
Based on Hull_MA
Developed by Alan Hull, it is an indicator, that solves the problem with making a moving average more reactive to current price activity. The Hull Moving Average almost eliminates lag and manages to improve smoothing.
The HMA manages to stick to rapid changes in price activity, as it has superior smoothing over a Simple Moving Average of the same period. The HMA employs Weighted Moving Averages (WMA) and dampens the smoothing effect. It can be calculated as follows:
HMA(n) = WMA(2*WMA(n/2) – WMA(n)), sqrt(n))
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
//SeaSide420
strategy("SS420FX", overlay=true, default_qty_type=strategy.percent_of_equity, max_bars_back=720, default_qty_value=100, calc_on_order_fills= true, calc_on_every_tick=true, pyramiding=0)
q=input(title="HullMA Short",type=integer,defval=14)
z=input(title="HullMA Long",type=integer,defval=14)
dt = input(defval=0.0010, title="Decision Threshold", type=float, step=0.0001)
SL = input(defval=-50000.00, title="Stop Loss in $", type=float, step=1)
TP = input(defval=100000.00, title="Target Point in $", type=float, step=1)
ot=1
n2ma=2*wma(close,round(q/2))
nma=wma(close,q)
diff=n2ma-nma
sqn=round(sqrt(q))
n2ma1=2*wma(close[1],round(q/2))
nma1=wma(close[1], q)
diff1=n2ma1-nma1
sqn1=round(sqrt(q))
n1=wma(diff,sqn)
n2=wma(diff1,sqn)
z2ma=2*wma(close[11],round(z/2))
zma=wma(close[11],z)
ziff=n2ma-nma
zqn=round(sqrt(z))
z2ma1=2*wma(close[12],round(z/2))
zma1=wma(close[12], z)
ziff1=n2ma1-nma1
zqn1=round(sqrt(z))
z1=wma(diff,sqn)
z2=wma(diff1,sqn)
z1e=z1>z2?green:black
z2e=z1>z2?black:red
z3e=z1>z2?green:red
n1e=plot(z1, title="HMA1", color=z1e, linewidth=2, offset=2)
n2e=plot(z2, title="HMA2", color=z2e, linewidth=2, offset=2)
fill(n1e, n2e, color=z3e, transp=80)
confidence=(security(tickerid, 'D', close)-security(tickerid, 'D', close[1]))/security(tickerid, 'D', close[1])
closelong = n1<n2 and close<n2 and confidence<dt or strategy.openprofit<SL or strategy.openprofit>TP
if (closelong)
    strategy.close("Long")
closeshort = n1>n2 and close>n2 and confidence>dt or strategy.openprofit<SL or strategy.openprofit>TP
if (closeshort)
    strategy.close("Short")
longCondition = n1>n2 and z1>z2 and strategy.opentrades<ot and confidence>dt and close>n1
if (longCondition)
    strategy.entry("Long",strategy.long)
shortCondition = n1<n2 and z1<z2 and strategy.opentrades<ot and confidence<dt and close<n1 
if (shortCondition)
    strategy.entry("Short",strategy.short)
SeaSide420 PRO
4 months ago
just in case someone doesn't already know, this strategy repaints.
that means the percent-profitable is not correct. it is in reality much lower, around 60%
when signal appears, if price keep in that direction, then ok, but if retracts back through the signals condition level,
and you refresh the page you will see the signal disappear!
This can be very frustrating to people who do not yet know about the repainting.
All i can say is, don't rely 100% on this strategy, it is more of a confirmation tool, to be added to your already existing
understanding of the market movements.
Bringing the SL setting in tight means you dont have to refresh the page to see the signal be wrong.
And will bring the Percent-profitable down to a realistic amount, and therefore you'll see more realistic results, and then can test this HullMA strategy on different pairs etc...
and see if my Dual HullMa cross & DailyCandle cross combination helps you at all with speculating the Forex market.
Reply
ale.agos SeaSide420
4 months ago
Just a question about repaint... I'm new in Tradingview so I don't know more about the problem. If I well understand repaint occurs when price (close I guess looking at your code) change due to new tick arrival. So repaint should influence just the live use of the strategy and not back-test on past data due to the fact that they are fix values (each candle has fix value of OCLH). If I'm right I understand your warning about use of strategy in live but we should have affordable results in backtest. I'm right or not? Also, with the goal to overtake the problem of repaint, what about use it as an indicator (as you suggested) looking at signal on last candle (not on candle who is growing)? Hope to be clear and sorry for my bad english! :)
Reply
SeaSide420 PRO ale.agos
4 months ago
hi, if you reduce the Stop Loss amount, then the script can close position when it goes wrong, and then can open new position. So then it is more accurate to follow as an indicator.
Also then the results are more realistic. You could manually simulate this strategy by having four HullMA indicators on your chart, and by looking at 3 different timeframes at once.
5minute,60minute,Daily
HullMA1 = Timeframe-5m, period 14, step 0
HullMA2 = Timeframe-5m,period 14,step 1
HullMA3 = Timeframe-60m, period 14, step 0
HullMA4 = Timeframe-60m,period 14,step 1
if hullMA1 is above hullMa2 and hullma3 is above hullma4 then open buy
if hullMA1 is below hullMa2 and hullma3 is below hullma4 then open sell
if price is above the 5mHullMA then buy only
if price is below the 5mHullMA then sell only
and the Daily cross is simply - if price is below previous candle close then sell only
if price is above previous candle close then buy only
those are the conditions for the strategy.
But just try reducing the SL and you will see better results.
I dont have low SL because then the chart gets a lot of signals and closes on it,
I just keep in mind when it might be going to repaint, and refresh page, and then have clean chart.
Once the "open" and "close" words pile up on top of each other it gets a bit messy.
the tighter the SL, the more opening and closing it will do.
But then the Percent-profitable will show more realistic results for the backtest of strategy on different pairs.
because no, the backtest results are not realistic with high SL, because it does not show all the times it was wrong.
Reply
ale.agos SeaSide420
4 months ago
Hi and thanks a lot for your kindly answer and all info about your method. I will try to do some test with the goal to see how it work. Due to the fact that my broker ( IG ) give me the possibility to use Prorealtime trading platform maybe I could try to convert the code with the goal to use / backtest it with Prorealtime and see what happen there. I know that prorealtime execute code every single candle (not every tick because when you are coding it ask you if you want to buy/sell at close or open so I guess it evaluate the candle when is complete at the end of every single timeframe) so it should not have repaint.
Reply
Justin PRO SeaSide420
4 months ago
Is there an Alert for this one?
Reply
SeaSide420 PRO Justin
4 months ago
there is now,
SS420FX
Reply
SeaSide420 PRO SeaSide420
4 months ago
oh, what i mean is there is now a SS420FX indicator built to be Alert friendly
because cant put alert on strategy
Reply