Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can I build a Strategy that uses Bid prices on a futures contract from the prior day?

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

    Can I build a Strategy that uses Bid prices on a futures contract from the prior day?

    I am using NinjaTrader 8 demo version which is not connected to a brokerage account but is connected to IQFeed with live NYMEX futures data.

    I want to build a strategy (or more likely pay someone to build a strategy) that will run on a chart and use historical bid price data on a futures contract from a certain time in the past to make a trading decision at a later time. So for example, I want the strategy to make a trade decision at 8 AM each morning based on the bid price from 5 PM the prior day. The issue here is I don't want the price from a trade that occurred at 5 PM, I want the bid price that was available at 5 PM the prior day even if there was no trade executed at that time. The strategy will trade in a SIM account of course since I'm not connected to a brokerage account.

    Does anyone know if that is feasible? The contract I am looking at now is CL 05-21. This Crude Oil futures contract expiring May 2021 doesn't trade too frequently, but when I view it on the Dynamic SuperDOM I see a nearly constant flow of numbers flashing up in the Buy and Sell column at different price points which I assume are bids and offers at those price points, with the numbers being the number of contracts bid or offered. I only have Level I data so I can't see the whole stack of bids and offers, just the best on each side I guess.

    Any help appreciated.

    #2
    Hello Johnax,

    Thank you for your post.

    Yes, this would be feasible if you added a 1 tick bid series to a script and used GetBar() and GetBid() to find the bar index of the prior day's 5 pm bar using GetBar and then use that bar index with GetBid() to get the bid price for that bar:





    Please let me know if you would like a list of professional NinjaScript Consultants or Educators who would be happy to create or modify any script at your request or assist you in learning NinjaScript.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thank you Kate. One follow-up question. Is the ability to retrieve this information dependent on my data service? I am using IQFeed, so can you confirm the GetBid() and GetBar() commands will work in the way you describe with this data service?

      I am familiar with the list of professional script consultants on the NinjaTrader website so I am all set there.

      Comment


        #4
        Hello Johnax,

        Thank you for your reply.

        IQFeed does supply historical bid/ask stamped tick data, so you should be fine there. For a list of what data each provider can supply, you can check out this link:



        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hi Kate,

          I just want to confirm one thing you wrote. In the first post on my question you said "this would be feasible if you added a 1 tick bid series to a script and used GetBar() and GetBid() to find the bar index of the prior day's 5 pm bar using GetBar and then use that bar index with GetBid() to get the bid price for that bar".

          The 1 tick bid series would be added by the strategy script, is that correct? Or would I need to add the 1 tick bid series to the chart manually before I initiate the strategy script?

          Thank you,

          John.

          Comment


            #6
            Hello Johnax,

            Thanks for your reply.

            Actually you could just use a bid series in the same interval as your primary series on the chart assuming you just care about the opening or closing bid price of that particular bar.

            Here's an example where we just use a 1 minute data series as our primary series, then add a 1 minute bid series as well. We can then just look back to whatever bar we like, in this example I'm just using a bar at the same time, but 1 day ago, and in this example we print both the opening and closing bid price of the bar:

            Code:
                public class ExampleYesterdayBid: Indicator
                {
                    protected override void OnStateChange()
                    {
                        if (State == State.SetDefaults)
                        {
                            Description                                    = @"Enter the description for your new custom Indicator here.";
                            Name                                        = "ExampleYesterdayBid";
                            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)
                        {
                            AddDataSeries(null, Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Bid);
                        }
                    }
            
                    protected override void OnBarUpdate()
                    {
                        if(BarsInProgress !=0)
                            return;
            
                        DateTime YesterdayTime = Time[0].AddDays(-1);
                        int barsAgo = CurrentBars[1] - BarsArray[1].GetBar(YesterdayTime);
            
                        if (CurrentBars[1] < barsAgo)
                            return;
            
                        Print(Times[1][barsAgo] + " " + Closes[1][barsAgo]);
                    }
                }
            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            942 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            4 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            33 views
            0 likes
            Last Post wzgy0920  
            Working...
            X