Forums › ProRealTime English forum › ProOrder support › strategy BarHunter DAX v1p › Reply To: strategy BarHunter DAX v1p
02/03/2020 at 4:36 PM
#118587
Could someone help in pointing out where I can adjust this?
Change mindist in the code to 15.
But you may still get Rejected as IG ‘Flash widen’ (for several seconds) the spread often.
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 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
//------------------------------------------------------------------------- // Hoofd code : BarHunter v3p //------------------------------------------------------------------------- //Germany //24 uur //01.15-08.00 = 4 //08.00-09.00 = 2 //09.00-17.30 = 1 //17.30-22.00 = 2 //22.00-01.15 = 5 //South Africa 40 //24 uur ZAR50 ZAR10 //07.30-16.30 8 //Alle andere tijden 30 //Wall Street 24 uur $10 / $2 //09.00-15.30 2,4 //15.30-22.00 1,6 //22.15-22.30 9,8 //23.00-00.00 9,8 //Alle andere tijden 3,8 defparam cumulateorders = FALSE defparam preloadbars = 1000 once enablets = 1 // trailing stop once enabletsvir = 1 // trailing stop virtual once displayts = 0 // trailing stop once holiday = 1 once closebeforeweekend = 0 once closebeforeweekendinloss =0 once securebeforeweekendprofit=0 once entrytype= 1 //entrytype=1 first version with error minimum distance stop //entrytype=2 entry modified with stop //entrytype=3 entry modified with market //entrytype=4 stop distance defnined first entry as entrytype 1 tds= 4// trend detection system off when optimising barnumbers // separate long/short or go both once longtrading =1 once shorttrading=1 // select which intradaybar should be analysed (depends on timeframe settings) once barnumberlong = 3 //long (timezone dependent) once barnumbershort= 3 //short (timezone dependent) // select the number of points above/below the breakvaluelong/short breakpoint=5 //========= once limitSLbroker=0 if time >210000 and time<070000 and CurrentDayOfWeek>=0 then limitSLbroker=12 elsif time>070000 and time<210000 and CurrentDayOfWeek>=0 then limitSLbroker =10 elsif time>210000 and CurrentDayOfWeek>5 then limitSLbroker=271 endif //fixed value 10 for dax (the minimum distance the stop can be place to the current close) if breakpoint <= limitSLbroker then if (15-breakpoint)>=0 and (15-breakpoint)<=15 then once minstopdistance=(15-breakpoint) else once minstopdistance = 15 endif else once minstopdistance = 0 endif // main criteria if intradaybarindex=0 then tradecounter=0 breakvaluelong=99999 breakvalueshort=0 tradeday=1 endif // holiday if holiday then if (Month = 5 AND Day = 1) OR (Month = 12 AND Day >=15) then tradeday=0 else tradeday=1 endif endif tradecount = tradecounter < 1 //perhaps 2 if using seperate bars for long & short // if entrytype>=1 and entrytype<4 then if longtrading or (longtrading and shorttrading) then if intradaybarindex=barnumberlong then breakvaluelong=high endif endif if shorttrading or (longtrading and shorttrading) then if intradaybarindex=barnumbershort then breakvalueshort=low endif endif elsif entrytype=4 then if longtrading or (longtrading and shorttrading) then if intradaybarindex=barnumberlong then breakvaluelong=high if high-close<minstopdistance then breakvaluelong=close+minstopdistance else breakvaluelong=breakvaluelong endif endif endif if shorttrading or (longtrading and shorttrading) then if intradaybarindex=barnumbershort then breakvalueshort=low if close-low<minstopdistance then breakvalueshort=close-minstopdistance else breakvalueshort=breakvalueshort endif endif endif endif // trend detection if tds=0 then trendup=1 trenddown=1 else if tds=1 then trendup=(Average[10](close)>Average[10](close)[1]) trenddown=(Average[10](close)<Average[10](close)[1]) else if tds=2 then bbup=BollingerUp[20](close) bbdn=BollingerDown[20](close) bbav=(bbup+bbdn)/2 trendup=bbav>bbav[1] trenddown=bbav<bbav[1] else if tds=3 then Period= 3 inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice) HULL = weightedaverage[round(sqrt(Period))](inner) trendup = HULL > HULL[1] trenddown = HULL < HULL[1] else if tds=4 then Period= 2 inner = 2*weightedaverage[round( Period/2)](totalprice)-weightedaverage[Period](totalprice) HULL = weightedaverage[round(sqrt(Period))](inner) trendup = HULL > HULL[1] trenddown = HULL < HULL[1] endif endif endif endif endif // POINT PIVOT HEBDOMADAIRE IF dayofweek < dayofweek[1] THEN weeklyhigh = prevweekhigh weeklylow = prevweeklow weeklyclose = prevweekclose prevweekhigh = high prevweeklow = low weeklyPivot = (weeklyHigh + weeklyLow + weeklyclose) / 3 ENDIF prevweekhigh = max(prevweekhigh, high) prevweeklow = min(prevweeklow, low) prevweekclose = close // POINT PIVOT JOURNALIER IF dayofweek = 1 THEN dayhigh = DHigh(2) daylow = DLow(2) dayclose = DClose(2) ENDIF IF dayofweek >=2 and dayofweek < 6 THEN dayhigh = DHigh(1) daylow = DLow(1) dayclose = DClose(1) ENDIF Pivot = (dayhigh + daylow + dayclose) / 3 S3 = daylow - 2 * (dayhigh- Pivot) R3 = dayhigh + 2* (Pivot - daylow) ecart=4 ecartWP=5 EC= HIGH-low/pointsize //SP=call"filtre_barhunter" // entry criteria if entrytype=1 and tradeday=1 then // entry criteria if hour<=21 then if longtrading then if intradaybarindex >= barnumberlong then if trendup and tradecount and (close>pivot or (close <pivot and (pivot-close)/pointsize >ecart)) and (close>weeklypivot or (close <weeklypivot and (weeklypivot-close)/pointsize >ecartWP))and ec>3.9 then buy 1 contract at breakvaluelong+breakpoint stop ppf=0 tradecounter=tradecounter+1 endif endif endif if shorttrading then if intradaybarindex >= barnumbershort then if trenddown and tradecount and (close<pivot or (close>pivot and (close-pivot)/pointsize >ecart))and (close<weeklypivot or (close>weeklypivot and (close-weeklypivot)/pointsize >ecartWP)) and ec>3.1 then sellshort 1 contract at breakvalueshort-breakpoint stop ppf=0 tradecounter=tradecounter+1 endif endif endif endif elsif entrytype=2 then if hour<=23 then if longtrading then if intradaybarindex >= barnumberlong then if trendup and tradecount then if ((breakvaluelong+breakpoint)-close)>=minstopdistance then buy 1 contract at breakvaluelong+breakpoint stop tradecounter=tradecounter+1 else buy 1 contract at close+(minstopdistance+breakpoint) stop tradecounter=tradecounter+1 endif endif endif endif if shorttrading then if intradaybarindex >= barnumbershort then if trenddown and tradecount then if (close-(breakvalueshort-breakpoint))>=minstopdistance then sellshort 1 contract at breakvalueshort-breakpoint stop tradecounter=tradecounter+1 else sellshort 1 contract at close-(minstopdistance-breakpoint) stop tradecounter=tradecounter+1 endif endif endif endif endif elsif entrytype=3 then if hour<=23 then if longtrading then if intradaybarindex >= barnumberlong then if trendup and tradecount then if high crosses over (breakvaluelong+breakpoint) then buy 1 contract at market endif endif endif endif if shorttrading then if intradaybarindex >= barnumbershort then if trenddown and tradecount then if low crosses under (breakvalueshort-breakpoint) then sellshort 1 contract at market tradecounter=tradecounter+1 endif endif endif endif endif elsif entrytype=4 then if hour<=23 then if longtrading then if intradaybarindex >= barnumberlong then if trendup and tradecount then buy 1 contract at breakvaluelong+breakpoint stop tradecounter=tradecounter+1 endif endif endif if shorttrading then if intradaybarindex >= barnumbershort then if trenddown and tradecount then sellshort 1 contract at breakvalueshort-breakpoint stop tradecounter=tradecounter+1 endif endif endif endif endif // trailing atr stop if enablets then // once steps=0.05 once minatrdist=3 once atrtrailingperiod = 14 // atr parameter once minstop = 15 // minimum distance if barindex=tradeindex then trailingstoplong = 5 // trailing stop atr distance trailingstopshort = 5 // trailing stop atr distance else if longonmarket then if newsl>0 then if trailingstoplong>minatrdist then if newsl>newsl[1] then trailingstoplong=trailingstoplong else trailingstoplong=trailingstoplong-steps endif else trailingstoplong=minatrdist endif endif endif if shortonmarket then if newsl>0 then if trailingstopshort>minatrdist then if newsl<newsl[1] then trailingstopshort=trailingstopshort else trailingstopshort=trailingstopshort-steps endif else trailingstopshort=minatrdist endif endif endif endif // atrtrail=averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000 trailingstartl=round(atrtrail*trailingstoplong) trailingstarts=round(atrtrail*trailingstopshort) tgl=trailingstartl tgs=trailingstarts // if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then maxprice=0 minprice=close newsl=0 endif // if longonmarket then maxprice=max(maxprice,close) if maxprice-tradeprice(1)>=tgl*pointsize then if maxprice-tradeprice(1)>=minstop then newsl=maxprice-tgl*pointsize else newsl=maxprice-minstop*pointsize endif endif endif // if shortonmarket then minprice=min(minprice,close) if tradeprice(1)-minprice>=tgs*pointsize then if tradeprice(1)-minprice>=minstop then newsl=minprice+tgs*pointsize else newsl=minprice+minstop*pointsize endif endif endif // if longonmarket then if newsl>0 then sell at newsl stop endif endif if shortonmarket then if newsl>0 then exitshort at newsl stop endif endif if displayts then //graphonprice newsl coloured(0,0,255,255) as "trailingstop atr" endif endif // ================trailing atr stop VIRTUAL================== if enabletsvir then // once stepsvir=0 once minatrdistvir=0 once atrtrailingperiodvir = 2 // atr parameter once minstopvir = 10 // minimum distance if barindex=tradeindex then trailingstoplongvir = 5 // trailing stop atr distance trailingstopshortvir = 5 // trailing stop atr distance else if longonmarket then if newslvir>0 then if trailingstoplongvir>minatrdistvir then if newslvir>newslvir[1] then trailingstoplongvir=trailingstoplongvir else trailingstoplongvir=trailingstoplongvir-stepsvir endif else trailingstoplongvir=minatrdistvir endif endif endif if shortonmarket then if newslvir>0 then if trailingstopshortvir>minatrdistvir then if newslvir<newslvir[1] then trailingstopshortvir=trailingstopshortvir else trailingstopshortvir=trailingstopshortvir-stepsvir endif else trailingstopshortvir=minatrdistvir endif endif endif endif // atrtrailvir=averagetruerange[atrtrailingperiodvir]((close/10)*pipsize)/1000 trailingstartlvir=round(atrtrailvir*trailingstoplongvir) trailingstartsvir=round(atrtrailvir*trailingstopshortvir) tglvir=trailingstartlvir tgsvir=trailingstartsvir // if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then maxpricevir=0 minpricevir=close newslvir=0 endif // if longonmarket then maxpricevir=max(maxpricevir,close) if maxpricevir-tradeprice(1)>=tglvir*pointsize then if maxpricevir-tradeprice(1)>=minstopvir then newslvir=maxpricevir-tglvir*pointsize else newslvir=maxpricevir-minstopvir*pointsize endif endif endif // if shortonmarket then minpricevir=min(minpricevir,close) if tradeprice(1)-minpricevir>=tgsvir*pointsize then if tradeprice(1)-minpricevir>=minstopvir then newslvir=minpricevir+tgsvir*pointsize else newslvir=minpricevir+minstopvir*pointsize endif endif endif // if longonmarket and close <newslvir and newslvir>0 then sell at market endif if shortonmarket and close>newslvir and newslvir>0 then exitshort at market endif if displayts then //graphonprice newsl coloured(0,0,255,255) as "trailingstop atr" endif endif //======================AJOUTER PAR FIFI PP=positionperf(0)*100 if pp>ppf then ppf=pp endif filtre=call"Forme_bougie" spread=abs(OPEN-CLOSE) coeff=spread/highest[200](spread)*100 //================= // coefficient de la bougie if longonmarket and barindex-tradeindex>1 AND ppf>0.5 and pp<ppF and coeff<4 and close<positionprice then sell at market endif if longonmarket AND coeff[1]<3 and coeff>80 and close>positionprice then sell at market endif //===============SHORT if shortonmarket and barindex-tradeindex<3 and pp<ppF and coeff>55 and close>positionprice then exitshort at market endif if shortonmarket and barindex-tradeindex>6 AND ppf>0.1 and pp<ppF and coeff<3 and close>positionprice then exitshort at market endif if shortonmarket AND coeff[1]<6 and coeff>70 and close<positionprice then exitshort at market endif //===================FORME DE BOUGIE if filtre[1]=-1 and barindex-tradeindex<4 and pp<ppF and longonmarket and close>positionprice then sell at market endif if filtre[1]=-1 and pp>0.7 and pp<ppF and longonmarket and close>positionprice then sell at market endif if filtre=1 and pp>2.5 and pp<PPF and shortonmarket and close<positionprice then exitshort at market endif if filtre[1]=1 and barindex-tradeindex<7 and pp<PPF and shortonmarket and close<positionprice then exitshort at market endif //=====================CROSS POINT DE PIVOT If longonmarket and close[1] < R3 and high[1]>R3 and open>close and pp>ppF-pp and close>positionprice then sell at market endif if shortonmarket and close[1]>S3 and low[1]<S3 and open<close and pp>ppF-pp and close<positionprice then exitshort at market endif //======================================= if longonmarket and pp>ppF-pp and close>positionprice and open>close and( (high-open>18)or(open=high and open-close>9)or(open[1]<close[1] and close[1]=high[1] and open[1]>close)) then sell at market endif if shortonmarket and pp>ppF-pp and close<positionprice and open<close and open[1]>close[1] and close[1]=LOW[1] and open[1]<close then exitshort at market endif // test de nombre de bar negative ajouter fifi743 if longonmarket and barindex-tradeindex>138 and close<positionprice then sell at market endif if shortonmarket and barindex-tradeindex>11 and close>positionprice then exitshort at market endif //===============AJOUTER FERMETURE DES POSITIONS RSI ET barindex-tradeindex ===== Myrsi=RSI[15](close) //34 if Myrsi<47 and barindex-tradeindex>3 and longonmarket and close>positionprice then sell at market endif if Myrsi>69 and barindex-tradeindex>1 and shortonmarket and close<positionprice then exitshort at market endif //=========================NB bar for i=0 to 3 if longonmarket and barindex-tradeindex<4 AND COEFF[i]>60 AND COEFF<10 and coeff[i]>coeff and ppf=0 then sell at market break endif if shortonmarket and barindex-tradeindex<5 AND COEFF[i]>60 AND COEFF<10 and coeff[i]>coeff and ppf=0 then exitshort at market endif next // =================== FORME DE BOUGIE DOJI ==================== if longonmarket and abs(open-close)<1 and high-close>18 and high[1]<high and close>positionprice then sell at market endif if shortonmarket and abs(open-close)<1 and low[1]<low and close<positionprice then exitshort at market endif //====================PAUL if closebeforeweekend then if onmarket then if (dayofweek=5 and hour>=22) then sell at market exitshort at market endif endif endif if securebeforeweekendprofit then if (dayofweek=5 and hour>=18) then if longonmarket then if close>positionprice+15 then sell at tradeprice(1)+10 stop //else //if hour>=22 then //sell at market //endif endif endif if shortonmarket then if close<positionprice-15 then exitshort at tradeprice(1)-10 stop else if hour>=22 then exitshort at market endif endif endif endif endif if closebeforeweekendinloss then if (dayofweek=5 and hour>=22) then if longonmarket then if close<positionprice then sell at market endif endif if shortonmarket then if close>positionprice then exitshort at market endif endif endif endif //============================== if CurrentDayOfWeek=1 and time>060000 and time<180000 then SL=160 elsif CurrentDayOfWeek=2 and time>060000 and time<180000 then SL=160 elsif CurrentDayOfWeek=3 and time>060000 and time<180000 then SL=170 elsif CurrentDayOfWeek=4 and time>060000 and time<180000 then SL=130 elsif CurrentDayOfWeek=5 and time>060000 and time<180000 then SL=150 elsif time>180000 and time<060000 then sl=270 endif SET STOP PLOSS sl //set stop %loss 2 //set target %profit 3 |