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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        144 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        71 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        125 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        79 views
        0 likes
        Last Post PaulMohn  
        Working...
        X