Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

why count not count correctly

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

    why count not count correctly

    hi why is slow count , with this code
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class Aziocane : Indicator
    {
    MemoryMappedFile file;
    private int nData = 0;
    private double bidPrice;
    private double askPrice;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "Aziocane";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    }
    else if (State == State.Configure)
    {

    file = MemoryMappedFile.CreateOrOpen("Test", 1000, MemoryMappedFileAccess.ReadWrite);

    }
    else if (State == State.Terminated)
    {
    file.Dispose();
    }
    }


    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.


    }

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    nData++;


    try
    {

    Print(nData++.ToString());

    }
    catch
    {
    Print("Data file busy...");
    }

    }
    }
    }


    when i print a variable nData jump some number ?? o_O i think is slow increase variable and change Tostring , is possible resolve this bug ??


    #2
    Hello faustf,

    OnMarketData is for every market data update.

    This means anytime there is a change in ask, change in bid, or change in last this will update.

    You are incrementing on every update. There could several updates before a tick is ever produced.

    Are you seeing that the Time & Sales window is not showing these updates?

    Below is a link to an example that prints the rest of the information seen in the Time & Sales window to help you understand you are seeing?


    You have mentioned a bug?
    What is the bug you are experiencing?
    Are you getting error messages or crashing behavior?
    Is OnMarketData not updating for every market data information of the ask bid and last?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      suppose
      you are inside of
      protected override void OnMarketData(MarketDataEventArgs e)
      {
      nData++;


      try
      {

      Print(nData++.ToString());

      }
      catch
      {
      Print("Data file busy...");
      }

      you are nData , arrive a new price for ask (suppose) , nData++ increase of one and print it , after 1 milliseconds arrive buy nData++ increase of one and print it , but why if nData is equal to 10 after buy increase ,is 13 ??? it should be 11 look the foto nData jump number why ???








      Comment


        #4
        Hello faustf,

        This does not add the volume together.

        This just counts the number of times OnMarketData has updated.

        If it jumps from 10 to 13 that would be because 3 market updates happened in a row.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          and than how is possible give a serial stamp at volume ?, if market update 3 in a row , probably also volume jump 3 and i lose some value ?

          Comment


            #6
            Hello faustf,

            I'm not certain what you are asking.

            If you want the market data update volume this would be the marketDataUpdate.Volume property of the arguments.

            Below are links to the help guide.
            https://ninjatrader.com/support/help...marketdata.htm
            https://ninjatrader.com/support/help...aeventargs.htm


            I would not expect for the marketDataUpdate.Volume of a market update to not have a value if 3 updates occur in a row.. Updates will happening continuously, and rapidly as real-time market data is received. Every market update will have volume (for futures and equities).
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            673 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            379 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            111 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            577 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            582 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X