Forums › ProRealTime English forum › ProOrder support › Strategy DayOpen Straddle for DAX › Reply To: Strategy DayOpen Straddle for DAX
11/19/2018 at 9:21 PM
#85224
something is really off here. When i look at my code who got in short yesterday, here is the code:
2 points for omx
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 |
//------------------------------------------------------------------------- // Main code : DailyOpen Straddle OMX NYY //------------------------------------------------------------------------- //------------------------------------------------------------------------- // Main Code : Straddle Dayopen V2.0 //------------------------------------------------------------------------- // Test On DAX 30 Cash 10 Minute Timeframe 200k bars or from 1/1/2015 // Common Rules Defparam Cumulateorders = False Defparam Preloadbars = 1000 // On/off Extratradecriteria = 1 // I.e. Long; Only Enters When The Current Bar High Is Lower Then The Lowest Daily High From Today, Yesterday And Day Before. Usepercentage = 0 // The Minimum Difference In Percentage [[1] From Dayopen Or In Points [0] From Dayopen Mfetrailing = 1 // Mfe Trailing Stop Wtrailing = 1 // Williams 3 Bar Trailing Stop Breakevenstop = 1 // Breakevenstop, Move Stoploss When Position Is In Profit. Excludefirsttwoweeks = 1 // Exclude The First 2 Weeks Of Every Year (Weeknumber 1 And 2) // Settings Positionsize = 1 SL = 1.00 // % Stoploss PT = 1.50 // % Profit Target MFETS = 0.35 // % Mfe Trailing Stop BES = 0.35 // % Break Even Stop BESMP = 0.05 // % Break Even Stop Minimum Profit WTSMP = 0.50 // % Williams Trailing Stop Minimum Profit If Mfe Trailing Stop Is Not Used ETD = 0 // Exclude a Trade Day; Sunday = 0 If Usepercentage Then Nopl=((Dayopen*0.15)/100)/pointsize Nops=((Dayopen*0.15)/100)/pointsize Else Nopl=2 //number of points long Nops=2 //number of points short Endif // Day & Time Once Entertime = 090000 Once Lasttime = 100000 Once Closetime = 240000 // Greater Then 23.59 Means It Continues Position Overnight Once Closetimefr=173000 If Excludefirsttwoweeks=1 Then If Year=2015 And Month=1 And (Day>=1 And Day<=18) Then Notrading = 1 Elsif Year=2016 And Month=1 And (Day>=1 And Day<=24) Then Notrading = 1 Elsif Year=2017 And Month=1 And (Day>=1 And Day<=22) Then Notrading = 1 Elsif Year=2018 And Month=1 And (Day>=1 And Day<=21) Then Notrading = 1 Elsif Year=2019 And Month=1 And (Day>=1 And Day<=20) Then Notrading = 1 Else Notrading = 0 Endif Endif Tt1 = Time >= Entertime Tt2 = Time <= Lasttime Tradetime = Tt1 And Tt2 and Notrading = 0 And Dayofweek <> ETD // Reset At Start If Intradaybarindex = 0 Then Longtradecounter = 0 Shorttradecounter = 0 Tradecounter = 0 Mclong = 0 Mcshort = 0 Endif // [pc] Position Criteria Pclong = Countoflongshares < 1 And Longtradecounter < 1 And Tradecounter < 1 Pcshort = Countofshortshares < 1 And Shorttradecounter < 1 And Tradecounter < 1 // [mc] Main Criteria If Time = Entertime Then Dayopen=open Endif If High > Dayopen+nopl Then Mclong=1 Else Mclong=0 Endif If Low < Dayopen-nops Then Mcshort=1 Else Mcshort=0 Endif // [ec] Extra Criteria If Extratradecriteria Then Min1 = Min(Dhigh(0),dhigh(1)) Min2 = Min(Dhigh(1),dhigh(2)) Max1 = Max(Dlow(0),dlow(1)) Max2 = Max(Dlow(1),dlow(2)) Eclong = High < Min(Min1,min2) Ecshort = Low > Max(Max1,max2) else Eclong=1 Ecshort=1 Endif // Long & Short Entry If Tradetime Then If Pclong and Mclong And Eclong Then Buy Positionsize Contract At Market Longtradecounter=longtradecounter + 1 Tradecounter=tradecounter+1 Endif If Pcshort and Mcshort And Ecshort Then Sellshort Positionsize Contract At Market Shorttradecounter=shorttradecounter + 1 Tradecounter=tradecounter+1 Endif Endif // Break Even Stop If Breakevenstop Then If Not Onmarket Then Newsl=0 Endif If Longonmarket And close-tradeprice(1)>=((Tradeprice/100)*BES)*pipsize Then Newsl = Tradeprice(1)+((Tradeprice/100)*BESMP)*pipsize Endif If Shortonmarket And Tradeprice(1)-close>=((Tradeprice/100)*BES)*pipsize Then Newsl = Tradeprice(1)-((Tradeprice/100)*BESMP)*pipsize Endif If Newsl>0 Then Sell At Newsl Stop Exitshort At Newsl Stop Endif Endif // Exit Mfe Trailing Stop If Mfetrailing Then Trailingstop = (Tradeprice/100)*MFETS If Not Onmarket Then Maxprice = 0 Minprice = Close Priceexit = 0 Endif If Longonmarket Then Maxprice = Max(Maxprice,close) If Maxprice-tradeprice(1)>=trailingstop*pipsize Then Priceexit = Maxprice-trailingstop*pipsize Endif Endif If Shortonmarket Then Minprice = Min(Minprice,close) If Tradeprice(1)-minprice>=trailingstop*pipsize Then Priceexit = Minprice+trailingstop*pipsize Endif Endif If Onmarket And Wtrailing=0 And Priceexit>0 Then Sell At Market Exitshort At Market Endif Endif // Exit Williams Trailing Stop If Wtrailing Then Count=1 I=0 J=i+1 Tot=0 While Count<4 Do Tot=tot+1 If (Low[j]>=low[i]) And (High[j]<=high[i]) Then J=j+1 Else Count=count+1 I=i+1 J=i+1 Endif Wend Basso=lowest[tot](Low) Alto=highest[tot](High) If Close>alto[1] Then Ref=basso Endif If Close<basso[1] Then Ref=alto Endif If Onmarket And Mfetrailing=0 And Positionperf>WTSMP Then If Low[1]>ref And High<ref Then Sell At Market Endif If High[1]<ref And Low>ref Then Exitshort At Market Endif Endif If Onmarket And Mfetrailing=1 And Priceexit>0 Then If High<ref Then Sell At Market Endif If Low>ref Then Exitshort At Market Endif Endif Endif // Exit At Closetime If Onmarket Then If Time >= Closetime Then Sell At Market Exitshort At Market Endif Endif // Exit At Closetime Friday If Onmarket Then If (Currentdayofweek=5 And Time>=closetimefr) Then Sell At Market Exitshort At Market Endif Endif // Build-in Exit Set Stop %loss SL Set Target %profit PT //graph 0 Coloured(300,0,0) As "Zeroline" //graph (Positionperf*100)coloured(0,0,0,255) As "Positionperformance" |
BUT when i backtest it today, it enters long, but on automatic it took a short?! why?