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 burtoninlondon, Today, 12:38 AM
    0 responses
    5 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    13 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,982 views
    3 likes
    Last Post jhudas88  
    Working...
    X