HOURLY BIAS

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #181100 quote
    Wolf Trades
    Participant
    Average

    Hi Guys, I tried to write a code about hourly bias (from 00:00 to 10:00)  but TS doesn’t open some trade.

    It opened a trade at 01:00 and close at 02:00  CORRECT

    no opened a trade at 02:00 and close at 03:00 UNCORRECT

    It opened a trade at 03:00 and close at 04:00  CORRECT

    no opened a trade at 04:00 and close at 05:00 UNCORRECT

    can you help me?

    Defparam CumulateOrders = false
    Defparam FlatAfter = 210000
    Size = 1
    Chiusura = 1 //dopo una barra
    SabatoeDomenica = OpenDayofWeek = 6 or OpenDayofWeek = 7
    
    // dalle 00:00 alle 01:00
    IF not SabatoeDomenica and CurrentTime = 000000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 010000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 01:00 alle 02:00
    IF not SabatoeDomenica and CurrentTime = 010000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 020000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 02:00 alle 03:00
    IF not SabatoeDomenica and CurrentTime = 020000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 030000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 03:00 alle 04:00
    IF not SabatoeDomenica and CurrentTime = 030000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 040000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 04:00 alle 05:00
    IF not SabatoeDomenica and CurrentTime = 040000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 050000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 05:00 alle 06:00
    IF not SabatoeDomenica and CurrentTime = 050000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 060000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 06:00 alle 07:00
    IF not SabatoeDomenica and CurrentTime = 060000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 070000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 07:00 alle 08:00
    IF not SabatoeDomenica and CurrentTime = 070000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 080000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 08:00 alle 09:00
    IF not SabatoeDomenica and CurrentTime = 080000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 090000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    // dalle 09:00 alle 10:00
    IF not SabatoeDomenica and CurrentTime = 090000 THEN
    BUY Size CONTRACTS AT MARKET
    ENDIF
    //
    IF CurrentTime = 100000 THEN
    SELL Size CONTRACTS AT MARKET
    ENDIF
    //
    
    BIAS.jpg BIAS.jpg
    #181102 quote
    PeterSt
    Participant
    Master

    Do it everywhere like this and it will start to respond as expected :

     

    // dalle 00:00 alle 01:00
    JustTraded = 0
    IF not JustTraded and not SabatoeDomenica and CurrentTime = 000000 THEN
      BUY Size CONTRACTS AT MARKET
      JustTraded = 1
    ENDIF
    //
    IF not JustTraded and CurrentTime = 010000 THEN
      SELL Size CONTRACTS AT MARKET
      JustTraded = 1
    ENDIF
    #181107 quote
    pror
    Participant
    Veteran

    Defparam CumulateOrders = true ?

    #181112 quote
    robertogozzi
    Moderator
    Master

    Sunday is 0, not 7.

    #181130 quote
    Wolf Trades
    Participant
    Average

    I Tried this way but the problem is the same.

    #181131 quote
    JohnScher
    Participant
    Veteran

    try this

     

    td = opendayofweek = 1 or opendayofweek = 2 or opendayofweek = 3 or opendayofweek = 4 or opendayofweek = 5
    tt = time   >= 000000 and time <= 090000
    
    If not onmarket and td and tt then
    buy at market
    Endif
    
    If onmarket then
    sell at market
    Endif
    
    #181132 quote
    robertogozzi
    Moderator
    Master

    The OnMarket status is updated the bar AFTER a trade is closed, so line 18  will not be executed at 010000 since a trade has just been closed but will be reported next bar, at 011500, so it will be skipped. There can’t be 2 trades opened at the same time.

    This is because you set line 1 to FALSE. Set it to TRUE, instead.

    #181144 quote
    Wolf Trades
    Participant
    Average

    It’s the same, it doesn’t works.

    #181161 quote
    robertogozzi
    Moderator
    Master

    Firstly, OpenDayOfWeek changes when the DAILY candle changes, so:

    • now, without DST, it changes at 00:00 (Utc+1) at the same time the DAY changes
    • when DST is active, it changes at 01:00 (Utc+2), while the DAY changes as usual at 00:00 (Utc+1), so there’s ONE whole hour when it’s reported as a new DAY, but as the old DAYOFWEEK. Adding GRAPH OpenDayOfWeek will help spot it on Mondays, when the 00:00 trade is never opened.

    Secondly, as I said in my previous post, ProOrder needs a whole bar to be aware of any update uf the OnMarket status, so when at 02:00 you want to close a trade, it DOES, but it can’t open a new one because the confirmation of the exit will be received from the broker after the new bar has started forming and can be dealt with only when it closes. If you replace any BUY time with minute 1500 (or 0100 if you use a 1-minute TF) instead of 0000, everything will run smoothly.

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

HOURLY BIAS


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Wolf Trades @lupo32 Participant
Summary

This topic contains 8 replies,
has 5 voices, and was last updated by robertogozzi
4 years, 3 months ago.

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