SebParticipant
Average
Hello, as some of you know IG has a trading session overnight for DAX outside of the regular futures session (08:00-22:00). The issue I have is that I want to plot the bars of this extra IG session, but I don’t want to use the OHLC data of those bars for my indicators for backtesting purposes. Does anybody know a solution for this?
For accurate calculation, it would be great to make personal arrays of data, and apply calculation of each of the indicators you are using on them, but it is not possible. However, there are 2 possibilities:
- use a time condition to allow or not your variables to be populated or not with the price data (the easy way, but not the more accurate one …)
- deconstruct all your indicators’ codes, make loops in the past, add time conditions to jump other not desired datas, and inject OHLC into indis calculation (the hard way but the better, but with limitations and a very painful work…).
SebParticipant
Average
Thank you Nicolas, do you have an example of possibility 2 for a simple indicator like Donchian?
ok, so to be clear, with the Donchian channel, let’s say of 20 periods, do you want to use the yesterday’s bars (before 220000 yesterday) for the calculation of the first 20 periods of the day (after 080000)?
Ok, this should work, please let’s try it and give feedbacks:
defparam flatafter = 210000
if longonmarket then
alreadybuy=1
endif
if shortonmarket then
alreadysell=1
endif
if intradaybarindex=0 then
alreadybuy=0
alreadysell=0
profit=strategyprofit
endif
if time = 061000 then
yh = highest[86](high)
yL=lowest[86](low)
os = 2*pipsize
endif
tcondition = time>080000 and time<200000
if tcondition and strategyprofit<=profit then
if close<yh+os and not alreadybuy then
buy 1 contract at yh+os stop
endif
if close>yl+os and not alreadysell then
sellshort 1 contract at yl-os stop
endif
endif
set stop ploss 15
set target pprofit 15
SebParticipant
Average
I tried the code, I changed “profit” to “profits” as profit is a function.
I graphed the “yh”, but this doesn’t update during the day as new highs are made (and your target or stop might be hit). you could use the normal highest[20](high) after the first 20 bars after 08:00. Until that you must count “x” up to 20 with the highest[x](high) to compare with “yh” if you want to be accurate.
Thanks for this idea!
SebParticipant
Average
What was the code that you used for the indicator you attached?
oh sorry, I posted the wrong code… it has nothing to deal with your indicator and I think I deleted it ; let’s do it again!! :angry:
I need to rest a bit! Too hot near a computer 🙂
period = 20
tcondition = time>=080000 and time<220000
hh=0
ll=close*100
count=0
for i = 0 to barindex do
if tcondition[i] then
hh=max(hh,high[i])
ll=min(ll,low[i])
count=count+1
if count=period then
break
endif
endif
next
return hh,ll
SebParticipant
Average
that is some smart code, merci Nicolas!
SebParticipant
Average
Trying to get my head around the code to make an ATR version now, but like you said, very painful work!