Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DateTime Time element

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

    DateTime Time element

    Hi,

    If I print DateTime.Now, I get:

    12/25/2011 3:13:10 PM

    Is there a way to take just the time element and print:

    3:13:10 PM

    Also, can I change the font color? It would be of great help.

    Thanks,
    DS

    #2
    Hello,

    You'd want to convert the DateTime object to a string and then specify the format you print:

    Code:
    Print(DateTime.Now.ToString("h:mm:ss tt"));
    Please see the MSDN section on the DateTime.Now property for more information:

    Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.


    The output window a simple TextBox control window which does not support custom text formatting.
    Last edited by NinjaTrader_Matthew; 12-25-2011, 03:02 PM.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi Matthew,

      Thanks for your reply, especially today.

      I'm basically trying to make my own, customized T&S window. If the output window won't do this, have any advice on what to use?

      Oh, and while I know how to grab Bids and Asks, is there anyway to tell if the last trade that went through was a Buy, Sell, or Stop?

      Thanks again,
      DS

      Comment


        #4
        DS,

        You can always output this information to a chart which will give you more control over how the information is displayed. There are also so more advanced C# programming concepts you can use to create your own window, however there are no supported NinjaScript methods to do so.

        I would suggest taking a look at the 'CustomPlotSample' listed under Tools--> Edit NinjaScript--> Indicator to get an idea of how you could create your own custom plot to display this custom T&S information.

        Oh, and while I know how to grab Bids and Asks, is there anyway to tell if the last trade that went through was a Buy, Sell, or Stop?

        Unfortunately this level of information is not exposed to NinjaTrader.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Originally posted by dsraider View Post
          Hi Matthew,

          Thanks for your reply, especially today.

          I'm basically trying to make my own, customized T&S window. If the output window won't do this, have any advice on what to use?

          Oh, and while I know how to grab Bids and Asks, is there anyway to tell if the last trade that went through was a Buy, Sell, or Stop?

          Thanks again,
          DS
          Are you by any chance reinventing the wheel ?

          ref: http://www.ninjatrader.com/support/f...ead.php?t=3478

          Comment


            #6
            koganam,

            Story of my life

            I've been basing my code on what you sent already but don't want to print out the entire Level II Book. Instead, I'm looking to make my own T&S window but wasn't aware that we didn't have access to market info like Long, Short, Stop, etc. Still, I'd like to add my own columns so I guess I have no choice but to continue.

            That said, I've run into an issue. For example:

            PHP Code:
            if(e.MarketDataType == MarketDataType.Last)
                        {
                            if(e.Price <= GetCurrentAsk())
                            Print(Time, Price, Vol, etc) 
            
            prints out every trade made and "if(e.Price < GetCurrentAsk()) prints out some bids and some asks. Do I have my logic wrong?

            Comment


              #7
              In your sample code, the only trades that shouldn't print are those above the current ask.

              Comment


                #8
                Hey VTrader,

                I agree but here's an example of what happens. This is with the "<=" logic. As you can see, my output window prints all trades.

                I'm sure it's probably something small but it's driving me crazy...

                EDIT: I'm probably confusing things. To start somewhat fresh, if I want to print out all trades that happen at the ask or higher (green and gold in the T&S window), what logic should I use?

                if(e.Price >= GetCurrentAsk())
                Print(e.Price.ToString() + e.Volume.ToString())

                prints out some of what the T&S shows in green and some of what it shows in blue. Does anyone know the actual code used by the T&S window?
                Attached Files
                Last edited by dsraider; 12-26-2011, 11:00 AM.

                Comment


                  #9
                  Anyone? Bueller? Code to match what T&S does?

                  Comment


                    #10
                    Originally posted by dsraider View Post
                    Anyone? Bueller? Code to match what T&S does?
                    I guess what you are asking for then is:

                    if(e.MarketDataType == MarketDataType.Ask)

                    Comment


                      #11
                      For some odd reason, that resulted in no prints at all when I first tried it but since I've changed a few other things since then, I'll give it another whirl. Thanks, koganam.

                      DS

                      Comment


                        #12
                        So, with this code:

                        PHP Code:
                        if(e.MarketDataType == MarketDataType.Last)
                                    {
                                        if(e.Price >= GetCurrentAsk())
                                        
                                        Print(time, price, volume); 
                        
                        I get what you see in the pics. It's either missing some trades or printing some bids. Any idea as to why?

                        Thanks,
                        DS

                        P.S. koganam, thanks for your code but I'm afraid that was just printing out the current asks. I'm looking to print out trades that actually took place at ask or above, like the T&S window shows.
                        Attached Files
                        Last edited by dsraider; 01-08-2012, 04:50 PM.

                        Comment


                          #13
                          Originally posted by dsraider View Post
                          So, with this code:

                          PHP Code:
                          if(e.MarketDataType == MarketDataType.Last)
                                      {
                                          if(e.Price >= GetCurrentAsk())
                                          
                                          Print(time, price, volume); 
                          
                          I get what you see in the pics. It's either missing some trades or printing some bids. Any idea as to why?

                          Thanks,
                          DS

                          P.S. koganam, thanks for your code but I'm afraid that was just printing out the current asks. I'm looking to print out trades that actually took place at bid or above, like the T&S window shows.
                          If you want to know the price at which the trade took place, you should be printing the Last price. Basically, you use the Ask price as the filter, and print the actual price at which the trade took place.

                          Comment


                            #14
                            Forgive me but I thought I had. Trying everything of which I can think...

                            PHP Code:
                            if(e.MarketDataType == MarketDataType.Last && MarketDataType.Last >= MarketDataType.Ask)
                            
                            Print(e.Price.ToString); 
                            
                            prints every trade made while...

                            PHP Code:
                            if(e.MarketDataType == MarketDataType.Last && e.Price >= GetCurrentAsk())
                            
                            Print(e.Price.ToString); 
                            
                            prints out some of each. I'm sure I just have something switched around. Do you see it?

                            Comment


                              #15
                              Originally posted by dsraider View Post
                              ... some of each.
                              Each of what? Maybe you have not yet clearly defined what you want to see? "The same as the T&S" is not an objective description: it is merely a comparison of existing data structures.

                              What are you expecting? e.g., based on the Ask price, I want to see all trades that printed at or above the Ask etc.,

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              574 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              332 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
                              553 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              551 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X