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 abelsheila, Yesterday, 07:38 PM
    1 response
    14 views
    0 likes
    Last Post hglover945  
    Started by nailz420, Yesterday, 09:14 AM
    1 response
    44 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by NinjaTrader_Brett, 05-12-2025, 03:19 PM
    0 responses
    280 views
    1 like
    Last Post NinjaTrader_Brett  
    Started by domjabs, 05-12-2025, 01:55 PM
    2 responses
    57 views
    0 likes
    Last Post domjabs
    by domjabs
     
    Started by Morning Cup Of Trades, 05-12-2025, 11:50 AM
    1 response
    62 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Working...
    X