prevent my system from taking a trade with CurrentDayOfWeek condition

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #145170 quote
    scoot3r83scoot3r83
    Participant
    Average

    Hi,

    I’m trying to prevent my system from taking a trade prior to 8pm Sunday night for a system in the US.. to avoid the ASX open. I have added this code however it does not prevent the trade entry.

    noTradeTimeBlock = NOT (CurrentTime < 160000 AND CurrentTime < 200000 AND CurrentDayOfWeek = 0)

    I have then included ‘noTradeTimeBlock’ in the buy order requirements. I understand this to say to remain false if the time is between 4pm & 8pm of a Sunday. Is there something incorrect here?

    When backtesting the system, a trade is still taken at 19:10 of a Sunday night, which I’m trying to avoid. I do also have the PRT time settings set to New York UTC +04:00.

    #145182 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Do Not use CURRENTTIME, use either TIME (time when a bar closes)  or OPENTIME (time when a bar opens).

    Try this (not tested):

    noTradeTimeBlock = OpenTime < 200000 AND CurrentDayOfWeek = 0
    #145652 quote
    scoot3r83scoot3r83
    Participant
    Average

    Hi @robertogozzi, thanks for the reply. I tried the code you suggested using ‘OpenTime’ or ‘Time’ and it works but begins to fail when I include the ‘CurrentDayOfWeek=0’. I am trying to avoid the opening of a trade in the hours before the markets open in New York time (8pm).

    So, this works to exclude the trade within the time as below

    noTradeTimeBlock = NOT ((Time >= 140000) AND (Time <= 200000))

    but as soon as I add the CurrentDayOfWeek function it begins to fail to remove the trades in the time frame I am trying to avoid.

    noTradeTimeBlock = NOT ((Time >= 140000) AND (Time <= 200000) AND (CurrentDayOfWeek=0))

    So in plain terms, if it is a Sunday and between 2pm and 8pm I want the strategy not to open any trade. So ‘noTradeTimeBlock’ will positive or true only when it is not a Sunday & between 2pm & 8pm.

    I don’t believe the syntax is incorrect but have I then used the ‘CurrentDayOfWeek’ function incorrectly?

    #145655 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Sorry, I incorrectly used CURRENTdayofweek, use OpenDayOfWeek

    o or DayOfWeek, instead.

    #145700 quote
    scoot3r83scoot3r83
    Participant
    Average

    Same results. This really has me puzzled.

    #145710 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    TIME or OPENTIME will use your time zone, not NY’s.

    Did you take this into account?

    scoot3r83 thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

prevent my system from taking a trade with CurrentDayOfWeek condition


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
scoot3r83 @scoot3r83 Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
5 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/24/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...