Jump – a 5 min strategy
Forums › ProRealTime English forum › ProOrder support › Jump – a 5 min strategy
- This topic has 9 replies, 5 voices, and was last updated 3 years ago by
monkeys nuts.
-
-
11/21/2021 at 7:33 PM #181993
Hello,
This strategy will look for a new highs (or lows for shorts) over the last N candles and, in conjunction with 2 x entry filters will take a position. I also added the volatility filter provided by JS in a recent post – thank you, this helped improve overall performance.
https://www.prorealcode.com/topic/filter-for-too-high-volatility/#post-180817
I had originally developed this strategy to run on a daily time frame, but have found that it runs just as well on lower time frames. 5 minutes is the lowest setting I would consider.
Risk Mgt – For initial Profit Target and Stop Loss it uses a simple ATR methodology, with a hard $ value as a backstop to the downside. The trailing stop is taken from another great strategy posted on this great site.
For the walk forward results in the screenshots provided the settings were as follows, running on an EU timezone;
Capital 10k
Position size 1
Spread 2.6
NASDAQ
5 min
Further testing:
1 – Need to optimise the short side as it doesn’t perform as well as the longs do. Will test different look back periods to try and improve this.
2 – Try to reduce how much the strategy gives back overall looking at the Losses Only metric and reflected in the Gain/Loss Ratio, without curve fitting.
All observations, feedback and questions are always welcome.
Thank you
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214//==========================================================================================================// Code: INCUBATOR Jump// Source: General research// Version 3// Index: NASDAQ// TF: 5 min (adapted from Daily)// TZ: EU// Spread: 2.6// Notes: v1.1 Core strategy, Long only// v2.1 Added Short entry// v3.1 Applied Entry Filter on 60 and 30 minute timeframe// v3.2 19/11/21 Optimised Trailing Stop for 5 minute timeframe (Entry Filter and Criteria remain the same)// Added Volatility filter to avoid enter trades during choppy marekt conditions// Author: JS// https://www.prorealcode.com/topic/filter-for-too-high-volatility/#post-180817//==========================================================================================================DEFPARAM CUMULATEORDERS = false//Risk ManagementPositionSize=1sl = PositionSize *110 //1100entry3pbase = (HIGHEST[16](High)+LOWEST[16](Low)) / 2off = 2 * AverageTrueRange[15](Close)//Filter FilterTimeframe(60 MINUTES)indicator1 = average[300] //175CB1 = close > indicator1CS1 = close < indicator1Timeframe(30 MINUTES)indicator2 = ADX[14] //14CB2 = (indicator2 >= 20)CS2 = (indicator2 <= 20)//Volatility Filter: Avoid entry during choppy marketsxPVolatility = (Std[3](Close) / Close) * 100F1 = xPVolatility < 0.29//GRAPH xPVolatility//Entry CriteriaIF NOT LongOnMarket AND Close>Close[24] AND CB1 AND CB2 and opendayofweek <>5 THENBUY PositionSize CONTRACTS AT entry3pbase + off STOPENDIFIF NOT ShortOnMarket AND Close<Close[24] AND CS1 AND CS2 and opendayofweek <>2 AND F1 THENSELLSHORT PositionSize CONTRACTS AT entry3pbase - off STOPENDIF//Break evenbreakevenPercent = 0.2PointsToKeep = 15startBreakeven = tradeprice(1)*(breakevenpercent/100)once breakeven = 1//1 on - 0 off//reset the breakevenLevel when no trade are on marketif breakeven>0 thenIF NOT ONMARKET THENbreakevenLevel=0ENDIF// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeepENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIF// --- end of BUY SIDE ---IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeepENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPENDIFendif//--------------------------------------------------------------------------------------------------------------------------------------------------// trailing atr stoponce trailingstoptype = 1 // trailing stop - 0 off, 1 ononce tsincrements = .1 //05 // set to 0 to ignore tsincrementsonce tsminatrdist = 5once tsatrperiod = 14 // ts atr parameteronce tsminstop = 12 // ts minimum stop distanceonce tssensitivity = 1 // [0]close;[1]high/lowif trailingstoptype thenif barindex=tradeindex thentrailingstoplong = 3 // ts atr distancetrailingstopshort = 3 // ts atr distanceelseif longonmarket thenif tsnewsl>0 thenif trailingstoplong>tsminatrdist thenif tsnewsl>tsnewsl[1] thentrailingstoplong=trailingstoplongelsetrailingstoplong=trailingstoplong-tsincrementsendifelsetrailingstoplong=tsminatrdistendifendifendifif shortonmarket thenif tsnewsl>0 thenif trailingstopshort>tsminatrdist thenif tsnewsl<tsnewsl[1] thentrailingstopshort=trailingstopshortelsetrailingstopshort=trailingstopshort-tsincrementsendifelsetrailingstopshort=tsminatrdistendifendifendifendiftsatr=averagetruerange[tsatrperiod]((close/10))/1000//tsatr=averagetruerange[tsatrperiod]((close/1)) // (forex)tgl=round(tsatr*trailingstoplong)tgs=round(tsatr*trailingstopshort)if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thentsmaxprice=0tsminprice=closetsnewsl=0endifif tssensitivity thentssensitivitylong=hightssensitivityshort=lowelsetssensitivitylong=closetssensitivityshort=closeendifif longonmarket thentsmaxprice=max(tsmaxprice,tssensitivitylong)if tsmaxprice-tradeprice(1)>=tgl*pointsize thenif tsmaxprice-tradeprice(1)>=tsminstop thentsnewsl=tsmaxprice-tgl*pointsizeelsetsnewsl=tsmaxprice-tsminstop*pointsizeendifendifendifif shortonmarket thentsminprice=min(tsminprice,tssensitivityshort)if tradeprice(1)-tsminprice>=tgs*pointsize thenif tradeprice(1)-tsminprice>=tsminstop thentsnewsl=tsminprice+tgs*pointsizeelsetsnewsl=tsminprice+tsminstop*pointsizeendifendifendifif longonmarket thenif tsnewsl>0 thensell at tsnewsl stopendifif tsnewsl>0 thenif low crosses under tsnewsl thensell at market // when stop is rejectedendifendifendifif shortonmarket thenif tsnewsl>0 thenexitshort at tsnewsl stopendifif tsnewsl>0 thenif high crosses over tsnewsl thenexitshort at market // when stop is rejectedendifendifendifendifif onmarket thenif dayofweek=0 and (hour=0 and minute>=57) and abs(dopen(0)-dclose(1))>50 and positionperf(0)>0 thenif shortonmarket and close>dopen(0) thenexitshort at marketendifif longonmarket and close<dopen(0) thensell at marketendifendifendif//==== ATR Profit Target & Stop Loss ====atrperiod = 20atr = AverageTrueRange[atrperiod]p = 7 //6l = 8 //7 optimised to 4set target profit p*atrset stop ploss l*atrSET STOP $LOSS sl5 users thanked author for this post.
11/22/2021 at 9:05 PM #18208011/22/2021 at 9:12 PM #182081Would u like to explain this 🙂
Time open12345678910if onmarket thenif dayofweek=0 and (hour=0 and minute>=57) and abs(dopen(0)-dclose(1))>50 and positionperf(0)>0 thenif shortonmarket and close>dopen(0) thenexitshort at marketendifif longonmarket and close<dopen(0) thensell at marketendifendifendif11/23/2021 at 4:29 AM #18208511/23/2021 at 11:52 AM #182103if you want to run this on a 5min TF, surely you need to add Timeframe(default) somewhere? like just above the volatility?
also, might be improved to keep the entry within the NDQ open hours
Tradetime = time >=143000 and time <210000//UK
in the ATR trail you want:
once tsminstop = 4
as that’s a given by IG
this is what I get on 1m bar BT
11/23/2021 at 11:58 AM #182105Is this the backtest with ur adjustments, nonetheless?
11/23/2021 at 12:08 PM #182106no, that’s the original. i haven’t done any other tests, just my first thoughts.
11/23/2021 at 1:50 PM #182109Hi
My apologies, I see I posted the wrong code for the strategy you see in the screenshots. Will rectify when I get back.
1 user thanked author for this post.
11/24/2021 at 5:45 PM #182218Working this on to a 15 min time frame. The 1M back test shows the downside testing lower time frame strategies on the standard 200k bars, and you don’t get to see how it performs through periods of real market stress.
11/26/2021 at 2:06 PM #182334There is something there. I might try having a go at creating a 15 min version myself. Higher time frames are definitely the way forward.
1 user thanked author for this post.
-
AuthorPosts