Strategy XXDJI-M5-EngulfingGap
Forums › ProRealTime English forum › ProOrder support › Strategy XXDJI-M5-EngulfingGap
- This topic has 34 replies, 13 voices, and was last updated 1 year ago by ProRealAlgos.
-
-
05/12/2020 at 7:15 PM #131368
Hi everyone,
Here is a new strategy on Wall Street/DJI 5 min TF based on the engulfing bar with range at least 1 ATR. Incorporated 2 Bollinger Band as trend filter.
DLS code is added to avoid high spread period and for skipping trade during major market open to avoid less reliable engulfing bar. Time Zone used is UTC+08:00, please change the time zone in PRT to obtain same result.
Variables atrperiod, bolltrendperiod and bolltrendperiod2 are used for optimization. Other variables are just taking moderate value, not being fully optimized.
Looking forward for your suggestion and ideas of improvement.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236DEFPARAM CumulateOrders = falseDEFPARAM PRELOADBARS = 5000//atrperiod = 18//bolltrendperiod2 = 24//bolltrendperiod2 = 80SL = 100stepfactor1 = 1stepfactor2 = 0.25RR = 4longbar = 0shortbar = 0longbarmultiplier = 1shortbarmultipler = 1.5strend = 2strend2 = 2bollBullLevel = 50bollBearLevel = 50bolltrendMAType = 5bolltrendMAType2 = 5//// --------- UK DAY LIGHT SAVINGS MONTHS ---------------- //mar = month = 3 // MONTH STARToct = month = 10 // MONTH ENDIF ( dayofweek >= 0 and mar AND 31-day<7 ) OR ( month > 3 AND month < 10 ) OR ( oct AND 31-day > 6 ) OR (dayofweek = 4 AND oct AND day<31) OR (dayofweek = 3 AND oct AND day+1<31) OR (dayofweek = 2 AND oct AND day+2<31) OR (dayofweek = 1 AND oct AND day+3<31) OR (dayofweek = 0 AND oct AND day+4<31) OR (dayofweek = 5 AND oct AND 31-day<7) THENUKDLS=1ELSEUKDLS=0ENDIF//GRAPH UKDLS as "UKDLS"// --------- US DAY LIGHT SAVINGS MONTHS ---------------- //mar = month = 3 // MONTH STARTnov = month = 11 // MONTH ENDIF (month > 3 AND month < 11) OR (mar AND day>14) OR (mar AND day-dayofweek>7) OR (nov AND day<=dayofweek AND day<7) THENUSDLS=010000ELSEUSDLS=0ENDIF//GRAPH USDLS as "USDLS"// --------- AU DAY LIGHT SAVINGS MONTHS ---------------- //oct = month = 10 // MONTH STARTapr = month = 4 // MONTH ENDIF (month > 10 OR month < 4) OR (apr AND day <=7 AND day<=dayofweek) OR (oct AND day > 7) OR (oct AND day <= 7 AND day>dayofweek) THENAUDLS=010000ELSEAUDLS=0ENDIF//GRAPH AUDLS as "AUDLS"//GRAPH dayofweek//GRAPH day//Time in UTC+8Rest0Minutes = 000000Rest15Minutes = 001500HighSpread1Start = 051500- USDLSHighSpread1End = 053000 - USDLSHighSpread2Start = 060000 - USDLSHighSpread2End = 070000 - USDLSIGAlmostClose = 054500 - USDLSIGOpen = 070000 - USDLSASXOpen = 080000 - AUDLSTSEOpen = 080000SSEOpen = 091500HKEOpen = 093000FWBOpen = 150000 - UKDLSLSEOpen = 160000 - UKDLSNYSEOpen = 223000 - USDLS//Skip high spreadtimeok = NOT(time >=HighSpread1Start AND time <=HighSpread1End) AND NOT(time >=HighSpread2Start AND time <=HighSpread2End)//Skip 15 mins when IG almost closetimeok = timeok AND NOT (time >=IGAlmostClose AND time <= IGAlmostClose + Rest15Minutes)//Skip when IG just open the markettimeok = timeok AND NOT (time >=IGOpen AND time <=IGOpen + Rest0Minutes)//Skip when ASX (first market) just open the markettimeok = timeok AND NOT (time >=ASXOpen AND time <=ASXOpen + Rest0Minutes)//Skip when TSE (first major) just open the markettimeok = timeok AND NOT (time >=TSEOpen AND time <=TSEOpen + Rest0Minutes)//Skip when SSE just open the markettimeok = timeok AND NOT (time >=SSEOpen AND time <=SSEOpen + Rest0Minutes)//Skip when HKE just open the markettimeok = timeok AND NOT (time >=HKEOpen AND time <=HKEOpen + Rest0Minutes)//Skip when FWB just open the markettimeok = timeok AND NOT (time >=FWBOpen AND time <=FWBOpen + Rest0Minutes)//Skip when LSE just open the markettimeok = timeok AND NOT (time >=LSEOpen AND time <=LSEOpen + Rest0Minutes)//Skip when NYSEjust open the markettimeok = timeok AND NOT (time >=NYSEOpen AND time <=NYSEOpen + Rest0Minutes)once bolltrendBull = 1once bolltrendBear = 1//bolltrendperiod = 50//strend = 2bolltrendMA = average[bolltrendperiod, bolltrendMAType](close)//50,1STDDEVtrend = STD[bolltrendperiod]bolltrendUP = bolltrendMA + strend * STDDEVtrendbolltrendDOWN = bolltrendMA - strend * STDDEVtrendIF bolltrendUP = bolltrendDOWN THENbolltrendPercent = 50ELSEbolltrendPercent = 100 * (close - bolltrendDOWN) / (bolltrendUP - bolltrendDOWN)ENDIF//bolltrendperiod = 50//strend = 2bolltrendMA2 = average[bolltrendperiod2, bolltrendMAType2](close)//50,1STDDEVtrend2 = STD[bolltrendperiod2]bolltrendUP2 = bolltrendMA2 + strend2 * STDDEVtrend2bolltrendDOWN2 = bolltrendMA2 - strend2 * STDDEVtrend2IF bolltrendUP2 = bolltrendDOWN2 THENbolltrendPercent2 = 50ELSEbolltrendPercent2 = 100 * (close - bolltrendDOWN2) / (bolltrendUP2 - bolltrendDOWN2)ENDIFbolltrendBull = bolltrendPercent > bollBullLevel OR bolltrendPercent2 > bollBullLevelbolltrendBear = bolltrendPercent < bollBearLevel OR bolltrendPercent2 < bollBearLevel//====== Enter market - start =====timeframe(5 minutes, updateonclose)atr14 = AverageTrueRange[atrperiod](close)C1 = bolltrendBull AND close[1] < open[1] AND close > open AND close > open[1] AND close - open > longbarmultiplier * atr14 + longbarC2 = bolltrendBear AND close[1] > open[1] AND close < open AND close < open[1] AND open - close > shortbarmultipler * atr14 + shortbartimeframe(default)samebarsignal = 0IF C1 THEN //when a pullback occurs...IF timeok AND Not OnMarket AND samebarsignal = 0 THENBUY 1 CONTRACT AT MARKETSET STOP pLOSS SL //50TP = RR * SLSET TARGET pPROFIT TP //300ENDIFsamebarsignal = 1ENDIF// SHORT sideIF C2 THEN //when a pullback occurs...IF timeok AND Not OnMarket AND samebarsignal = 0 THENSELLSHORT 1 CONTRACT AT MARKETSET STOP pLOSS SL //50TP = RR * SLSET TARGET pPROFIT TP //300ENDIFsamebarsignal = 1ENDIF//====== Enter market - end =====//====== Exit market - start =====IF NOT ONMARKET THENENDIF//====== Exit market - end =====//====== Trailing Stop mechanism - start =====trailingstart = (stepfactor1 * SL ) / pointsizetrailingstep = (stepfactor2 * SL ) / pointsize//resetting variables when no trades are on marketif not onmarket thenpriceexit = 0endif//case LONG orderif longonmarket then//first move (breakeven)IF priceexit=0 AND close-tradeprice(1) >= trailingstart*pointsize THENpriceexit = tradeprice(1) + trailingstep*pointsizeENDIF//next movesIF priceexit>0 THENP2 = close-priceexit >= trailingstart*pointsizeIF P2 THENpriceexit = priceexit + trailingstep*pointsizeENDIFENDIFendif//case SHORT orderif shortonmarket then//first move (breakeven)IF priceexit=0 AND tradeprice(1)-close >= trailingstart*pointsize THENpriceexit = tradeprice(1) - trailingstep*pointsizeENDIF//next movesIF priceexit>0 THENP2 = priceexit-close >= trailingstart*pointsizeIF P2 THENpriceexit = priceexit - trailingstep*pointsizeENDIFENDIFendif//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPendif//====== Trailing Stop mechanism - end =====3 users thanked author for this post.
05/12/2020 at 8:50 PM #13138605/12/2020 at 10:50 PM #131401Strange works fine for me
05/13/2020 at 11:14 AM #13146805/14/2020 at 8:35 AM #13161105/14/2020 at 4:02 PM #131677wow! Great work! Thanks…
Where can I change the time zone? I do not know well Prorealtime yet..
05/15/2020 at 3:14 AM #131727Where can I change the time zone?
You can change the Time Zone from Options -> Platform options -> Time zones & Trading hours -> Display all data in this time zone: <select the UTC+0800>
06/01/2020 at 5:04 PM #134071Hi…
I can’t get much more than 8% on total return. I have changed the PR Time to read UTC+8. Is there anything else I may be doing wrong?
I am in UK using Spread bet demo if that helps?
Thanks
06/01/2020 at 5:57 PM #13408306/01/2020 at 6:22 PM #134086i got a syntaxe message
These are variables, if you are copying the code manually, then you need to add them into variable window. Otherwise, you can just import the .itf attached in the first thread. It includes the variables, spread, etc…
06/01/2020 at 6:25 PM #134087I may be doing wrong
Hard to say what problem, do you define the unit to 100k or 200k bar? Maybe post some screen shots to help.
06/04/2020 at 11:36 PM #13461009/02/2020 at 9:35 PM #143249AnonymousCa gave, quelquesoit le code qu’on copie y’a toujours une merde…
AnonymousInactiveTopics: 0Replies: 0Been thanked: 0 times09/02/2020 at 9:41 PM #143251Anonymousmême chose en téléchargeant directement le fichier .ITF
AnonymousInactiveTopics: 0Replies: 0Been thanked: 0 times09/03/2020 at 9:49 AM #143271Hi Lino,
I would asume you have to replace line 4/5/6 as below (remove the /):
//atrperiod = 18//bolltrendperiod2 = 24//bolltrendperiod2 = 80byatrperiod = 18bolltrendperiod2 = 24bolltrendperiod2 = 80On my side, when I want to launch the code I have the error message below “The code is invalide, please correct it” (translated from french), while i have no issues highlighted in the code itself.Can anyone explain me the task of lines 167 to 172 ? I have the feeling that some conditions are missing.123456//====== Enter market - end =====//====== Exit market - start =====IF NOT ONMARKET THENENDIFThank you Dow Jones for your work.
Alex.1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on