Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to use TimeLastTick in a custom indicator ?

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

    How to use TimeLastTick in a custom indicator ?

    Trying to use TimeLastTick begets compiling errors.
    myTickTime = TimeLastTick(); results in "CS103"
    and
    myTickTime = DateTime.TimeLastTick(); results in "CS117"

    #2
    What is TimeLastTick? Your own method/function? It is not a supported NinjaScript method/property and I don't believe its a method/property of the DateTime structure either.
    RayNinjaTrader Customer Service

    Comment


      #3
      I found TimeLastTick as a column available with Market Analyzer and I wish I could use it as a method. Do you mean that it is not a NT supported one ?
      By the way what about these promising announcements made formerly such as :

      08-13-2007, 12:17 PM
      NinjaTrader_Dierk
      ________________________________________
      Dealing with nanoseconds does not make difference: Time[0] still will be the timestamp of the actual and not the time as a tick came in (like in T&S window). You need to write to the market data stream, which is not officially supported in NT6, but will be in NT 6.5, fall time frame. Please take a look at e.g. VolumeProfile indicator, OnMarketData method if you want to get into that based on NT6.

      09-06-2007, 08:06 PM
      NinjaTrader_Ray
      ________________________________________
      NT 6.5 will allow you to access T&S data which you can store yourself.

      Basically, my aim is to be able to access T&S data and I hope it is going to be available soon as indicators.

      Comment


        #4
        grd974,

        I am confused as to what you are trying to accomplish? Couldn't you just run your indicator with CalculateOnBarClose = false and then on OnBarUpdate() just do DateTime.Now? In real-time the bars are updated as soon as a tick comes in and the time of that tick would be DateTime.Now.

        Alternatively, you could use the new OnMarketData() method.
        Code:
        protected override void OnMarketData(MarketDataEventArgs e)
        {
            if (e.MarketDataType ==  MarketDataType.Last)
                 Print(e.Time);
        }
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Hi Josh,

          Would you mind providing us with some code in the line of the SampleMarketDepth.zip file you once uploaded on this forum but this time focused on OnMarketData() method ?

          Comment


            #6
            We will be posting a reference sample in the neat future. For now, if you look int the 6.5 Help Guide (press F1 when NT is running) look for OnMarketData() section (search for it it) and you will see some reference code there.
            RayNinjaTrader Customer Service

            Comment


              #7
              Using OnMarketData()

              I can't figure out why this code works :
              private void OnMarketData(object sender, MarketDataEventArgs e)
              {
              if (e.MarketDataType == MarketDataType.Last)
              Print(e.Time + " " + e.Price + " Ask");
              }

              and that one does not :
              private void OnMarketData(object sender, MarketDataEventArgs e)
              {
              if (e.MarketDataType == MarketDataType.Last && e.MarketDataType == MarketDataType.Ask)
              Print(e.Time + " " + e.Price + " Ask");
              }

              Comment


                #8
                Since

                MarketDataType.Last != MarketDataType.Ask

                You will never get an event when e.MarketDataType == both the above.

                .Last = Last traded price
                .Ask = Ask price
                RayNinjaTrader Customer Service

                Comment


                  #9
                  If you wanted to check to see if the last price and the latest ask price are the same you will want to store the values into variables and then run the comparison with the variables. I believe the method gets updated by either the bid/ask data first then the last data. So you want to store the ask price to a variable and when the OnMarketData() comes around again to update the last price run a check against the stored ask price. Don't quote me on that order of execution, but you can check it really simply by placing simple print functions. Do something like
                  Code:
                  if (e.MarketDataType == MarketDataType.Last)
                       Print(e.Time + " " + e.Price + " Last");
                  else if (e.MarketDataType == MarketDataType.Ask)
                       Print(e.Time + " " + e.Price + " Ask");
                  else if (e.MarketDataType == MarketDataType.Bid)
                       Print(e.Time + " " + e.Price + " Bid");
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    MarketData update order

                    Josh

                    Re update order, please see screenshot and tell me if time&sales is printing the last 2 trades at 9:59:01 correctly as between the bid and ask.

                    Per the output using your code, the Ask is 12948 at 9:59:01 and the Bid is 12947 then drops to 12946.

                    The second most recent Last trade is at 12948 which hits the Ask however is printed as a "between" trade.

                    The Ask then changes to 12949, which would indicate Last is reported before the Ask is reported as changed?

                    The Bid then changes to 12948 and the most recent Last trade is 12948 and still "between" even though the next print is the Ask at 12948. How can the Last trade still be "between"?

                    Thanks.
                    Attached Files

                    Comment


                      #11
                      Thanks for reporting. I will play with this in more depth.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by DawnTreader, 05-08-2024, 05:58 PM
                      7 responses
                      25 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by sgordet, Today, 05:24 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post sgordet
                      by sgordet
                       
                      Started by royhagerman, Today, 04:30 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post royhagerman  
                      Started by haas88, 03-21-2024, 02:22 AM
                      18 responses
                      208 views
                      0 likes
                      Last Post haas88
                      by haas88
                       
                      Started by Board game geek, Today, 02:20 AM
                      0 responses
                      7 views
                      0 likes
                      Last Post Board game geek  
                      Working...
                      X