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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        133 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        75 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        117 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        113 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        90 views
        0 likes
        Last Post CarlTrading  
        Working...
        X