Don't want to use DAX afterhours session to calculate indicators

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #75215 quote
    Seb
    Participant
    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?

    #75246 quote
    Nicolas
    Keymaster
    Master

    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:

    1. 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 …)
    2. 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…).
    Seb thanked this post
    #75267 quote
    Seb
    Participant
    Average

    Thank you Nicolas, do you have an example of possibility 2 for a simple indicator like Donchian?

    #75274 quote
    Nicolas
    Keymaster
    Master

    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)?

    #75285 quote
    Seb
    Participant
    Average

    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)?

    exactly!

    #75304 quote
    Nicolas
    Keymaster
    Master

    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
    Seb thanked this post
    custom-donchian-channel-to-avoid-after-market-hours.png custom-donchian-channel-to-avoid-after-market-hours.png
    #75310 quote
    Seb
    Participant
    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!

    #75332 quote
    Seb
    Participant
    Average

    What was the code that you used for the indicator you attached?

    #75339 quote
    Nicolas
    Keymaster
    Master

    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:

    #75340 quote
    Nicolas
    Keymaster
    Master

    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
    #75364 quote
    Seb
    Participant
    Average

    that is some smart code, merci Nicolas!

    #75481 quote
    Seb
    Participant
    Average

    Trying to get my head around the code to make an ATR version now, but like you said, very painful work!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Don't want to use DAX afterhours session to calculate indicators


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Seb @seb Participant
Summary

This topic contains 11 replies,
has 2 voices, and was last updated by Seb
7 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/04/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...