Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Incorrect Market data

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

    Incorrect Market data

    I have something strange on my strategy. Last week I was working with Euronext stocks and everything was fine. Now I work with US stocks and with the same strategy I have this trouble.

    I Open a 5 minute chart and I set the strategy. On Initialize() I add a new time frame for the main symbol and I get data from another symbol:

    Add(PeriodType.Second,5);
    Add("$EURUSD", PeriodType.Minute, 60);


    After Initialize() I retrieve market data:

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if (e.MarketDataType == MarketDataType.Ask)
    Ask = e.Price;

    if (e.MarketDataType == MarketDataType.Bid)
    Bid = e.Price;
    }


    When doing this if I Print(Bid); I get the data from the EURUSD instead of the main instrument.

    Even if I set this code I still get wrong data (in this case the value of Print(Bid); is always zero):

    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if (BarsInProgress == 1)
    {
    if (e.MarketDataType == MarketDataType.Ask)
    Ask = e.Price;

    if (e.MarketDataType == MarketDataType.Bid)
    Bid = e.Price;
    }
    }


    What I'm doing wrong?

    #2
    guillembm,

    Who is your data provider?

    The use of BarsInProgress is necessary in order to be sure you are getting data for the correct instrument in multi-instrument strategies.

    Please let me know if I may assist further.
    Last edited by NinjaTrader_AdamP; 11-21-2011, 10:29 AM.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Kinetick

      The point is that when I Print(Bid); from onbarupdate with this code I get mixed data from all instruments on the strategy. To Print I set

      if (BarsInProgress == 1)
      {
      Print(Bid);
      }

      It should print only data from the main instrument in 5 second frame.

      I restarted NT and it's the same

      Comment


        #4
        I don't think you are getting bid/ask data

        Debug everything in your onmarketdata.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        65 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        41 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        23 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        26 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        52 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X