Forums › ProRealTime English forum › ProOrder support › Help with a condition › Reply To: Help with a condition
08/26/2018 at 8:46 AM
#79076
Hi GraHal of course. Also I’ve been all night working on it and I changed a few things to enhance it.
Basically I change RSI by RSX and results are much better now. However code is a bit frankenstein…don’t laugh please 🙂
It’s for DAX M1 and my main question is how to avoid RSXBARS for no limiting trades at that certain vars number. I spent much hours testing with WHILE and ONCE but I can’t solve it.
Also, any other idea to enchance strategy is welcome 🙂
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 |
//------------------------------------------------------------------------- // Código principal : CH - 1M - TR - STO //------------------------------------------------------------------------- /// Definition of code parameters defparam preloadbars = 500 DEFPARAM FlatBefore = 101000 DEFPARAM FlatAfter = 172500 daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0 // INICIO RSX Len=RSXLEN if (f90 = 0.0) then f90 = 1.0 f0 = 0.0 if (Len-1 >= 5) then f88 = Len-1.0 else f88 = 5.0 endif f8 = 100.0*(Close) f18 = 3.0 / (Len + 2.0) f20 = 1.0 - f18 else if (f88 <= f90) then f90 = f88 + 1 else f90 = f90 + 1 endif f10 = f8 f8 = 100*Close v8 = f8 - f10 f28 = f20 * f28 + f18 * v8 f30 = f18 * f28 + f20 * f30 vC = f28 * 1.5 - f30 * 0.5 f38 = f20 * f38 + f18 * vC f40 = f18 * f38 + f20 * f40 v10 = f38 * 1.5 - f40 * 0.5 f48 = f20 * f48 + f18 * v10 f50 = f18 * f48 + f20 * f50 v14 = f48 * 1.5 - f50 * 0.5 f58 = f20 * f58 + f18 * Abs(v8) f60 = f18 * f58 + f20 * f60 v18 = f58 * 1.5 - f60 * 0.5 f68 = f20 * f68 + f18 * v18 f70 = f18 * f68 + f20 * f70 v1C = f68 * 1.5 - f70 * 0.5 f78 = f20 * f78 + f18 * v1C f80 = f18 * f78 + f20 * f80 v20 = f78 * 1.5 - f80 * 0.5 if ((f88 >= f90) and (f8 <> f10)) then f0 = 1.0 endif if ((f88 = f90) and (f0 = 0.0)) then f90 = 0.0 endif endif if ((f88 < f90) and (v20 > 0.0000000001)) then v4 = (v14 / v20 + 1.0) * 50.0 if (v4 > 100.0) then v4 = 100.0 endif if (v4 < 0.0) then v4 = 0.0 endif else v4 = 50.0 endif // FIN RSX // General conditions RSX=v4 RSXLEN = 14 // 34 //12 RSXVARMIN = 28 // 31 //26 RSXVARMAX = 64 //62 //66 RSXBARS = 24 //33 //24 // Conditions long STOL = Stochastic[204,4] STOOVERL = 25 STOUNDERL = 60 STOMANTAINL = 89 ATRPROFITL = AverageTrueRange[5] //50 //AverageTrueRange[5] ATRPROFITMULTL = 5 //1 //4.7 ATRRISKL = AverageTrueRange[10] ATRRISKMULTL = 3.8 //3.5 MAPROFITAVGL = 14 BBPROFITSTDAVGL = 15 //RSXL = RSX // Conditions short STOS = Stochastic[199,2] STOOVERS = 70 STOUNDERS = 83 STOMANTAINS = 6 ATRPROFITS = AverageTrueRange[10] ATRPROFITMULTS = 4.6 ATRRISKS = AverageTrueRange[4] ATRRISKMULTS = 4.4 MAPROFITAVGS = 15 BBPROFITSTDAVGS = 18 //RSXS = RSX once RRreached = 0 profitpipsl = ATRPROFITL*ATRPROFITMULTL // 0.1 * var:30-60 4.9 riskpipsl = ATRRISKL*ATRRISKMULTL //risk in pips amountl = 1 //lot amount to open each trade sdl = 0.17 //standard deviation of MA floating profit - orig: 0.25 profitpipss = ATRPROFITS*ATRPROFITMULTS // 0.1 * var:30-60 4.6 riskpipss = ATRRISKS*ATRRISKMULTS //whole account risk in percent% amounts = 1 //lot amount to open each trade sds = 0.17 //standard deviation of MA floating profit - orig: 0.25 // Conditions to enter long positions c3 = (STOL > STOOVERL) // 20 c4 = (STOL < STOUNDERL) // 40 c5 = (STOL > STOL[1]) // and (STOL[1] < STOL[2]) c6 = (RSX > RSX[1]) and (RSX > RSXVARMIN) c7 = ((lowest[RSXBARS](RSX)) < RSXVARMIN) and ((highest[RSXBARS](RSX)) < RSXVARMAX) // Conditions to enter short positions c13 = (STOS < STOUNDERS) // 80 c14 = (STOS > STOOVERS) // 60 c15 = (STOS < STOS[1]) c16 = (RSX < RSX[1]) and (RSX < RSXVARMAX) c17 = ((highest[RSXBARS](RSX)) > RSXVARMAX) and ((lowest[RSXBARS](RSX)) > RSXVARMIN) //first trade whatever condition if NOT ONMARKET AND c3 and c4 and c5 and c6 and c7 AND NOT daysForbiddenEntry then //close>close[1] BUY amountl LOT AT MARKET endif if NOT ONMARKET AND c13 and c14 and c15 and c16 and c17 AND NOT daysForbiddenEntry then //close<close[1] SELLSHORT amounts LOT AT MARKET endif //money management //liveaccountbalance = accountbalance+strategyprofit moneyriskl = riskpipsl if longonmarket then onepointvaluebasketl = pointvalue*countofposition mindistancetoclosel =(moneyriskl/onepointvaluebasketl)*pipsize endif moneyrisks = riskpipss if shortonmarket then onepointvaluebaskets = pointvalue*countofposition mindistancetocloses =(moneyrisks/onepointvaluebaskets)*pipsize endif //floating profit floatingprofitl = (((close-positionprice)*pointvalue)*countofposition)/pipsize floatingprofits = (((close-positionprice)*pointvalue)*countofposition)/pipsize //actual trade gains MAfloatingprofitl = average[MAPROFITAVGL](floatingprofitl) BBfloatingprofitl = MAfloatingprofitl - std[BBPROFITSTDAVGL](MAfloatingprofitl)*sdl MAfloatingprofits = average[MAPROFITAVGS](floatingprofits) BBfloatingprofits = MAfloatingprofits - std[BBPROFITSTDAVGS](MAfloatingprofits)*sds //floating profit risk reward check if profitpipsl>0 and floatingprofitl>profitpipsl then RRreached=1 endif if profitpipss>0 and floatingprofits>profitpipss then RRreached=1 endif //stoploss trigger when risk reward ratio is not met already //if onmarket and RRreached=0 then //SELL AT positionprice-mindistancetoclose STOP //EXITSHORT AT positionprice-mindistancetoclose STOP //endif if longonmarket and RRreached=0 then SELL AT positionprice-mindistancetoclosel STOP //EXITSHORT AT positionprice-mindistancetoclose STOP endif if shortonmarket and RRreached=0 then //SELL AT positionprice-mindistancetoclose STOP EXITSHORT AT positionprice-mindistancetocloses STOP endif //stoploss trigger when risk reward ratio has been reached //if onmarket and RRreached=1 then //if floatingprofit crosses under BBfloatingprofit then //SELL AT MARKET //EXITSHORT AT MARKET //endif //endif if longonmarket and RRreached=1 and (stol < STOMANTAINL) then if floatingprofitl crosses under BBfloatingprofitl then SELL AT MARKET endif endif if shortonmarket and RRreached=1 and (stos > STOMANTAINS) then if floatingprofits crosses under BBfloatingprofits then EXITSHORT AT MARKET endif endif //resetting the risk reward reached variable if not onmarket then RRreached = 0 endif |
Thanks a lot!