Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    55 responses
    2,139 views
    0 likes
    Last Post BudaTrader  
    Started by Board game geek, 10-29-2023, 12:00 PM
    15 responses
    315 views
    0 likes
    Last Post givemefood  
    Started by notenufftime, Today, 07:09 PM
    0 responses
    3 views
    0 likes
    Last Post notenufftime  
    Started by fingers, 12-15-2023, 08:44 AM
    8 responses
    189 views
    0 likes
    Last Post notenufftime  
    Started by PapaKurt, Today, 06:40 PM
    0 responses
    7 views
    0 likes
    Last Post PapaKurt  
    Working...
    X