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 ZeroKuhl, 05-30-2024, 10:22 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by johnsb1990, Today, 09:34 AM
    0 responses
    6 views
    0 likes
    Last Post johnsb1990  
    Started by psangram, Today, 09:30 AM
    0 responses
    6 views
    0 likes
    Last Post psangram  
    Started by gabberdim, Today, 09:14 AM
    2 responses
    9 views
    0 likes
    Last Post gabberdim  
    Started by kiss987, 05-16-2018, 02:19 AM
    13 responses
    2,849 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X