strategy BarHunter DAX v1p
Forums › ProRealTime English forum › ProOrder support › strategy BarHunter DAX v1p
- This topic has 255 replies, 11 voices, and was last updated 1 year ago by sfl.
-
-
02/03/2020 at 11:31 AM #118539
TimeHunter v1p MOD FIFI
Hey interesting … with no optimisation or even adjustment of Time (yet) for UK Timezone see attached on DJI @ H2 TF.
Well done Paul and Fifi!
02/03/2020 at 12:10 PM #11854902/03/2020 at 12:32 PM #118552wants me to edit the variables.
Change the 7 to 5 at the red arrowhead
1 user thanked author for this post.
02/03/2020 at 12:34 PM #11855402/03/2020 at 1:44 PM #11856302/03/2020 at 1:44 PM #118566see attached on DJI @ H2 TF.
Even better on DJI H1 with EntryHour = 15 at Line 42.
Hour 15 being 15:00 to 16:00 UK time is logical as the DJI opens at 14:30 so after half an hour to settle down?
02/03/2020 at 1:51 PM #1185690.2 size
You are showing Size = 1 on your results?
I haven’t yet got decent results on DAX 1 Hour … have you Francesco?
Maybe they were okay. but I was so impressed with the DJI results!? I’ll go back and have a look now I have got the DJI running in Forward Test on Demo.
All hail Paul and Fifi ! 🙂
02/03/2020 at 1:52 PM #11857002/03/2020 at 1:57 PM #118571that’s why I also edited the post
We are too quick for each other! 🙂
I have added to my previous with a question for you anyway.
02/03/2020 at 2:03 PM #11857202/03/2020 at 4:36 PM #118587Could 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.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624//-------------------------------------------------------------------------// 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,8defparam cumulateorders = FALSEdefparam preloadbars = 1000once enablets = 1 // trailing stoponce enabletsvir = 1 // trailing stop virtualonce displayts = 0 // trailing stoponce holiday = 1once closebeforeweekend = 0once closebeforeweekendinloss =0once securebeforeweekendprofit=0once 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 1tds= 4// trend detection system off when optimising barnumbers// separate long/short or go bothonce longtrading =1once 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/shortbreakpoint=5//=========once limitSLbroker=0if time >210000 and time<070000 and CurrentDayOfWeek>=0 thenlimitSLbroker=12elsif time>070000 and time<210000 and CurrentDayOfWeek>=0 thenlimitSLbroker =10elsif time>210000 and CurrentDayOfWeek>5 thenlimitSLbroker=271endif//fixed value 10 for dax (the minimum distance the stop can be place to the current close)if breakpoint <= limitSLbroker thenif (15-breakpoint)>=0 and (15-breakpoint)<=15 thenonce minstopdistance=(15-breakpoint)elseonce minstopdistance = 15endifelseonce minstopdistance = 0endif// main criteriaif intradaybarindex=0 thentradecounter=0breakvaluelong=99999breakvalueshort=0tradeday=1endif// holidayif holiday thenif (Month = 5 AND Day = 1) OR (Month = 12 AND Day >=15) thentradeday=0elsetradeday=1endifendiftradecount = tradecounter < 1 //perhaps 2 if using seperate bars for long & short//if entrytype>=1 and entrytype<4 thenif longtrading or (longtrading and shorttrading) thenif intradaybarindex=barnumberlong thenbreakvaluelong=highendifendifif shorttrading or (longtrading and shorttrading) thenif intradaybarindex=barnumbershort thenbreakvalueshort=lowendifendifelsif entrytype=4 thenif longtrading or (longtrading and shorttrading) thenif intradaybarindex=barnumberlong thenbreakvaluelong=highif high-close<minstopdistance thenbreakvaluelong=close+minstopdistanceelsebreakvaluelong=breakvaluelongendifendifendifif shorttrading or (longtrading and shorttrading) thenif intradaybarindex=barnumbershort thenbreakvalueshort=lowif close-low<minstopdistance thenbreakvalueshort=close-minstopdistanceelsebreakvalueshort=breakvalueshortendifendifendifendif// trend detectionif tds=0 thentrendup=1trenddown=1elseif tds=1 thentrendup=(Average[10](close)>Average[10](close)[1])trenddown=(Average[10](close)<Average[10](close)[1])elseif tds=2 thenbbup=BollingerUp[20](close)bbdn=BollingerDown[20](close)bbav=(bbup+bbdn)/2trendup=bbav>bbav[1]trenddown=bbav<bbav[1]elseif tds=3 thenPeriod= 3inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)HULL = weightedaverage[round(sqrt(Period))](inner)trendup = HULL > HULL[1]trenddown = HULL < HULL[1]elseif tds=4 thenPeriod= 2inner = 2*weightedaverage[round( Period/2)](totalprice)-weightedaverage[Period](totalprice)HULL = weightedaverage[round(sqrt(Period))](inner)trendup = HULL > HULL[1]trenddown = HULL < HULL[1]endifendifendifendifendif// POINT PIVOT HEBDOMADAIREIF dayofweek < dayofweek[1] THENweeklyhigh = prevweekhighweeklylow = prevweeklowweeklyclose = prevweekcloseprevweekhigh = highprevweeklow = lowweeklyPivot = (weeklyHigh + weeklyLow + weeklyclose) / 3ENDIFprevweekhigh = max(prevweekhigh, high)prevweeklow = min(prevweeklow, low)prevweekclose = close// POINT PIVOT JOURNALIERIF dayofweek = 1 THENdayhigh = DHigh(2)daylow = DLow(2)dayclose = DClose(2)ENDIFIF dayofweek >=2 and dayofweek < 6 THENdayhigh = DHigh(1)daylow = DLow(1)dayclose = DClose(1)ENDIFPivot = (dayhigh + daylow + dayclose) / 3S3 = daylow - 2 * (dayhigh- Pivot)R3 = dayhigh + 2* (Pivot - daylow)ecart=4ecartWP=5EC= HIGH-low/pointsize//SP=call"filtre_barhunter"// entry criteriaif entrytype=1 and tradeday=1 then// entry criteriaif hour<=21 thenif longtrading thenif intradaybarindex >= barnumberlong thenif 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 thenbuy 1 contract at breakvaluelong+breakpoint stopppf=0tradecounter=tradecounter+1endifendifendifif shorttrading thenif intradaybarindex >= barnumbershort thenif 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 thensellshort 1 contract at breakvalueshort-breakpoint stopppf=0tradecounter=tradecounter+1endifendifendifendifelsif entrytype=2 thenif hour<=23 thenif longtrading thenif intradaybarindex >= barnumberlong thenif trendup and tradecount thenif ((breakvaluelong+breakpoint)-close)>=minstopdistance thenbuy 1 contract at breakvaluelong+breakpoint stoptradecounter=tradecounter+1elsebuy 1 contract at close+(minstopdistance+breakpoint) stoptradecounter=tradecounter+1endifendifendifendifif shorttrading thenif intradaybarindex >= barnumbershort thenif trenddown and tradecount thenif (close-(breakvalueshort-breakpoint))>=minstopdistance thensellshort 1 contract at breakvalueshort-breakpoint stoptradecounter=tradecounter+1elsesellshort 1 contract at close-(minstopdistance-breakpoint) stoptradecounter=tradecounter+1endifendifendifendifendifelsif entrytype=3 thenif hour<=23 thenif longtrading thenif intradaybarindex >= barnumberlong thenif trendup and tradecount thenif high crosses over (breakvaluelong+breakpoint) thenbuy 1 contract at marketendifendifendifendifif shorttrading thenif intradaybarindex >= barnumbershort thenif trenddown and tradecount thenif low crosses under (breakvalueshort-breakpoint) thensellshort 1 contract at markettradecounter=tradecounter+1endifendifendifendifendifelsif entrytype=4 thenif hour<=23 thenif longtrading thenif intradaybarindex >= barnumberlong thenif trendup and tradecount thenbuy 1 contract at breakvaluelong+breakpoint stoptradecounter=tradecounter+1endifendifendifif shorttrading thenif intradaybarindex >= barnumbershort thenif trenddown and tradecount thensellshort 1 contract at breakvalueshort-breakpoint stoptradecounter=tradecounter+1endifendifendifendifendif// trailing atr stopif enablets then//once steps=0.05once minatrdist=3once atrtrailingperiod = 14 // atr parameteronce minstop = 15 // minimum distanceif barindex=tradeindex thentrailingstoplong = 5 // trailing stop atr distancetrailingstopshort = 5 // trailing stop atr distanceelseif longonmarket thenif newsl>0 thenif trailingstoplong>minatrdist thenif newsl>newsl[1] thentrailingstoplong=trailingstoplongelsetrailingstoplong=trailingstoplong-stepsendifelsetrailingstoplong=minatrdistendifendifendifif shortonmarket thenif newsl>0 thenif trailingstopshort>minatrdist thenif newsl<newsl[1] thentrailingstopshort=trailingstopshortelsetrailingstopshort=trailingstopshort-stepsendifelsetrailingstopshort=minatrdistendifendifendifendif//atrtrail=averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl=round(atrtrail*trailingstoplong)trailingstarts=round(atrtrail*trailingstopshort)tgl=trailingstartltgs=trailingstarts//if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenmaxprice=0minprice=closenewsl=0endif//if longonmarket thenmaxprice=max(maxprice,close)if maxprice-tradeprice(1)>=tgl*pointsize thenif maxprice-tradeprice(1)>=minstop thennewsl=maxprice-tgl*pointsizeelsenewsl=maxprice-minstop*pointsizeendifendifendif//if shortonmarket thenminprice=min(minprice,close)if tradeprice(1)-minprice>=tgs*pointsize thenif tradeprice(1)-minprice>=minstop thennewsl=minprice+tgs*pointsizeelsenewsl=minprice+minstop*pointsizeendifendifendif//if longonmarket thenif newsl>0 thensell at newsl stopendifendifif shortonmarket thenif newsl>0 thenexitshort at newsl stopendifendifif displayts then//graphonprice newsl coloured(0,0,255,255) as "trailingstop atr"endifendif// ================trailing atr stop VIRTUAL==================if enabletsvir then//once stepsvir=0once minatrdistvir=0once atrtrailingperiodvir = 2 // atr parameteronce minstopvir = 10 // minimum distanceif barindex=tradeindex thentrailingstoplongvir = 5 // trailing stop atr distancetrailingstopshortvir = 5 // trailing stop atr distanceelseif longonmarket thenif newslvir>0 thenif trailingstoplongvir>minatrdistvir thenif newslvir>newslvir[1] thentrailingstoplongvir=trailingstoplongvirelsetrailingstoplongvir=trailingstoplongvir-stepsvirendifelsetrailingstoplongvir=minatrdistvirendifendifendifif shortonmarket thenif newslvir>0 thenif trailingstopshortvir>minatrdistvir thenif newslvir<newslvir[1] thentrailingstopshortvir=trailingstopshortvirelsetrailingstopshortvir=trailingstopshortvir-stepsvirendifelsetrailingstopshortvir=minatrdistvirendifendifendifendif//atrtrailvir=averagetruerange[atrtrailingperiodvir]((close/10)*pipsize)/1000trailingstartlvir=round(atrtrailvir*trailingstoplongvir)trailingstartsvir=round(atrtrailvir*trailingstopshortvir)tglvir=trailingstartlvirtgsvir=trailingstartsvir//if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenmaxpricevir=0minpricevir=closenewslvir=0endif//if longonmarket thenmaxpricevir=max(maxpricevir,close)if maxpricevir-tradeprice(1)>=tglvir*pointsize thenif maxpricevir-tradeprice(1)>=minstopvir thennewslvir=maxpricevir-tglvir*pointsizeelsenewslvir=maxpricevir-minstopvir*pointsizeendifendifendif//if shortonmarket thenminpricevir=min(minpricevir,close)if tradeprice(1)-minpricevir>=tgsvir*pointsize thenif tradeprice(1)-minpricevir>=minstopvir thennewslvir=minpricevir+tgsvir*pointsizeelsenewslvir=minpricevir+minstopvir*pointsizeendifendifendif//if longonmarket and close <newslvir and newslvir>0 thensell at marketendifif shortonmarket and close>newslvir and newslvir>0 thenexitshort at marketendifif displayts then//graphonprice newsl coloured(0,0,255,255) as "trailingstop atr"endifendif//======================AJOUTER PAR FIFIPP=positionperf(0)*100if pp>ppf thenppf=ppendiffiltre=call"Forme_bougie"spread=abs(OPEN-CLOSE)coeff=spread/highest[200](spread)*100//=================// coefficient de la bougieif longonmarket and barindex-tradeindex>1 AND ppf>0.5 and pp<ppF and coeff<4 and close<positionprice thensell at marketendifif longonmarket AND coeff[1]<3 and coeff>80 and close>positionprice thensell at marketendif//===============SHORTif shortonmarket and barindex-tradeindex<3 and pp<ppF and coeff>55 and close>positionprice thenexitshort at marketendifif shortonmarket and barindex-tradeindex>6 AND ppf>0.1 and pp<ppF and coeff<3 and close>positionprice thenexitshort at marketendifif shortonmarket AND coeff[1]<6 and coeff>70 and close<positionprice thenexitshort at marketendif//===================FORME DE BOUGIEif filtre[1]=-1 and barindex-tradeindex<4 and pp<ppF and longonmarket and close>positionprice thensell at marketendifif filtre[1]=-1 and pp>0.7 and pp<ppF and longonmarket and close>positionprice thensell at marketendifif filtre=1 and pp>2.5 and pp<PPF and shortonmarket and close<positionprice thenexitshort at marketendifif filtre[1]=1 and barindex-tradeindex<7 and pp<PPF and shortonmarket and close<positionprice thenexitshort at marketendif//=====================CROSS POINT DE PIVOTIf longonmarket and close[1] < R3 and high[1]>R3 and open>close and pp>ppF-pp and close>positionprice thensell at marketendifif shortonmarket and close[1]>S3 and low[1]<S3 and open<close and pp>ppF-pp and close<positionprice thenexitshort at marketendif//=======================================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)) thensell at marketendifif 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 thenexitshort at marketendif// test de nombre de bar negative ajouter fifi743if longonmarket and barindex-tradeindex>138 and close<positionprice thensell at marketendifif shortonmarket and barindex-tradeindex>11 and close>positionprice thenexitshort at marketendif//===============AJOUTER FERMETURE DES POSITIONS RSI ET barindex-tradeindex =====Myrsi=RSI[15](close)//34if Myrsi<47 and barindex-tradeindex>3 and longonmarket and close>positionprice thensell at marketendifif Myrsi>69 and barindex-tradeindex>1 and shortonmarket and close<positionprice thenexitshort at marketendif//=========================NB barfor i=0 to 3if longonmarket and barindex-tradeindex<4 AND COEFF[i]>60 AND COEFF<10 and coeff[i]>coeff and ppf=0 thensell at marketbreakendifif shortonmarket and barindex-tradeindex<5 AND COEFF[i]>60 AND COEFF<10 and coeff[i]>coeff and ppf=0 thenexitshort at marketendifnext// =================== FORME DE BOUGIE DOJI ====================if longonmarket and abs(open-close)<1 and high-close>18 and high[1]<high and close>positionprice thensell at marketendifif shortonmarket and abs(open-close)<1 and low[1]<low and close<positionprice thenexitshort at marketendif//====================PAULif closebeforeweekend thenif onmarket thenif (dayofweek=5 and hour>=22) thensell at marketexitshort at marketendifendifendifif securebeforeweekendprofit thenif (dayofweek=5 and hour>=18) thenif longonmarket thenif close>positionprice+15 thensell at tradeprice(1)+10 stop//else//if hour>=22 then//sell at market//endifendifendifif shortonmarket thenif close<positionprice-15 thenexitshort at tradeprice(1)-10 stopelseif hour>=22 thenexitshort at marketendifendifendifendifendifif closebeforeweekendinloss thenif (dayofweek=5 and hour>=22) thenif longonmarket thenif close<positionprice thensell at marketendifendifif shortonmarket thenif close>positionprice thenexitshort at marketendifendifendifendif//==============================if CurrentDayOfWeek=1 and time>060000 and time<180000 thenSL=160elsif CurrentDayOfWeek=2 and time>060000 and time<180000 thenSL=160elsif CurrentDayOfWeek=3 and time>060000 and time<180000 thenSL=170elsif CurrentDayOfWeek=4 and time>060000 and time<180000 thenSL=130elsif CurrentDayOfWeek=5 and time>060000 and time<180000 thenSL=150elsif time>180000 and time<060000 thensl=270endifSET STOP PLOSS sl//set stop %loss 2//set target %profit 302/03/2020 at 6:03 PM #118598Florian Legeard – I removed your ‘bad’ code and replaced it with the second code that you posted. I also removed the French part of your post.
1 user thanked author for this post.
02/04/2020 at 3:22 AM #11861102/04/2020 at 3:44 AM #118614and here’s TimeHunter v1.01p VS crude oil
take into account, when going back in time and a index is half the value, a stoploss using points or percentage matters.
Same goes using points for a break or percentage. Using percentage can lower the equity curve.
02/04/2020 at 9:50 AM #118622Change mindist in the code to 15. But you may still get Rejected as IG ‘Flash widen’ (for several seconds) the spread often.
Have you been rejected at mindist = 15 Florian?
Try below (for mindist = 30) just so you can understand what goes on and hopefully you may get a trade triggered.
Below relates to Lines 51 to 71 in the code you posted.
Only try on Demo (Not Real Live).
123456789101112131415161718192021breakpoint=5//=========once limitSLbroker=0if time >210000 and time<070000 and CurrentDayOfWeek>=0 thenlimitSLbroker=30elsif time>070000 and time<210000 and CurrentDayOfWeek>=0 thenlimitSLbroker =10elsif time>210000 and CurrentDayOfWeek>5 thenlimitSLbroker=271endif//fixed value 10 for dax (the minimum distance the stop can be place to the current close)if breakpoint <= limitSLbroker thenif (30-breakpoint)>=0 and (30-breakpoint)<=25 thenonce minstopdistance=(30-breakpoint)elseonce minstopdistance = 30endifelseonce minstopdistance = 0endif -
AuthorPosts
Find exclusive trading pro-tools on