Extreme weekend gaps

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #163433 quote
    Johann
    Participant
    Average

    Hi Nicolas,

    Trying to see if I can figure out what happens on weekend gaps? Battling to define the Friday close and Monday open. Want to use it in a hourly timeframe as a filter to either trade the Monday or not depending on the gap…

    Timeframe(daily,updateonclose)
    If dayofweek = 5 Then
    gapclose = close
    Elsif dayofweek = 1  Then
    gapopen = open
    Endif
    If dayofweek = 1 Then
    If (gapopen-gapclose)>100 Then
    gapweekup=1
    Else
    gapweekup=0
    Endif
    Endif
    Timeframe(default)
    If gapweekup=1 and Average[5](close) crosses under Average[15](close) Then
    Sellshort 1 contract at market
    Endif
    SET STOP pLOSS 100
    SET TARGET pPROFIT 100
    
    
    #163435 quote
    Vonasi
    Moderator
    Master

    Strategy code is run at the close of a candle so with UPDATEONCLOSE your strategy cannot know until the close of a daily candle what the open value was for that candle – so you will need to use a faster time frame or DEFAULT if you want to catch the Monday opening price and place orders based on it at the market open.

    #163439 quote
    Johann
    Participant
    Average

    Thanks Vonasi,

    I tried the following on the hourly tf…but it does not register the Friday close and Monday open correctly any suggestions?

    If dayofweek = 5 and time = 230000 Then
    gapclose = close
    Elsif dayofweek = 1 and time = 10000 Then
    gapopen = open
    Endif
    If dayofweek = 1 and time = 10000 Then
    If (gapopen-gapclose)>100 Then
    gapweekup=1
    Else
    gapweekup=0
    Endif
    Endif
    #163443 quote
    Johann
    Participant
    Average

    Not to worry figured it out should be 20000…

    #163448 quote
    Vonasi
    Moderator
    Master

    A candle can be identified by two reference times.

    TIME = the closing time of the candle (which is also the same as the opening time of the following candle).

    OPENTIME = the opening time of the candle (which is also the same as the closing time of the previous candle).

    So the hourly candle that opens at 010000 will close at 020000 and can be referenced as either OPENTIME = 010000 or TIME = 020000

     

    It is similar with OPENDAYOFWEEK and DAYOFWEEK.

    Johann thanked this post
    #163571 quote
    Johann
    Participant
    Average

    Hi Vonasi, thought I had did but I just don’t seem to get it right for the code to take the close on a Friday at 230000 and compare it to the open on the Monday at 10000. Any suggestions either as a indicator or strategy on a hourly timeframe?

    #163632 quote
    Vonasi
    Moderator
    Master

    If you add this indicator to your chart it can help to clarify things:

    return opendayofweek as "opendayofweek", dayofweek as "dayofweek", time as "time", opentime as "opentime"

     

    It would appear that the candle that closes at 010000 is classified as opening at 000000 on Sunday. So you should be looking for dayofweek = 0 and time = 10000.

    Johann thanked this post
    Screenshot_2.png Screenshot_2.png
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Extreme weekend gaps


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Johann @johann Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by Vonasi
4 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/08/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...