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/18/2021 at 5:59 PM #16194203/10/2021 at 8:01 PM #16374603/10/2021 at 8:57 PM #163750
here is a modified code & idea from Vonasi, instead of seasonal pattens it hunts for intraday patterns. Which in essence is a bit like barhunter, but now better written and changed to fit the purpose.
Timeframe 15m to 4 hours. There are maybe combinations possible. I post the code so it can be explored.
This code is setup for forex eurusd mini, 1hour tf and optimised on 30k bars without sl/pt/ts or spread.
note stepsize is depended on the market it is applied too.
1 user thanked author for this post.
03/10/2021 at 11:36 PM #163757here is a modified code & idea from Vonasi, instead of seasonal pattens it hunts for intraday patterns
The seasonality bit I’ll take credit for but the intraday patterns is all your own doing. Happy curve hunting!
03/11/2021 at 12:33 PM #163828Thank You Paul for yet another intriguing Strategy!
I’m putting attached on Demo Forward Test.
Spread = 5
2 users thanked author for this post.
07/05/2023 at 9:37 AM #217290@Paul @mods
Hi there,
I keep getting kicked out by IG in LIVE with this strategy without understanding why. Apparently many people have had the same experience;I tried to increase the SL and the Trailing vs the original figure but it doesn’t work;
Here under the code modified.
once minstop = 15 // minimum trailing stop distance
…
set stop %loss 3
Anybody has manage to launched it live ?
thanks for your help,
Chris
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298//-------------------------------------------------------------------------// Code principal : DAX H1 Timehunter v4.5p//-------------------------------------------------------------------------//-------------------------------------------------------------------------// hoofd code : Timehunter v4.5p 1h dax//-------------------------------------------------------------------------// dax 1 hour timeframe backtest / dax 1 minute live// spread 4// optimise entryhour 0 to 23// optimise entryminute 0 to 59 but set to 0 using 1 hour or higher timeframe// on timeframe 5 minutes with entryminute interval of 5// on timeframe 10 minutes with entryminute interval of 10// on timeframe 15 minutes with entryminute interval of 15// on timeframe 30 minutes with entryminute interval of 30defparam cumulateorders = falsedefparam preloadbars = 1000timeframe (default)once positionsize = 1once mode = 1 // use [1] for 1 hour timeframe, [0] for 1 minute timeframeonce tds = 3 // off when optimising [trend detection system]// separate long/short or go bothonce longtrading =1once shorttrading =1once holiday =1once closefriday =1once displaydim =1 // displays the number of days in market (activated graph)once maxdim =5 // maximum days in market (first day = 0)// select the number of points above/below the breakvaluelong/shortonce entryhour =4once entryminute=0// select the number of points above/below the breakvaluelong/shortonce breakpointpercentage=4// breakpoint calculationbreakpoint = ((close/10000)*breakpointpercentage)*pointsize// reset low timeframeif intradaybarindex=0 thentradecounter=0tradeday=1endif// holidayif holiday thenif (month = 5 and day = 1) or (month = 12 and day >=24) thentradeday=0elsetradeday=1endifendiftimeframe (1 hour, updateonclose)// reset high timeframeif intradaybarindex=0 thenbreakvaluelong=99999breakvalueshort=0endif// define break valueif (longtrading and not shorttrading) or (longtrading and shorttrading) thenif hour=entryhour and (minute>=entryminute) thenstartbarlong=intradaybarindexbreakvaluelong=highendifendifif (shorttrading and not longtrading) or (longtrading and shorttrading) thenif hour=entryhour and (minute>=entryminute) thenstartbarshort=intradaybarindexbreakvalueshort=lowendifendif// trend detection systemif 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 thenperiod= 2inner = 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=3 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]endifendifendifendif// point pivot [fifi743]if dayofweek < dayofweek[1] thenweeklyhigh = prevweekhighweeklylow = prevweeklowweeklyclose = prevweekcloseprevweekhigh = highprevweeklow = lowweeklypivot = (weeklyhigh + weeklylow + weeklyclose) / 3endifprevweekhigh = max(prevweekhigh, high)prevweeklow = min(prevweeklow, low)prevweekclose = closeif 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) / 3ecart=2ecartwp=3// conditionscondbuy=intradaybarindex=startbarlongcondbuy=condbuy and trendupcondbuy=condbuy and (close>pivot or (close <pivot and (pivot-close)/pointsize >ecart))condbuy=condbuy and (close>weeklypivot or (close <weeklypivot and (weeklypivot-close)/pointsize >ecartwp))condsell=intradaybarindex=startbarshortcondsell=condsell and trenddowncondsell=condsell and (close<pivot or (close>pivot and (close-pivot)/pointsize >ecart))condsell=condsell and (close<weeklypivot or (close>weeklypivot and (close-weeklypivot)/pointsize >ecartwp))timeframe (default)// entryif mode then // mode[1] backtesting on 1 hour timeframeif tradeday and tradecounter < 1 thenif (longtrading and not shorttrading) or (longtrading and shorttrading) thenif condbuy thenbuy positionsize contract at (breakvaluelong+breakpoint) stoptradecounter=tradecounter+1endifendifif (shorttrading and not longtrading) or (longtrading and shorttrading) thenif condsell thensellshort positionsize contract at (breakvalueshort-breakpoint) stoptradecounter=tradecounter+1endifendifendifelse // mode[0] running demo / live on 1 minute timeframeif tradeday and tradecounter < 1 thenif (longtrading and not shorttrading) or (longtrading and shorttrading) thenif condbuy thenif high > breakvaluelong+breakpoint thenbuy positionsize contract at markettradecounter=tradecounter+1endifendifendifif (shorttrading and not longtrading) or (longtrading and shorttrading) thenif condsell thenif low < breakvalueshort-breakpoint thensellshort positionsize contract at markettradecounter=tradecounter+1endifendifendifendifendiftimeframe (1 hour, updateonclose)// trailing atr stop on high timeframeonce trailingstoptype = 1 // trailing stop - 0 off, 1 ononce trailingstoplong = 5 // trailing stop atr relative distanceonce trailingstopshort = 5 // trailing stop atr relative distanceonce atrtrailingperiod = 14 // atr parameter valueonce minstop = 15 // minimum trailing stop distance//----------------------------------------------atrtrail = averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl = round(atrtrail*trailingstoplong)trailingstarts = round(atrtrail*trailingstopshort)//if trailingstoptype thentgl =trailingstartltgs=trailingstartsif not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenmaxprice = 0minprice = closenewsl = 0endifif longonmarket thenmaxprice = max(maxprice,close)if maxprice-tradeprice(1)>=tgl*pointsize thenif maxprice-tradeprice(1)>=minstop thennewsl = maxprice-tgl*pointsizeelsenewsl = maxprice - minstop*pointsizeendifendifendifif shortonmarket thenminprice = min(minprice,close)if tradeprice(1)-minprice>=tgs*pointsize thenif tradeprice(1)-minprice>=minstop thennewsl = minprice+tgs*pointsizeelsenewsl = minprice + minstop*pointsizeendifendifendifendiftimeframe (default)// trailing atr stop exits on low timeframeif trailingstoptype thenif longonmarket thenif newsl>0 thensell at newsl stopendifendifif shortonmarket thenif newsl>0 thenexitshort at newsl stopendifendifendif// close to reduce risk in the weekendif closefriday thenif onmarket thenif (dayofweek=5 and hour=22) thensell at marketexitshort at marketendifendifendif// stoploss & profit targetset target %profit 2set stop %loss 3// display days in marketif displaydim thenif (not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket))) thendim=0endifif not ( dayofweek=1 and hour <= 1) thenif onmarket thenif openday <> openday[1] thendim = dim + 1endifendifendifif onmarket and dayofweek=1 and hour=1 then//dim=-1 // shows when position is active on monday first hourendifif onmarket and dim>=maxdim thensell at marketexitshort at marketendifendif//graph dim // display days in market//graphonprice newsl coloured(0,0,255,255) as "trailingstop atr"//graphonprice breakvaluelong+breakpoint coloured(121,141,35,255) as "breakpoint"//graphonprice breakvalueshort-breakpoint coloured(121,141,35,255) as "breakpoint"//graphonprice breakvaluelong coloured(255,0,0,255) as "breakvaluelong"//graphonprice breakvalueshort coloured(255,0,0,255) as "breakvalueshort"//graph barindex-tradeindex//graph intradaybarindex07/05/2023 at 10:27 AM #217291without understanding why
What Rejection message do you see? Check the Cancelled / Rejected tab on the Orders List?
1 user thanked author for this post.
07/05/2023 at 11:39 AM #217302hi @Grahal,
It says “the level of order is to close from the market level. The minimum is 10 points”;
I thought it was the SL; but apparently not.
I am on IG Live.
Did you launch it live?07/05/2023 at 12:27 PM #21732007/05/2023 at 12:45 PM #217321the level of order is to close from the market level. The minimum is 10 points”;
So does it run in Live for a while (over several bars) but then gets Rejected when it tries to exeute an Order / Trade?
If Yes, then it’s, as fifi says, a pending Buy or SellShort Order as below …
12buy positionsize contract at (breakvaluelong+breakpoint) stopsellshort positionsize contract at (breakvalueshort-breakpoint) stop1 user thanked author for this post.
07/05/2023 at 12:50 PM #21732207/05/2023 at 1:05 PM #217323replace with the code below
1234minidistance=10buy positionsize contract at (breakvaluelong+max(breakpoint,minidistance)) stopsellshort positionsize contract at (breakvalueshort-max(breakpoint,minidistance)) stop1 user thanked author for this post.
07/05/2023 at 4:23 PM #217330You can also, when starting a prepared instance of the system, choose to check the “Re-adjustable stops” checkbox which will allow ProRealTime to adjust the stoploss level based on the current minimum stop distance.
1 user thanked author for this post.
07/05/2023 at 5:53 PM #217332Above only works if the coded pending order is > 10 so best bet is fifi code + enable the adjustabe stop box.
1 user thanked author for this post.
07/06/2023 at 6:02 PM #217376Thanks Guys ^^
Here is the modified code for the followers!
DAX H1 Timehunter v4.5p for IG123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297//-------------------------------------------------------------------------// hoofd code : Timehunter v4.5p 1h dax//-------------------------------------------------------------------------// dax 1 hour timeframe backtest / dax 1 minute live// spread 4// optimise entryhour 0 to 23// optimise entryminute 0 to 59 but set to 0 using 1 hour or higher timeframe// on timeframe 5 minutes with entryminute interval of 5// on timeframe 10 minutes with entryminute interval of 10// on timeframe 15 minutes with entryminute interval of 15// on timeframe 30 minutes with entryminute interval of 30defparam cumulateorders = falsedefparam preloadbars = 1000timeframe (default)once positionsize = 1once mode = 1 // use [1] for 1 hour timeframe, [0] for 1 minute timeframeonce tds = 3 // off when optimising [trend detection system]// separate long/short or go bothonce longtrading =1once shorttrading =1once holiday =1once closefriday =1once displaydim =1 // displays the number of days in market (activated graph)once maxdim =5 // maximum days in market (first day = 0)// select the number of points above/below the breakvaluelong/shortonce entryhour =4once entryminute=0// select the number of points above/below the breakvaluelong/shortonce breakpointpercentage=4// breakpoint calculationbreakpoint = ((close/10000)*breakpointpercentage)*pointsize// reset low timeframeif intradaybarindex=0 thentradecounter=0tradeday=1endif// holidayif holiday thenif (month = 5 and day = 1) or (month = 12 and day >=24) thentradeday=0elsetradeday=1endifendiftimeframe (1 hour, updateonclose)// reset high timeframeif intradaybarindex=0 thenbreakvaluelong=99999breakvalueshort=0endif// define break valueif (longtrading and not shorttrading) or (longtrading and shorttrading) thenif hour=entryhour and (minute>=entryminute) thenstartbarlong=intradaybarindexbreakvaluelong=highendifendifif (shorttrading and not longtrading) or (longtrading and shorttrading) thenif hour=entryhour and (minute>=entryminute) thenstartbarshort=intradaybarindexbreakvalueshort=lowendifendif// trend detection systemif 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 thenperiod= 2inner = 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=3 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]endifendifendifendif// point pivot [fifi743]if dayofweek < dayofweek[1] thenweeklyhigh = prevweekhighweeklylow = prevweeklowweeklyclose = prevweekcloseprevweekhigh = highprevweeklow = lowweeklypivot = (weeklyhigh + weeklylow + weeklyclose) / 3endifprevweekhigh = max(prevweekhigh, high)prevweeklow = min(prevweeklow, low)prevweekclose = closeif 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) / 3ecart=2ecartwp=3// conditionscondbuy=intradaybarindex=startbarlongcondbuy=condbuy and trendupcondbuy=condbuy and (close>pivot or (close <pivot and (pivot-close)/pointsize >ecart))condbuy=condbuy and (close>weeklypivot or (close <weeklypivot and (weeklypivot-close)/pointsize >ecartwp))condsell=intradaybarindex=startbarshortcondsell=condsell and trenddowncondsell=condsell and (close<pivot or (close>pivot and (close-pivot)/pointsize >ecart))condsell=condsell and (close<weeklypivot or (close>weeklypivot and (close-weeklypivot)/pointsize >ecartwp))timeframe (default)minidistance=10// entryif mode then // mode[1] backtesting on 1 hour timeframeif tradeday and tradecounter < 1 thenif (longtrading and not shorttrading) or (longtrading and shorttrading) thenif condbuy thenbuy positionsize contract at (breakvaluelong+max(breakpoint,minidistance)) stoptradecounter=tradecounter+1endifendifif (shorttrading and not longtrading) or (longtrading and shorttrading) thenif condsell thensellshort positionsize contract at (breakvalueshort-max(breakpoint,minidistance)) stoptradecounter=tradecounter+1endifendifendifelse // mode[0] running demo / live on 1 minute timeframeif tradeday and tradecounter < 1 thenif (longtrading and not shorttrading) or (longtrading and shorttrading) thenif condbuy thenif high > breakvaluelong+breakpoint thenbuy positionsize contract at markettradecounter=tradecounter+1endifendifendifif (shorttrading and not longtrading) or (longtrading and shorttrading) thenif condsell thenif low < breakvalueshort-breakpoint thensellshort positionsize contract at markettradecounter=tradecounter+1endifendifendifendifendiftimeframe (1 hour, updateonclose)// trailing atr stop on high timeframeonce trailingstoptype = 1 // trailing stop - 0 off, 1 ononce trailingstoplong = 5 // trailing stop atr relative distanceonce trailingstopshort = 5 // trailing stop atr relative distanceonce atrtrailingperiod = 14 // atr parameter valueonce minstop = 15 // minimum trailing stop distance//----------------------------------------------atrtrail = averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl = round(atrtrail*trailingstoplong)trailingstarts = round(atrtrail*trailingstopshort)//if trailingstoptype thentgl =trailingstartltgs=trailingstartsif not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thenmaxprice = 0minprice = closenewsl = 0endifif longonmarket thenmaxprice = max(maxprice,close)if maxprice-tradeprice(1)>=tgl*pointsize thenif maxprice-tradeprice(1)>=minstop thennewsl = maxprice-tgl*pointsizeelsenewsl = maxprice - minstop*pointsizeendifendifendifif shortonmarket thenminprice = min(minprice,close)if tradeprice(1)-minprice>=tgs*pointsize thenif tradeprice(1)-minprice>=minstop thennewsl = minprice+tgs*pointsizeelsenewsl = minprice + minstop*pointsizeendifendifendifendiftimeframe (default)// trailing atr stop exits on low timeframeif trailingstoptype thenif longonmarket thenif newsl>0 thensell at newsl stopendifendifif shortonmarket thenif newsl>0 thenexitshort at newsl stopendifendifendif// close to reduce risk in the weekendif closefriday thenif onmarket thenif (dayofweek=5 and hour=22) thensell at marketexitshort at marketendifendifendif// stoploss & profit targetset target %profit 2set stop %loss 3// display days in marketif displaydim thenif (not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket))) thendim=0endifif not ( dayofweek=1 and hour <= 1) thenif onmarket thenif openday <> openday[1] thendim = dim + 1endifendifendifif onmarket and dayofweek=1 and hour=1 then//dim=-1 // shows when position is active on monday first hourendifif onmarket and dim>=maxdim thensell at marketexitshort at marketendifendif//graph dim // display days in market//graphonprice newsl coloured(0,0,255,255) as "trailingstop atr"//graphonprice breakvaluelong+breakpoint coloured(121,141,35,255) as "breakpoint"//graphonprice breakvalueshort-breakpoint coloured(121,141,35,255) as "breakpoint"//graphonprice breakvaluelong coloured(255,0,0,255) as "breakvaluelong"//graphonprice breakvalueshort coloured(255,0,0,255) as "breakvalueshort"//graph barindex-tradeindex//graph intradaybarindex1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on