ProRealCode - Trading & Coding with ProRealTime™
@Paul, do you trust these to let them take orders in real? Only in Demo for now? The drawdown looks a bit high isnt it?
Otherwise incredible job 😀
Thnx. Just occasionally I check the how it would’ve performed OOS. I don’t have it in demo or live.
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.
here 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!
Thank You Paul for yet another intriguing Strategy!
I’m putting attached on Demo Forward Test.
Spread = 5
@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
//-------------------------------------------------------------------------
// 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 30
defparam cumulateorders = false
defparam preloadbars = 1000
timeframe (default)
once positionsize = 1
once mode = 1 // use [1] for 1 hour timeframe, [0] for 1 minute timeframe
once tds = 3 // off when optimising [trend detection system]
// separate long/short or go both
once longtrading =1
once shorttrading =1
once holiday =1
once closefriday =1
once 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/short
once entryhour =4
once entryminute=0
// select the number of points above/below the breakvaluelong/short
once breakpointpercentage=4
// breakpoint calculation
breakpoint = ((close/10000)*breakpointpercentage)*pointsize
// reset low timeframe
if intradaybarindex=0 then
tradecounter=0
tradeday=1
endif
// holiday
if holiday then
if (month = 5 and day = 1) or (month = 12 and day >=24) then
tradeday=0
else
tradeday=1
endif
endif
timeframe (1 hour, updateonclose)
// reset high timeframe
if intradaybarindex=0 then
breakvaluelong=99999
breakvalueshort=0
endif
// define break value
if (longtrading and not shorttrading) or (longtrading and shorttrading) then
if hour=entryhour and (minute>=entryminute) then
startbarlong=intradaybarindex
breakvaluelong=high
endif
endif
if (shorttrading and not longtrading) or (longtrading and shorttrading) then
if hour=entryhour and (minute>=entryminute) then
startbarshort=intradaybarindex
breakvalueshort=low
endif
endif
// trend detection system
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
period= 2
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=3 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
// point pivot [fifi743]
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
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
ecart=2
ecartwp=3
// conditions
condbuy=intradaybarindex=startbarlong
condbuy=condbuy and trendup
condbuy=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=startbarshort
condsell=condsell and trenddown
condsell=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)
// entry
if mode then // mode[1] backtesting on 1 hour timeframe
if tradeday and tradecounter < 1 then
if (longtrading and not shorttrading) or (longtrading and shorttrading) then
if condbuy then
buy positionsize contract at (breakvaluelong+breakpoint) stop
tradecounter=tradecounter+1
endif
endif
if (shorttrading and not longtrading) or (longtrading and shorttrading) then
if condsell then
sellshort positionsize contract at (breakvalueshort-breakpoint) stop
tradecounter=tradecounter+1
endif
endif
endif
else // mode[0] running demo / live on 1 minute timeframe
if tradeday and tradecounter < 1 then
if (longtrading and not shorttrading) or (longtrading and shorttrading) then
if condbuy then
if high > breakvaluelong+breakpoint then
buy positionsize contract at market
tradecounter=tradecounter+1
endif
endif
endif
if (shorttrading and not longtrading) or (longtrading and shorttrading) then
if condsell then
if low < breakvalueshort-breakpoint then
sellshort positionsize contract at market
tradecounter=tradecounter+1
endif
endif
endif
endif
endif
timeframe (1 hour, updateonclose)
// trailing atr stop on high timeframe
once trailingstoptype = 1 // trailing stop - 0 off, 1 on
once trailingstoplong = 5 // trailing stop atr relative distance
once trailingstopshort = 5 // trailing stop atr relative distance
once atrtrailingperiod = 14 // atr parameter value
once minstop = 15 // minimum trailing stop distance
//----------------------------------------------
atrtrail = averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000
trailingstartl = round(atrtrail*trailingstoplong)
trailingstarts = round(atrtrail*trailingstopshort)
//
if trailingstoptype then
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
endif
timeframe (default)
// trailing atr stop exits on low timeframe
if trailingstoptype then
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
endif
// close to reduce risk in the weekend
if closefriday then
if onmarket then
if (dayofweek=5 and hour=22) then
sell at market
exitshort at market
endif
endif
endif
// stoploss & profit target
set target %profit 2
set stop %loss 3
// display days in market
if displaydim then
if (not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket))) then
dim=0
endif
if not ( dayofweek=1 and hour <= 1) then
if onmarket then
if openday <> openday[1] then
dim = dim + 1
endif
endif
endif
if onmarket and dayofweek=1 and hour=1 then
//dim=-1 // shows when position is active on monday first hour
endif
if onmarket and dim>=maxdim then
sell at market
exitshort at market
endif
endif
//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 intradaybarindex
without understanding why
What Rejection message do you see? Check the Cancelled / Rejected tab on the Orders List?
hi @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?
the 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 …
buy positionsize contract at (breakvaluelong+breakpoint) stop
sellshort positionsize contract at (breakvalueshort-breakpoint) stop
The breakpoint must be greater than 10 points
replace with the code below
minidistance=10
buy positionsize contract at (breakvaluelong+max(breakpoint,minidistance)) stop
sellshort positionsize contract at (breakvalueshort-max(breakpoint,minidistance)) stop
You 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.
Above only works if the coded pending order is > 10 so best bet is fifi code + enable the adjustabe stop box.
Thanks Guys ^^
Here is the modified code for the followers!
//-------------------------------------------------------------------------
// 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 30
defparam cumulateorders = false
defparam preloadbars = 1000
timeframe (default)
once positionsize = 1
once mode = 1 // use [1] for 1 hour timeframe, [0] for 1 minute timeframe
once tds = 3 // off when optimising [trend detection system]
// separate long/short or go both
once longtrading =1
once shorttrading =1
once holiday =1
once closefriday =1
once 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/short
once entryhour =4
once entryminute=0
// select the number of points above/below the breakvaluelong/short
once breakpointpercentage=4
// breakpoint calculation
breakpoint = ((close/10000)*breakpointpercentage)*pointsize
// reset low timeframe
if intradaybarindex=0 then
tradecounter=0
tradeday=1
endif
// holiday
if holiday then
if (month = 5 and day = 1) or (month = 12 and day >=24) then
tradeday=0
else
tradeday=1
endif
endif
timeframe (1 hour, updateonclose)
// reset high timeframe
if intradaybarindex=0 then
breakvaluelong=99999
breakvalueshort=0
endif
// define break value
if (longtrading and not shorttrading) or (longtrading and shorttrading) then
if hour=entryhour and (minute>=entryminute) then
startbarlong=intradaybarindex
breakvaluelong=high
endif
endif
if (shorttrading and not longtrading) or (longtrading and shorttrading) then
if hour=entryhour and (minute>=entryminute) then
startbarshort=intradaybarindex
breakvalueshort=low
endif
endif
// trend detection system
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
period= 2
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=3 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
// point pivot [fifi743]
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
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
ecart=2
ecartwp=3
// conditions
condbuy=intradaybarindex=startbarlong
condbuy=condbuy and trendup
condbuy=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=startbarshort
condsell=condsell and trenddown
condsell=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
// entry
if mode then // mode[1] backtesting on 1 hour timeframe
if tradeday and tradecounter < 1 then
if (longtrading and not shorttrading) or (longtrading and shorttrading) then
if condbuy then
buy positionsize contract at (breakvaluelong+max(breakpoint,minidistance)) stop
tradecounter=tradecounter+1
endif
endif
if (shorttrading and not longtrading) or (longtrading and shorttrading) then
if condsell then
sellshort positionsize contract at (breakvalueshort-max(breakpoint,minidistance)) stop
tradecounter=tradecounter+1
endif
endif
endif
else // mode[0] running demo / live on 1 minute timeframe
if tradeday and tradecounter < 1 then
if (longtrading and not shorttrading) or (longtrading and shorttrading) then
if condbuy then
if high > breakvaluelong+breakpoint then
buy positionsize contract at market
tradecounter=tradecounter+1
endif
endif
endif
if (shorttrading and not longtrading) or (longtrading and shorttrading) then
if condsell then
if low < breakvalueshort-breakpoint then
sellshort positionsize contract at market
tradecounter=tradecounter+1
endif
endif
endif
endif
endif
timeframe (1 hour, updateonclose)
// trailing atr stop on high timeframe
once trailingstoptype = 1 // trailing stop - 0 off, 1 on
once trailingstoplong = 5 // trailing stop atr relative distance
once trailingstopshort = 5 // trailing stop atr relative distance
once atrtrailingperiod = 14 // atr parameter value
once minstop = 15 // minimum trailing stop distance
//----------------------------------------------
atrtrail = averagetruerange[atrtrailingperiod]((close/10)*pipsize)/1000
trailingstartl = round(atrtrail*trailingstoplong)
trailingstarts = round(atrtrail*trailingstopshort)
//
if trailingstoptype then
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
endif
timeframe (default)
// trailing atr stop exits on low timeframe
if trailingstoptype then
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
endif
// close to reduce risk in the weekend
if closefriday then
if onmarket then
if (dayofweek=5 and hour=22) then
sell at market
exitshort at market
endif
endif
endif
// stoploss & profit target
set target %profit 2
set stop %loss 3
// display days in market
if displaydim then
if (not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket))) then
dim=0
endif
if not ( dayofweek=1 and hour <= 1) then
if onmarket then
if openday <> openday[1] then
dim = dim + 1
endif
endif
endif
if onmarket and dayofweek=1 and hour=1 then
//dim=-1 // shows when position is active on monday first hour
endif
if onmarket and dim>=maxdim then
sell at market
exitshort at market
endif
endif
//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 intradaybarindex
strategy BarHunter DAX v1p
This topic contains 255 replies,
has 11 voices, and was last updated by sfl
2 years, 6 months ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 01/15/2020 |
| Status: | Active |
| Attachments: | 136 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.