Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Constructing a volume-based spread

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

    Constructing a volume-based spread

    I'd like to use volume data (volume = 1) for one instrument and get the price for that instrument and the concurrent price for a second instrument at the SAME TIME STAMP that the primary 1-volume bar occurred in order to construct a volume-based spread.

    My question is how do I extract the price of the secondary instrument at the time stamp of the primary instrument? See below for more details.

    In other words, I need the following:
    1) A primary instrument 1 contract volume bar (i.e., volume = 1)
    2) The price for a second instrument at the most recent time stamp for the primary instrument 1 volume bar.

    Example:
    primary instrument = ES, volume = 1
    secondary instrument = NQ
    //Note: when volume = 1, we just have a Close price, there is no OHLC bar

    bar[1]: ES (primary) 1 volume bar price = 1681.50, time = 10:00:55, NQ (secondary) price @ 10:00:55 = 3722.25, spread = 2040.75
    //Question: How do I get the NQ price at 10:00:55?

    bar[2]: ES (primary) 1 volume bar price = 1681.75, time = 10:01:01, NQ (secondary) price @ 10:01:01 = 3722.00, spread = 2040.25
    Last edited by bluelou; 09-14-2013, 12:08 PM.

    #2
    You need to add a 1-tick series of the second instrument and collect the value for each incoming tick, and then store it in a variable. Then retrieve that value when OnBarUpdate() calls the primary bars (BarsInProgress == 0) and calculate the spread.

    Comment


      #3
      Thx, Harry. I was wondering if there was another way. That'll do..

      Comment


        #4
        Hello bluelou,

        Thank you for your post.

        Adding the secondary bar series to the script with a 1 tick period as Harry suggested should work for this example. You would however only need to call Closes[1][0] to pull the last close of the 1 tick bar series.

        For information on Closes please visit the following link: http://www.ninjatrader.com/support/h...nt7/closes.htm

        For information on using multiple instruments and time frames please visit the following link: http://www.ninjatrader.com/support/h...nstruments.htm

        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by swestendorf, Today, 11:14 AM
        2 responses
        5 views
        0 likes
        Last Post NinjaTrader_Kimberly  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        4 responses
        13 views
        0 likes
        Last Post xiinteractive  
        Started by Mupulen, Today, 11:26 AM
        0 responses
        2 views
        0 likes
        Last Post Mupulen
        by Mupulen
         
        Started by Sparkyboy, Today, 10:57 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by TheMarlin801, 10-13-2020, 01:40 AM
        21 responses
        3,917 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Working...
        X