Custom trading hours won't work with dopen/dclose

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #138488 quote
    mykologen
    Participant
    Average

    Hi!

    I have been using GAP-strategies (SPTRD/USA500) with custom trading hours for the US market UTC+1 (14:30-21:00 + enabled the Daily data option) without any issues.

    Now I am taking the same approach for Swedish market open UTC (08:00-16:30 + enable daily data) and this won’t work as intended. The candles/price is cut off in the right way on my chart but the strategy doesn’t work properly. It will for example trade even though the open-price is not above previous close. It seems to work if I restrict the time from 10:00-16:30 but then the data is of course incorrect. Attached my settings and a trade that shouldn’t happen.

    Any idea what might be wrong?

    DEFPARAM CumulateOrders = False
    
    if date>date[1] and dopen(0)>dclose(1) then
    gap=1
    else
    gap=0
    endif
    
    if gap=1 then
    Buy 1 contract at market
    Endif
    
    if longonmarket and time=170000 then
    sell at market
    endif
    Timeframe.png Timeframe.png Trade.png Trade.png
    #138495 quote
    GraHal
    Participant
    Master

    I haven’t digested all you say, but a couple of other members on here have made comments about Gap Strategies not working recently.

    Link below

    https://www.prorealcode.com/topic/prt-not-showing-gaps/

    #138592 quote
    mykologen
    Participant
    Average

    Strange… In my case I cut off the price manually, hence I create the GAPs but PRT won’t understand them. I am just confused since the same approach works for the US market. Will contact PRT.

    #138992 quote
    mykologen
    Participant
    Average

    No answer from PRT but found out that on the 5 min TF code below will work properly. However on the 1-4 min TF neither does my first code or this one work as intended, I am clueless.

    ONCE entertime = 090000
    tt1 = opentime >= entertime
    tt2 = opentime <= entertime
    tradetime = tt1 and tt2
    
    ONCE closetime = 172500
    if opentime >= closetime and opentime <= closetime then
    lastcl = close
    endif
    
    If NOT LongOnMarket and tradetime and close > lastcl then
    Buy 1 contract at market
    endif
    
    if longonmarket and time=closetime then
    sell at market
    endif
    #138996 quote
    mykologen
    Participant
    Average

    Seems to work now, it was somehow bugged, had to switch from 1 min TF to 5 min and then back again to reload the candles/data, then it suddenly started to work on the 1 min TF as intended…

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

Custom trading hours won't work with dopen/dclose


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
mykologen @mykologen Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by mykologen
5 years, 7 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 07/05/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...