Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Variable Sum

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

    Variable Sum

    I have an indicator which grabs all the trades at ask. It looks like this:

    PHP Code:
    protected override void OnMarketData(MarketDataEventArgs e)
    {
    if (e.MarketDataType == MarketDataType.Ask)
                {
                    askPrice = e.Price;
                    return;
                }
    
    long    askVolume    = e.Volume;
    if (price >= askPrice)
    Ask.Set (askVolume);
    } 
    
    I then draw Ask on my chart. It plots each trade correctly but simply plots the latest one. I'd like it to keep a running total per bar but am running into trouble. Any tips? Arrays? For loops? Have tried my hand at each but have come up short.
    Last edited by dsraider; 01-21-2012, 03:26 PM.

    #2
    dsraider,

    This looks like its meant to plot volume. Do you mean its meant to display the total volume at the ask price? What is the "price" variable in this example? Is Ask the data series you are attempting to plot:?

    Please keep in mind OnMarketData() is updated every new tick, so your data series Ask will be quite large.

    I look forward to helping you resolve your issue.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi Adam,

      At second glance, it looks as if I can simply customize the BuySellVolume indicator to suit my needs. One question for clarification, though: does that indicator plot ONLY trades that have actually gone through or is it collecting all Bids and all Asks? I can't do the math that quickly in my head.

      Thanks,
      DS

      Comment


        #4
        dsraider,

        It looks like its getting the bid and ask volume depending. Its adding the volume between the last tick and the current tick, assigning it to buy volume or sell volume depending on if there was a buy or sell during that volume quote.

        Please let me know if I may assist further.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Sounds like what I'm looking for.

          Thanks for your help

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          576 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X