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. Discussion here, https://www.prorealcode.com/topic/strategy-xxdji-m5-engulfinggap/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
DEFPARAM CumulateOrders = false DEFPARAM PRELOADBARS = 5000 //atrperiod = 18 //bolltrendperiod2 = 24 //bolltrendperiod2 = 80 SL = 100 stepfactor1 = 1 stepfactor2 = 0.25 RR = 4 longbar = 0 shortbar = 0 longbarmultiplier = 1 shortbarmultipler = 1.5 strend = 2 strend2 = 2 bollBullLevel = 50 bollBearLevel = 50 bolltrendMAType = 5 bolltrendMAType2 = 5 //// --------- UK DAY LIGHT SAVINGS MONTHS ---------------- // mar = month = 3 // MONTH START oct = month = 10 // MONTH END IF ( 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) THEN UKDLS=1 ELSE UKDLS=0 ENDIF //GRAPH UKDLS as "UKDLS" // --------- US DAY LIGHT SAVINGS MONTHS ---------------- // mar = month = 3 // MONTH START nov = month = 11 // MONTH END IF (month > 3 AND month < 11) OR (mar AND day>14) OR (mar AND day-dayofweek>7) OR (nov AND day<=dayofweek AND day<7) THEN USDLS=010000 ELSE USDLS=0 ENDIF //GRAPH USDLS as "USDLS" // --------- AU DAY LIGHT SAVINGS MONTHS ---------------- // oct = month = 10 // MONTH START apr = month = 4 // MONTH END IF (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) THEN AUDLS=010000 ELSE AUDLS=0 ENDIF //GRAPH AUDLS as "AUDLS" //GRAPH dayofweek //GRAPH day //Time in UTC+8 Rest0Minutes = 000000 Rest15Minutes = 001500 HighSpread1Start = 051500- USDLS HighSpread1End = 053000 - USDLS HighSpread2Start = 060000 - USDLS HighSpread2End = 070000 - USDLS IGAlmostClose = 054500 - USDLS IGOpen = 070000 - USDLS ASXOpen = 080000 - AUDLS TSEOpen = 080000 SSEOpen = 091500 HKEOpen = 093000 FWBOpen = 150000 - UKDLS LSEOpen = 160000 - UKDLS NYSEOpen = 223000 - USDLS //Skip high spread timeok = NOT(time >=HighSpread1Start AND time <=HighSpread1End) AND NOT(time >=HighSpread2Start AND time <=HighSpread2End) //Skip 15 mins when IG almost close timeok = timeok AND NOT (time >=IGAlmostClose AND time <= IGAlmostClose + Rest15Minutes) //Skip when IG just open the market timeok = timeok AND NOT (time >=IGOpen AND time <=IGOpen + Rest0Minutes) //Skip when ASX (first market) just open the market timeok = timeok AND NOT (time >=ASXOpen AND time <=ASXOpen + Rest0Minutes) //Skip when TSE (first major) just open the market timeok = timeok AND NOT (time >=TSEOpen AND time <=TSEOpen + Rest0Minutes) //Skip when SSE just open the market timeok = timeok AND NOT (time >=SSEOpen AND time <=SSEOpen + Rest0Minutes) //Skip when HKE just open the market timeok = timeok AND NOT (time >=HKEOpen AND time <=HKEOpen + Rest0Minutes) //Skip when FWB just open the market timeok = timeok AND NOT (time >=FWBOpen AND time <=FWBOpen + Rest0Minutes) //Skip when LSE just open the market timeok = timeok AND NOT (time >=LSEOpen AND time <=LSEOpen + Rest0Minutes) //Skip when NYSEjust open the market timeok = timeok AND NOT (time >=NYSEOpen AND time <=NYSEOpen + Rest0Minutes) once bolltrendBull = 1 once bolltrendBear = 1 //bolltrendperiod = 50 //strend = 2 bolltrendMA = average[bolltrendperiod, bolltrendMAType](close)//50,1 STDDEVtrend = STD[bolltrendperiod] bolltrendUP = bolltrendMA + strend * STDDEVtrend bolltrendDOWN = bolltrendMA - strend * STDDEVtrend IF bolltrendUP = bolltrendDOWN THEN bolltrendPercent = 50 ELSE bolltrendPercent = 100 * (close - bolltrendDOWN) / (bolltrendUP - bolltrendDOWN) ENDIF //bolltrendperiod = 50 //strend = 2 bolltrendMA2 = average[bolltrendperiod2, bolltrendMAType2](close)//50,1 STDDEVtrend2 = STD[bolltrendperiod2] bolltrendUP2 = bolltrendMA2 + strend2 * STDDEVtrend2 bolltrendDOWN2 = bolltrendMA2 - strend2 * STDDEVtrend2 IF bolltrendUP2 = bolltrendDOWN2 THEN bolltrendPercent2 = 50 ELSE bolltrendPercent2 = 100 * (close - bolltrendDOWN2) / (bolltrendUP2 - bolltrendDOWN2) ENDIF bolltrendBull = bolltrendPercent > bollBullLevel OR bolltrendPercent2 > bollBullLevel bolltrendBear = 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 + longbar C2 = bolltrendBear AND close[1] > open[1] AND close < open AND close < open[1] AND open - close > shortbarmultipler * atr14 + shortbar timeframe(default) samebarsignal = 0 IF C1 THEN //when a pullback occurs... IF timeok AND Not OnMarket AND samebarsignal = 0 THEN BUY 1 CONTRACT AT MARKET SET STOP pLOSS SL //50 TP = RR * SL SET TARGET pPROFIT TP //300 ENDIF samebarsignal = 1 ENDIF // SHORT side IF C2 THEN //when a pullback occurs... IF timeok AND Not OnMarket AND samebarsignal = 0 THEN SELLSHORT 1 CONTRACT AT MARKET SET STOP pLOSS SL //50 TP = RR * SL SET TARGET pPROFIT TP //300 ENDIF samebarsignal = 1 ENDIF //====== Enter market - end ===== //====== Exit market - start ===== IF NOT ONMARKET THEN ENDIF //====== Exit market - end ===== //====== Trailing Stop mechanism - start ===== trailingstart = (stepfactor1 * SL ) / pointsize trailingstep = (stepfactor2 * SL ) / 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 P2 = close-priceexit >= trailingstart*pointsize IF P2 THEN priceexit = priceexit + trailingstep*pointsize ENDIF 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 P2 = priceexit-close >= trailingstart*pointsize IF P2 THEN priceexit = priceexit - trailingstep*pointsize ENDIF ENDIF endif //exit on trailing stop price levels if onmarket and priceexit>0 then EXITSHORT AT priceexit STOP SELL AT priceexit STOP endif //====== Trailing Stop mechanism - end ===== |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hello
Can you confirm this configuration for FRANCE ?
//Time in UTC+8
Rest0Minutes = 000000
Rest15Minutes = 001500
HighSpread1Start = 221500- USDLS
HighSpread1End = 223000 – USDLS
HighSpread2Start = 060000 – USDLS
HighSpread2End = 010000 – USDLS
IGAlmostClose = 224500 – USDLS
IGOpen = 000000 – USDLS
ASXOpen = 010000 – AUDLS
TSEOpen = 010000
SSEOpen = 021500
HKEOpen = 023000
FWBOpen = 080000 – UKDLS
LSEOpen = 090000 – UKDLS
NYSEOpen = 153000 – USDLS