Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop trading for a period of time(Longer than a day and shorter than a day)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Stop trading for a period of time(Longer than a day and shorter than a day)

    As I am developing my strategy, I wanted to test to stop trading for some x period of time. However, I realized that i can only implement the logic for not trading for the day by using if Bars.IsFirstBarOfSession

    I wanted to test my strategy using different periods of time
    1. longer than a day(ie. a week or a month)
    2. shorter than day(ie. an hour).

    How would I go about this.

    Thank you again!

    #2
    Hi tchen7, thanks for writing in. To go longer than one day you will need to use DateTime variables and check the Time[0] timestamp on every bar to make sure the time stamp has not passed that exact date. Time[] is an array full of DateTime objects for each bar on the chart, and the documentation for DateTime is linked below:

    https://learn.microsoft.com/en-us/do...e?view=net-7.0 (publicly available).

    I found an example here that will be helpful:
    https://stackoverflow.com/questions/...an-30-days-old (publicly available)

    Kind regards,
    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by furelaong, 06-18-2025, 11:04 PM
    0 responses
    21 views
    0 likes
    Last Post furelaong  
    Started by futurenow, 12-06-2021, 05:49 PM
    19 responses
    1,005 views
    0 likes
    Last Post Redders
    by Redders
     
    Started by mathfrick2023, 05-08-2025, 12:51 PM
    8 responses
    118 views
    0 likes
    Last Post Yogaman
    by Yogaman
     
    Started by several, 04-22-2025, 05:21 AM
    1 response
    280 views
    0 likes
    Last Post Lukasxgtx  
    Started by NTEducationTeam, 06-12-2025, 02:30 PM
    0 responses
    44 views
    0 likes
    Last Post NTEducationTeam  
    Working...
    X