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

Time restraints

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

    Time restraints

    Trying to build a simple daily chart strategy with a set time entry and exit.
    Current program,
    set 1
    "other indicators"
    (Times[0][0].TimeOfDay == new TimeSpan(8, 0, 0))) I have it set to enter long.

    Set 2
    (Times[0][0].TimeOfDay == new TimeSpan(15, 0, 0)) In order to exit the long.

    The problem I am running into is it is buying at 4PM one day and exiting the trade the next day at 4PM according to the strat analyzer. This makes it skip days it could have traded on I have attempted to link the buy and close into the input variables as well as making time region over a hour or so and STILL no dice.... I cannot figure out why it can't buy in the morning and sell in the afternoon of the same day. I have set a few other times on other programs and they work just as indented on smaller time frames. I've tried building it exactly as shown in the NinjaTrader time set-up page but cannot figure out why it is not working. Any help would be appreciated.
    Thanks

    #2
    Hello ejasper,

    Welcome to the NinjaTrader forums!

    What is the Calculate setting set to in the strategy parameters?


    What about the chart, is this a 60 minute chart or a day bar chart?

    If you are viewing historical data, is TickReplay enabled?


    An example of a time filter can be found in the help guide.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea,
      Thanks for the reply.

      I have the calculate "On bar close". I went back through and tried changing to the calculate "on each tick" and could not get it to change.

      I am using the daily chart.

      I am using the strategy analyzer so I would presume it is historical data?! I do not have TickReplay enabled, but I did and again nothing changed.

      Is it possible to even to set an exact enter/ exit times? I only have one criteria so if it is met it should simply enter right? To exit the day, at 3PM so I stay away from the close, I simply have

      if ((Position.Quantity == 1)
      && (Times[0][0].TimeOfDay == new TimeSpan(15, 0, 0)))

      I am by no means an expert but I would think that would be simple enough for the program to see if I am in a position, then to exit it regardless at 3PM.
      * If I set a specific time as a condition it wont even open up a trade like shown above unless I set the time as an "input or variable" and it only enters and exits at 4PM.
      If you want to see the rest of the program to help diagnose let me know.
      Please let me know your thoughts!
      Thanks

      Comment


        #4
        Hello ejasper,

        If this is a day chart in the strategy analyzer without TickReplay or 1-tick intra-bar granularity, Calculate will be OnBarClose and orders will be submitted when the bar closes.

        Time[0] (or Times[0][0]) will represent the close time of the bar, which on a day bar of the end of the session, so time filters would not work with this.
        Further, without 1-tick granularity, the end of day information would be used to fill orders.

        You could add another series that is a 60 minute series if you want actions to occur each hour. Times[1][0] would represent the 60 minute bar close time and you could use this for your time conditions.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by LiamTwine, Today, 08:10 AM
        0 responses
        0 views
        0 likes
        Last Post LiamTwine  
        Started by Balage0922, Today, 07:38 AM
        0 responses
        5 views
        0 likes
        Last Post Balage0922  
        Started by JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        19 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        6 views
        0 likes
        Last Post Creamers  
        Working...
        X