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

toTime() system clock or market clock?

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

    toTime() system clock or market clock?

    Hi,

    Curious on toTIME() does it pick up the market or local CPU time?

    Thanks,

    Blue

    #2
    Hello,

    Really neither. ToTime() converts some .NET time to an integer that is easier to understand:


    Time[0] is what you are probably converting, so that would be the time stamp of the referenced bar. In the case of Time[0], it is the current bar "0" time stamp. The time stamps match your PC clock settings:
    DenNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ben View Post
      Hello,
      ... The time stamps match your PC clock settings ...
      Doesn't it depend on whether the incoming data has its own timestamp?

      I'm referring to the following found under "How does NinjaTrader build Chart Bars?"

      in the help manual.

      As ticks come into NinjaTrader in real-time, they are time stamped based on your local PC time if they do not already have an associated time stamp that is provided from the real-time data source. The majority of our supported brokerage feeds DO NOT time stamp ticks where most of our supported market data vendor feeds do provide time stamped ticks.

      Comment


        #4
        Trade at specific time

        Hi Ben,

        Let me explain what I am trying to do:

        1. Market reaches certain time (hhmmss) of day (only load strategy on that chart 5 minutes out from time of trade)

        2. Market puts in OCO order for long/short breakout

        3. typical TP's and SL's

        I have configured the wizard for some of it, then went in by hand (been a while since I have done any coding) and went through all the articles on TIME object and still spinning circles as I am not a programmer by trade.

        What I have now is this:

        Code:
        if(DateTime.Now.TimeOfDay.CompareTo(ToTime(8,29,52)) == ToTime(8, 29, 52))
        			{
                        EnterLongStopLimit(Quantity, Close[0] + PriceOffset * TickSize, Close[0] + 2 * TickSize, "L1");
                        EnterShortStopLimit(Quantity, Close[0] + PriceOffset * TickSize, Close[0] + 2 * TickSize, "S1");
                    }
        I would think this would work, however, I would think the 'compareTo' method returns BOOL and I wouldn't have to do the last part. However, I always get lots of errors and would rather spend my time trading. haha



        Blue...

        Comment


          #5
          Hello,

          I suggest using this sample as reference:


          You also may find this breakout specific sampel useful (although I do not think it uses time as a filter):


          You may want to do something like this:

          if(ToTime(Time[
          0]) >= 82952)//if time now is >= to 8:29AM and 52 sec's.
          {
          //do something
          }
          DenNinjaTrader Customer Service

          Comment


            #6
            thank you

            Ben,

            Thanks, that is much simpler and less confusing. I thought I tried that at one time and nothing came through as I did a replay, but I will try it again and see. The Strategy helps a ton, awesome, thanks!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rhyminkevin, Today, 04:58 PM
            4 responses
            52 views
            0 likes
            Last Post dp8282
            by dp8282
             
            Started by iceman2018, Today, 05:07 PM
            0 responses
            5 views
            0 likes
            Last Post iceman2018  
            Started by lightsun47, Today, 03:51 PM
            0 responses
            7 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            14 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            50 views
            0 likes
            Last Post futtrader  
            Working...
            X