ZigoParticipant
Master
@ nonetheless
I wrote your method in backtest
Defparam cumulateorders = false
once p=13
Hull= Weightedaverage[round(SQRT(p))]( 2*Weightedaverage[round(p/2)](close)-Weightedaverage[p](close))
c1 = HULL > HULL[1] and HULL[1]<HULL[2]
c2 = HULL < HULL[1] and HULL[1]>HULL[2]
if c1 and not longonmarket then
buy 1 share at market
endif
if c2 then
sell at market
endif
if c2 and not onmarket then
sellshort 1 share at market
endif
if shortonmarket and c1 then
exitshort at market
endif
set stop ploss 75
set target pprofit 50
yes, but why 144 seconds, and why only 1 day of backtest?
Looks good, but 144 seconds … very non-standard Time Frame?
Instead of fitting Conditions to a TF, fit a TF to the Conditions … why not? 🙂
why only 1 day of backtest?
We have to fit to another TF for the next day!? 🙂
@nonetheless, tried to incorporate also your HULL 34 idea using bollinger%
I simply pick 10s (no reason, just any small TF to handle quick decision like manual trade), result seems ok, however just 1 week of data, for sure need forward test. But maybe you can see if the trade quality is close to your expectation.
Many variables are just simply out of heart, only the gap is optimized.
// Definition of code parameters
DEFPARAM CumulateOrders = false // Cumulating positions deactivated
DEFPARAM preloadbars = 5000
Ctime = time >= 080000 and time <= 163000
//HULL 13
TIMEFRAME(2 minutes)
Period13 = 13
inner13 = 2*weightedaverage[round( Period13/2)](close)-weightedaverage[Period13](close)
HULL13 = weightedaverage[round(sqrt(Period13))](inner13)
C1 = HULL13 > HULL13[1] and HULL13[1] < HULL13[2]
C2 = HULL13 < HULL13[1] and HULL13[1] > HULL13[2]
//ATR 13
atr13 = AverageTrueRange[Period13](close)
//HULL13min = MIN(HULL13, HULL13[1])
//HULL13min = MIN(HULL13min, HULL13[2])
//HULL13max = MAX(HULL13, HULL13[1])
//HULL13max = MAX(HULL13max, HULL13[2])
gap = 1.2
C3 = close > HULL13 + gap * atr13
C4 = close < HULL13 - gap * atr13
//HULL 34
Period34 = 34
strend = 2
inner34 = 2*weightedaverage[round( Period34/2)](typicalprice)-weightedaverage[Period34](typicalprice)
HULL34 = weightedaverage[round(sqrt(Period34))](inner34)
STDDEVtrend = STD[Period34]
bollstrend = strend * STDDEVtrend
bolltrendUP = HULL34 + bollstrend
bolltrendDOWN = HULL34 - bollstrend
IF bolltrendUP = bolltrendDOWN THEN
bolltrendPercent = 50
ELSE
bolltrendPercent = 100 * (close - bolltrendDOWN) / (bolltrendUP - bolltrendDOWN)
ENDIF
C5 = bolltrendPercent > 55 AND bolltrendPercent > bolltrendPercent[1] AND bolltrendPercent[1] > bolltrendPercent[2]
C6 = bolltrendPercent < 45 AND bolltrendPercent < bolltrendPercent[1] AND bolltrendPercent[1] < bolltrendPercent[2]
C7 = 1 //bolltrendPercent > 45 OR bolltrendPercent > bolltrendPercent[1]
C8 = 1 //bolltrendPercent < 55 OR bolltrendPercent < bolltrendPercent[1]
TIMEFRAME(default)
SL = 0.5
// Conditions to enter long position
IF NOT OnMarket AND Ctime AND close > open AND C1 AND C3 AND NOT C6 AND C7 THEN
BUY 1 CONTRACTS AT MARKET
SET STOP %LOSS SL
//SET TARGET %PROFIT SL
ENDIF
// Conditions to exit long positions
If LongOnMarket AND C2 AND C6 AND close > POSITIONPRICE THEN
SELL AT MARKET
ENDIF
//If LongOnMarket AND C2 AND C6 AND close < POSITIONPRICE THEN
//SELL AT MARKET
//ENDIF
// Conditions to enter short positions
IF NOT OnMarket AND Ctime AND close < open AND C2 AND C4 AND NOT C5 AND C8 THEN
SELLSHORT 1 CONTRACTS AT MARKET
SET STOP %LOSS SL
//SET TARGET %PROFIT SL
ENDIF
// Conditions to exit short positions
IF ShortOnMarket AND C1 AND C5 AND close < POSITIONPRICE THEN
EXITSHORT AT MARKET
ENDIF
//IF ShortOnMarket AND C1 AND C5 AND close > POSITIONPRICE THEN
//EXITSHORT AT MARKET
//ENDIF
//
// Stops and targets : Enter your protection stops and profit targets here
//====== Trailing Stop mechanism - start =====
stepfactor1 = 0.5
stepfactor2 = 0.05
trailingstart = (stepfactor1 * SL/100 * tradeprice(1) ) / pointsize
trailingstep = (stepfactor2 * SL/100 * tradeprice(1) ) / pointsize
//resetting variables when no trades are on market
if not onmarket then
priceexit = 0
endif
//case LONG order
if longonmarket then
//first move (breakeven)
IF priceexit=0 AND close-tradeprice(1) >= trailingstart*pointsize THEN
priceexit = tradeprice(1) + trailingstep*pointsize
ENDIF
//next moves
IF priceexit>0 THEN
priceexit = priceexit + trailingstep*pointsize
ENDIF
endif
//case SHORT order
if shortonmarket then
//first move (breakeven)
IF priceexit=0 AND tradeprice(1)-close >= trailingstart*pointsize THEN
priceexit = tradeprice(1) - trailingstep*pointsize
ENDIF
//next moves
IF priceexit>0 THEN
priceexit = priceexit - trailingstep*pointsize
ENDIF
endif
if longonmarket and priceexit>0 then
sell at priceexit stop
if low crosses under priceexit then
sell at market
endif
endif
if shortonmarket and priceexit>0 then
exitshort at priceexit stop
if high crosses over priceexit then
exitshort at market
endif
endif
//====== Trailing Stop mechanism - end =====
looks interesting, but 10 seconds is too short for me. Not enough backtest to run on auto and manually there’d be too many false signals, chopping and changing.
Decent result for those few days though…
Actually it is multiple time frame, signal is at 2 minutes TF. 10s is execution time frame…
ZigoParticipant
Master
The unity of time is the second. I intended to work with 3 different TF .
144 sec is the only Fibonacci number when multiplier with 5 that gives round numbers:
144*5 (720 sec or 12 min)
144* 5², (3600 sec or 60 min or 1 hour)
144*5³ (18000 sec or 300 min or exactly 5 hours)
……..
signal is at 2 minutes TF. 10s is execution time frame…
Works good on DJI at signal 1 min TF and 5 sec execution over 100k bars.
Thank you for sharing Dow Jones.
You should work on yours some more Zigo … I added a MA Filter and got attached!
Spread = 5 and SL and TP // out.
Hello @GraHal, can you pass the bot with the change, please?
I tried to set up the net and reverse simultaneously trade and can’t see how to do it. I tested it in a live trade set to net off, and clicked to place a reverse order and it closed the existing position but didn’t open a new one.
I’m with IG and just called support who said it wasn’t possible but agreed it was a valid suggestion and would try to include it at some point. Any ideas welcome, cheers!
Here you go Josef … a v1 of Zigo’s code (v0) above.
It might be an alternative to use Hull(34) as a Filter then it nearer to Nonetheless manual strategy?
I quickly added simple MA and it worked so I set it going on Demo Forward Test! 🙂
//-------------------------------------------------------------------------
// Main code : ZigoNone DJI S144 v1
//-------------------------------------------------------------------------
Defparam cumulateorders = false
P = 13
A7 = 10
A14 = 70
Hull= Weightedaverage[round(SQRT(p))]( 2*Weightedaverage[round(p/2)](close)-Weightedaverage[p](close))
c1 = HULL > HULL[1] and HULL[1]<HULL[2]
c2 = HULL < HULL[1] and HULL[1]>HULL[2]
if c1 and Close > Average[A7](close) then
buy 1 share at market
endif
//if c2 then
//sell at market
//endif
if c2 and Close < Average[A14](close) then
sellshort 1 share at market
endif
//if shortonmarket and c1 then
//exitshort at market
//endif
//set stop ploss 75
//set target pprofit 50
144 sec is the only Fibonacci number when multiplier with 5 that gives round numbers:
interesting to use a Fibonacci relation with TFs, hadn’t thought of that.
Shame that, even though 144 secs is longer than 2mins, a 200k backtest is only 5 days as opposed to 13 months. Another weird quirk of PRT .
ZigoParticipant
Master
The only reason that I use irregular TF is, that the entire world use regular TF.
B.t.w. the code for Hull (13) with arrows (used in the main frame)
once p=13
H13=Weightedaverage[round(SQRT(round(0.89*p)))]( 2*Weightedaverage[round(round(0.89*p)/2)](close)-Weightedaverage[round(0.89*p)](close))
c1 = H13 > H13[1] and H13[1]<H13[2]
c2 = H13 < H13[1] and H13[1]>H13[2]
if c1 then
DRAWARROWUP(barindex, low-AverageTrueRange[14](close))coloured(0,255,0,255)
elsif c2 then
DRAWARROWDOWN(barindex, high +AverageTrueRange[14](close))coloured(255,0,0,255)
endif
return H13 as"Hull 13"
B.t.w.