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

Bid / Ask historical

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

    Bid / Ask historical

    Hello,

    I'm trying to run a backtest - working with historical data - with my indicator. However, something is wrong.

    My real-time data logic - OnMarketData:

    if (e.MarketDataType == MarketDataType.Last)
    lastVolume = e.Volume;
    lastPrice = e.Price;
    else if (e.MarketDataType == MarketDataType.Ask)
    priceAsk = e.Price;
    else if (e.MarketDataType == MarketDataType.Bid)
    priceBid = e.Price;
    //My method
    myMethod(lastPrice, lastVolume);



    I've moved that logic to OnBarUpdate, now it's looks like this:

    protected override void Initialize()
    {

    Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Last);
    Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Ask);
    Add(Instrument.FullName, PeriodType.Tick, 1, MarketDataType.Bid);
    CalculateOnBarClose = true;

    }
    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    {
    lastVolume = Volume[0];
    lastPrice = Close[0];
    myMethod(lastPrice, lastVolume);
    }
    if (BarsInProgress == 2)
    {
    priceAsk = Close[0];
    }
    if (BarsInProgress == 3)
    {
    priceBid = Close[0];
    }
    }


    I would really appreciate any help you can give me.

    Cheers,

    Ronald.

    #2
    Hi Ronald, would you mind clarifying what is not working according to your expectations? The method you've designed is only called in BIP0 so for Last data per your code.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Yes, that's correct. I need to be sure that my indicator works properly on historical and realtime data. That's the reason why I moved my logic to OnBarUpdate. However, the indicador is not displaying the right bid-ask information.

      My question is: How can I get Bid/Ask Intrabar values for historical purposes? I just need to simulate the OMD logic for backtest.

      Cheers,

      Comment


        #4
        I've read this online, is this accurate?

        The reason being that historical bid and ask data are stored in separate data structures with only 1 second time stamp resolution. This make it impossible to reconstruct historical bid, ask and last data in the same sequence as it occurred real time.
        Last edited by ronald.garcia; 02-01-2013, 03:14 PM.

        Comment


          #5
          Ronald, that's correct the timestamp resolution is down to 1 second. For our next major update we're looking to enhance this by allowing down the .NET .Ticks resolution (1 tick == 100 nanoseconds)

          Also, the 3 streams you work with are individually updating per series and are not inherently synched as the pure OnMarketDate() Level1 stream.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Thank you for your help.

            I'm looking forward to the next version.

            Ronald.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Davidtowleii, Today, 12:15 AM
            0 responses
            3 views
            0 likes
            Last Post Davidtowleii  
            Started by guillembm, Yesterday, 11:25 AM
            2 responses
            9 views
            0 likes
            Last Post guillembm  
            Started by junkone, 04-21-2024, 07:17 AM
            9 responses
            68 views
            0 likes
            Last Post jeronymite  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            4 responses
            20 views
            0 likes
            Last Post trilliantrader  
            Started by mgco4you, Yesterday, 09:46 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X