No entry before 11AM Monday

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #76284 quote
    Bullets
    Participant
    Junior

    Hi,

    I’m have some trouble trying to code no entry between say Saturday 12PM and Monday 11AM.

    At the start of my strategy code.

    Can any assist?

    Thanks

    #76292 quote
    robertogozzi
    Moderator
    Master

    Here you can find the coding example to use (lines 7 and 10, then 25 and 30) https://www.prorealcode.com/topic/d-i-rsioma-trend-following-on-dax/.

    #76303 quote
    GraHal
    Participant
    Master

    Above added as row 51 to Snippet Library Snippet Link Library

    robertogozzi thanked this post
    #76304 quote
    Bullets
    Participant
    Junior

    Hi, its not quite what I’m after. I’m running a 24 hour FX strategy, but what I’m finding is it takes trades as soon as the market opens on Monday morning when the spreads are very large and there is a gap. So I Just want it to only take trades from 11AM monday all the way to Friday when the FX markets close.

    So what I need is a time range which overlaps into days rather than a time interval per day. Like for example, if the time is between Monday after 11AM to Saturday 11AM then enter the trade.

    #76305 quote
    Vonasi
    Moderator
    Master

    You could just set a flag on or off.

    if opentime = 110000 and opendayofweek = 1 then
    tradeflag = 1
    endif
    
    if opentime = 110000 and opendayofweek = 6 then
    tradeflag = 0
    endif
    
    if tradeflag and (your entry conditions) then
    buy 1 contract at market
    endif
    
    #76309 quote
    Bullets
    Participant
    Junior

    Just so I understand exactly what that does –

    Does the first part require the system to be on and when it clicks to 11AM on Monday the timeflag = 1

    What happens if the system gets shut off mid week and I turn it back on, and hence the time has already passed Monday 11AM will the timeflag still be 1?

    And the same goes for Saturday, what if my expiry is on Friday and I only start the system on Sunday, because the time never passed 11am Saturday when the system is onn, is it possible for the timeflag to be 1 on Monday before 11AM given the condition of opentime on the Saturday was never meet?

    Thank you

    #76310 quote
    GraHal
    Participant
    Master

    Above also saved to Snippet Library as row 52

    #76312 quote
    Vonasi
    Moderator
    Master

    Your strategy will do nothing until the trigger time is hit. I think this will allow you to start your strategy at any time and start trading immediately. Not tested – I suggest graphing tradeflag to check it does what you want it to do.

    if (opendayofweek = 6 and opentime < 110000) or (opendayofweek = 1 and opentime >= 110000) or (opendayofweek >= 2 and opendayofweek <= 5) then
    tradeflag = 1
    else 
    tradeflag = 0
    endif
     
    if tradeflag and (your entry conditions) then
    buy 1 contract at market
    endif
    #76313 quote
    Bullets
    Participant
    Junior

    I think that code marks sense now.

    Thankyou!

    #76314 quote
    Vonasi
    Moderator
    Master

    You don’t really need the if then else so a shorter version would be:

    timeok = (opendayofweek = 6 and opentime < 110000) or (opendayofweek = 1 and opentime >= 110000) or (opendayofweek >= 2 and opendayofweek <= 5) then
    
    if timeok and (your entry conditions) then
    buy 1 contract at market
    endif
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

No entry before 11AM Monday


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Bullets @bullets Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by Vonasi
7 years, 7 months ago.

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