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/16/2021 at 5:05 PM #169817
Thank you. On my charting artist I can only have a history of 1 year. If anyone could prove it for many more years, I’d appreciate it if you’d pass the statistics. Greetings.
08/25/2021 at 6:45 PM #176233Excellent bit of code. I’m not getting the same results as you so I guess I need to understand it now and work out what changes are required to make it work today.
Thanks for sharing.
12/26/2022 at 2:28 PM #206329Hi,
I apply this strategy on daily SPY but I got error. Is this startegy suitable for daily SPY?
12/26/2022 at 2:49 PM #20633107/20/2023 at 1:02 PM #217933Interesting code. I made some adjustments to adapt it to the DAX index on the 5 minute timeframe. I would say it’s a high risk it’s overly optimized though.
Here’s the code123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251DEFPARAM CumulateOrders = falseDEFPARAM PRELOADBARS = 5000atrperiod = 18bolltrendperiod = 24bolltrendperiod2 = 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(30 minutes, updateonclose)ma1 = Average[45](typicalPrice)ma2 = Average[15](typicalPrice)c4b = (ma1 >= ma2)ma3 = Average[15](typicalPrice)ma4 = Average[55](typicalPrice)c4s = (ma3 <= ma4)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 = 0buyday = (dlow(0) < dlow(1) or dhigh(0) < dhigh(1)) and (dhigh(0) < dhigh(1)) and (dlow(0) < dlow(1)) and (dlow(0) > dlow(1) xor dhigh(0) < dhigh(1)) and c4bshortday = (dlow(0) < dlow(1)) and (dlow(0) < dlow(1) or dhigh(0) < dhigh(1)) and c4sIF C1 THEN //when a pullback occurs...IF timeok AND Not OnMarket AND samebarsignal = 0 and buyday 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 and shortday 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 ===== -
AuthorPosts
Find exclusive trading pro-tools on