Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Timed to the second

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

    Timed to the second

    Good morning All,

    I'm trying to get NT to submit an order at 9:29:50 AM, but I'm not getting anywhere. I don't have a problem doing it at 9:29 or 9:30 because on 1 minute bars, the bar time stamp is to the minute, not the seconds.

    Below is a sample of what I'm trying to do, but it is not working. Any help is greatly appreciated.

    CalculateOnBarClose = false;

    If (Position.MarketPosition == MarketPosition.Flat
    && DateTime.Now.Ticks == 092950
    {
    Do This
    }


    #2
    GeoOrtiz,
    Thanks for your post. You are really close to what you are looking for. Instead of DateTime.Now.Ticks, use ToTime(DateTime.Now)
    So it should look like this.
    Code:
    If (Position.MarketPosition == MarketPosition.Flat && ToTime(DateTime.Now) == 092950)
    Bobby Y.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your response Bobby. I tried your suggestion, but unfortunately, it didn't work. I'm running my test on the Market Replay connection. Would that be the problem? The script says "DateTime.Now", so I'm wondering if it is reading the current system time or the Market Replay time.

      Comment


        #4
        UPDATE: I changed the script to trade with the current time (to execute at 21:14:50) and it worked!!! Thank you Bobby!

        P.S. In the spirit of full disclosure, the script that I just tested had the following modification:

        if (&& Position.MarketPosition == MarketPosition.Flat
        && ToTime(DateTime.Now) >= 211450
        && ToTime(DateTime.Now) <= 211458)

        I did this thinking that if on that one second, there was no tick, the order wouldn't be placed. So I gave it 8 seconds to place the order and it worked well.
        Last edited by GeoOrtiz; 01-05-2016, 08:27 PM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X