skip first x days in a backtest on any TF

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #103253 quote
    Paul
    Participant
    Master

    Hello,

    I’am trying to see no trades in the first 5 days of a backtest on any timeframe.

    Coded the way below & other ways, but still I see trades.

    if intradaybarindex=0 then
    if barindex=0 then
    storedate1=date
    endif
    if date>storedate1 then
    storedate2=date
    endif
    if date>storedate2 then
    storedate3=date
    endif
    if date>storedate3 then
    storedate4=date
    endif
    if date>storedate4 then
    storedate5=date
    endif
    if date>storedate5 then
    tradingok=1
    else
    tradingok=0
    endif
    endif

    Could some plz advise what is wrong?

    #103256 quote
    robertogozzi
    Moderator
    Master

    Try this (not tested):

    IF barindex = 0 THEN
       TradeON = 0
       Count   = 0
    ENDIF
    IF OpenDay <> OpenDay[1] THEN
       Count = Count + 1
       IF Count <= 5 THEN
          TradeON = 0
       ELSE
          TradeON = 1
       ENDIF
    ENDIF
    IF MyConditions AND TradeON THEN
     .
     .
    ENDIF
    Paul thanked this post
    #103278 quote
    Paul
    Participant
    Master

    Thanks that does the trick and this code is easier to use!

    #103636 quote
    Paul
    Participant
    Master

    Just for reference;

    Used a code to count the days a position was onmarket and found that between 0 and 1am on Monday it counts (sometimes?) as a day too. So on Monday the counter goes up with 2.

    This code below seems to fix that.

    if (not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket))) then
    count=0
    endif
    if  not ( dayofweek=1 and hour <= 1) then
    if onmarket then
    IF OpenDay <> OpenDay[1] THEN
    count = Count + 1
    endif
    endif
    endif
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

skip first x days in a backtest on any TF


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Paul @micky75d Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Paul
6 years, 7 months ago.

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