Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accurate time and sales export

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

    Accurate time and sales export

    I am trying to print out the (time and sales) to a text file

    My current code works which is:



    protected override void OnBarUpdate()
    {

    // print A format (T&S)
    // 2021 12 28 7 53 18 0.000000 0.000000 4796.500000 86054 ^
    sw.WriteLine(Times[1][0].Year + " " + Times[1][0].Month + " " + Times[1][0].Day + " " + Times[1][0].Hour + " " + Times[1][0].Minute + " " + Times[1][0].Second + " " + GetCurrentBid() + " " + GetCurrentAsk() + " " + Close[0] + " " + g_volume + " " + Tiki ); // Append a new line to the file

    ...

    }



    But I noticed that bids and ask prices are not aligning properly to ninja time and sales window bids and asks for the last tick.

    What method I can call to get the (bid ask last) and volume data from the current tick?














    #2
    Hello marluv,

    Thanks for your note.

    You could use OnMarketData() to get the most recent Bid, Ask, Last price information as well as Volume.

    See this help guide page for more information about OnMarketData() and sample code demonstrating how to get the Bid, Ask, Last, and Volume in OnMarketData().

    OnMarketData(): https://ninjatrader.com/support/help...marketdata.htm

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Yes that fixed it lol

      easy!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      633 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      567 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X