• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Script Misses Entry at 8:30 Open

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

    Script Misses Entry at 8:30 Open

    I have an automated strategy based off of the ChandelierSAR for short trades, that automatically enters a short trade at 8:30AM (when the market opens) if the indicator is higher than the current market position as shown below.



    It seemed to work fine on a 233-tick chart but does not enter on the 377-tick chart shown below.



    You can see from the chart that it worked fine later on. It isn't because there are no 8:30AM tick bars either, there are three of them.

    8:27
    8:29
    8:30
    8:30
    8:30
    8:31
    8:31
    8:32

    What is the deal? It works on one chart and not another? I am stumped.

    The Strat and Indicator are attached.
    Attached Files

    #2
    Hello RDpos,

    Thank you for your post.

    ToTime() returns an integer representing time including seconds. A bar would have to end at 8:30:00 for your condition to be true. This happens all the time on minute bars but not so often on ticks bars.

    Add this statement and view the output window:
    Code:
    Print (ToTime(Time[0]));
    You can then see how the bar stamps are represented as an integer.

    Try this to capture the whole minute:
    Code:
     
    if (ToTime(Time[0]) >= ToTime(8, 30, 0) && ToTime(Time[0]) <= ToTime(8, 30, 59 ))
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan, I did an analog in the strategy wizard by changing to

      ToTime(Time[0]) > ToTime(8,29,0)
      ToTime(Time[0]) < ToTime(8,31,0)
      DefaultInput[0] < Chandelier....

      The only problem now would be an inactive market where no 377-tick bar is completed between 08:30:00 and 08:30:59. Is there a way to account for that intrabar? That problem would be much more prominent at 610-tick or higher tick charts.

      Comment


        #4
        Yes, that should work when creating it with the condition builder.

        You can use:
        Code:
        if (Bars.BarsSinceSession == 0)
        This should be the first bar of the day regardless of the timestamp.

        Session times are defined in the Chart Properties.

        http://www.ninjatrader-support.com/H...ceSession.html
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bkinvent, Today, 09:45 PM
        0 responses
        6 views
        0 likes
        Last Post bkinvent  
        Started by linuxguru, Today, 06:02 PM
        0 responses
        9 views
        0 likes
        Last Post linuxguru  
        Started by kokobeef, Today, 06:00 PM
        0 responses
        7 views
        0 likes
        Last Post kokobeef  
        Started by Bionian, Today, 03:07 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by JakeOfSpades, Today, 03:05 PM
        2 responses
        14 views
        0 likes
        Last Post JakeOfSpades  
        Working...
        X