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

MarketDataType.Ask and the message sent

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

    MarketDataType.Ask and the message sent

    I am running the following IF statements, I have checked the via the print menu, they are both executing there commands.

    when the bid or ask side is updated, is a string of all levels sent, this would account for why I get 2 firing, can i just include update or do i need another method to say only when changed do i want to execute the statement

    if (e.MarketDataType == MarketDataType.Ask && e.Position == 0)
    {

    }
    if (e.MarketDataType == MarketDataType.Bid && e.Position == 0)
    {

    }

    #2
    if (e.MarketDataType == MarketDataType.Ask && e.Position == 0 && e.Operation == Operation.Update);

    This statement prints levels above 0, as I understand it && means
    and also, so how can it be printing other levels in output menu?

    Comment


      #3
      tinkerz, have you seen the reference sample titled Creating your own Level II data book? It goes over the details of creating/maintaining a LII book.

      Now I'm not exactly what you're trying to accomplish, but maybe you could just the OnMarketData() method? That just returns the best bid, best ask, and the last price.

      This code has much more "fluff" than necessary to display the basics, but it should help you out. Let us know if you have any other questions.
      Code:
      protected override void OnMarketData(MarketDataEventArgs e)
      {
          if (e.MarketDataType == MarketDataType.Last)
          {        
              Print("last\t" + e.Price.ToString() + "\t" + e.Volume.ToString());
          }
          else if (e.MarketDataType == MarketDataType.Bid)
          {
              double bidprice = e.Price;
              int bidvol = e.Volume;
              string datastring = "bid\t" + bidprice + "\t" + bidvol;
              Print(datastring);
          }
          else if (e.MarketDataType == MarketDataType.Ask)
          {
              double askprice = e.Price;
              int askvol = e.Volume;
              string datastring = "ask\t" + askprice + "\t" + askvol;
              Print(datastring);
          }
      }
      AustinNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by SantoshXX, Today, 03:09 AM
      0 responses
      11 views
      0 likes
      Last Post SantoshXX  
      Started by DanielTynera, Today, 01:14 AM
      0 responses
      2 views
      0 likes
      Last Post DanielTynera  
      Started by yertle, 04-18-2024, 08:38 AM
      9 responses
      41 views
      0 likes
      Last Post yertle
      by yertle
       
      Started by techgetgame, Yesterday, 11:42 PM
      0 responses
      12 views
      0 likes
      Last Post techgetgame  
      Started by sephichapdson, Yesterday, 11:36 PM
      0 responses
      2 views
      0 likes
      Last Post sephichapdson  
      Working...
      X