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

Cumulating Bid Volume and Ask Volume

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

    Cumulating Bid Volume and Ask Volume

    Hi

    I have to code an indicator for a client that wants to have accumulated Bid and Ask Volume at specific time during the day.

    I get weird result.

    Here is how I get my bid and ask data and cumulate them :

    Code:
    protected override void OnMarketData(MarketDataEventArgs e)    
            {
                if(e.MarketDataType == MarketDataType.Ask)
                        accumulatedAsk += e.Volume;
                else    
                if(e.MarketDataType == MarketDataType.Bid)
                        accumulatedBid += e.Volume;    
            }
    Is there something wrong ?

    the data I get is way too high !

    Thanks

    #2
    Hi blar,

    Do you need to know how much the market volume has increased since a date? e.Volume is current volume, not the difference I believe so += e.Volume will just add current volume repeatedly. The best way would be to capture e.Volume at the the time you would like to start comparison by copying it to a new variable. Then later, you can see how much it moved by comparing it to the current e.Volume
    Last edited by Dexter; 02-22-2011, 12:02 PM. Reason: typo

    Comment


      #3
      Hi blar58,

      Biggest challenge here is identifying what you're looking for conceptually. Bid / ask volume can change without seeing orders filled, and the volume you're checking changes with each change in price level. Unfortunately we can't advise a specific implementation, but can refer to this sample for help working with market depth and seeing the bigger picture of bid / ask volume at different price levels.
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by blar58 View Post
        Hi

        I have to code an indicator for a client that wants to have accumulated Bid and Ask Volume at specific time during the day.

        I get weird result.

        Here is how I get my bid and ask data and cumulate them :

        Code:
        protected override void OnMarketData(MarketDataEventArgs e)    
                {
                    if(e.MarketDataType == MarketDataType.Ask)
                            accumulatedAsk += e.Volume;
                    else    
                    if(e.MarketDataType == MarketDataType.Bid)
                            accumulatedBid += e.Volume;    
                }
        Is there something wrong ?

        the data I get is way too high !

        Thanks

        blar58,

        What you are doing here is measuring the supply @ask and supply @bid every time there is a change to these supply levels your add supply totals together.

        I f you are looking at measuring traded volume that occurs @ask and @bid, you need to do something like this.

        --------------------------------------------------------------------------------------------------------------------------
        protected override void OnMarketData(MarketDataEventArgs e)
        {

        if(Bars.Count != activeBar)

        {
        CurrentAskVolumeTotal = 0;
        CurrentBidVolumeTotal = 0;
        activeBar = Bars.Count;
        }


        if (e.MarketDataType == MarketDataType.Ask)AskPrice = e.Price;

        if (e.MarketDataType == MarketDataType.Bid)BidPrice = e.Price;

        if (e.MarketDataType == MarketDataType.Last)LastPrice = e.Price;

        if (e.MarketDataType == MarketDataType.Last)LastVolume = e.Volume;

        if (e.MarketDataType != MarketDataType.Last)return;


        if((LastPrice >= AskPrice) && (AskPrice!=0)) CurrentAskVolumeTotal += LastVolume;
        else if((LastPrice <= BidPrice) && (BidPrice!=0)) CurrentBidVolumeTotal += LastVolume;


        VolumeDown.Set(CurrentBidVolumeTotal);

        VolumeUp.Set(CurrentAskVolumeTotal);

        }

        ----------------------------------------------------------------------------------------------------------------------------

        RJay
        Last edited by RJay; 02-22-2011, 12:53 PM.
        RJay
        NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

        Comment


          #5
          Ok guys

          Thank you. I found a way to get what I WANTED...


          blar

          Comment


            #6
            Oh thanks RT

            I didn't saw your post but this is exactly what I did


            Thanks


            blar

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alifarahani, Today, 09:40 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by RookieTrader, Today, 09:37 AM
            4 responses
            17 views
            0 likes
            Last Post RookieTrader  
            Started by PaulMohn, Today, 12:36 PM
            0 responses
            5 views
            0 likes
            Last Post PaulMohn  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            40 views
            0 likes
            Last Post love2code2trade  
            Started by junkone, Today, 11:37 AM
            3 responses
            25 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X