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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        28 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        284 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        281 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        132 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        90 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X