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

BuySellVolume - Indicator review

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

    BuySellVolume - Indicator review

    I just found something strange when I tried to use the BuySellVolume indicator.
    Let me create a simplified table to explain:



    I did not mix Bid & Asks events in the table, so let you suppose that there were only Bids or Asks in the example to make the BuySellVolume sum.
    As you can see, the BuySell indicator is permanently lagging the Volume bar by 1 tick, and the last tick volume (4 on the tick #4 of currentbar #0) is disappearing when the Currentbar is moving to a new bar.
    I never realized that until I was attentively watching "On Market Data" during ETH (slower activity).
    I suppose this could be same with the NT7 indicators using OnMarketData.
    I'm using NT8 and here below the BuySellVolume code for a reminder:

    Code:
    protected override void OnMarketData(MarketDataEventArgs e)
            {            
                if(e.MarketDataType == MarketDataType.Last)
                {                
                    if(e.Price >= e.Ask)
                    {
                        buys += e.Volume;
                    }
                    else if (e.Price <= e.Bid)
                    {
                        sells += e.Volume;
                    }
                }    
            }
            
            protected override void OnBarUpdate()
            {
                if (CurrentBar < activeBar)
                    return;
    
                Sells[0] = sells;
                Buys[0] = buys + sells;
    
                // Reset accumulators on new bar
                if (CurrentBar != activeBar)
                {
                    buys = 0;
                    sells = 0;
                    activeBar = CurrentBar;
                }
            }
    Maybe some folks already posted on this matter, but I did not find any message.
    So there are 2 issues I'm posting here :

    1) Volume (buys+sells) not (historically) corresponding to the Bar Volume:
    I'm suggesting the following code to improve the indicator

    Code:
    Sells[CurrentBar - activeBar] = sells;
    Buys[CurrentBar - activeBar] = buys + sells;
    When CurrentBar & activeBar are equal, it's equivalent to the original code
    When CurrentBar & activeBar are temporarely (before the reset code part at the end) not equal, CurrentBar-activeBar = 1 and still adds the last tick volume to the previous bar [1]. This is possible because of the 1-tick lag in the code operations.

    2) Permanent 1-tick lag when the indicator is displayed in real-time:
    I'm not a C# programmer and I humbly program NT8 as an amateur for building my own sery of indicators.
    I did not find any solution for this 2nd issue, but maybe someone smarter could explain (in familiar language) if it's possible or not to solve this issue.

    Thanks
    Attached Files
    Last edited by alizes; 08-16-2016, 10:44 AM.

    #2
    Hi alizes,

    To confirm, you are seeing this behavior with NinjaTrader 8 and you are not seeing this behavior with NinjaTrader 7, is this correct?

    For future reference, below I am providing a link to the NinjaTrader 8 issues and bug reports section of the forums.


    And a link to the general discussion for NinjaTrader 8 in the forums.


    I was able to reproduce the discrepancy between NinjaTrader 8 and NinjaTrader 7 with the BuySellVolume indicator and I have submitted a bug report to our development.

    Please let me know if you find any other behavior you feel is incorrect with the NT8 platform.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for your answer.

      NT7 is not installed on my machine.
      I found the issue with NT8 and made an assumption that it could also be similar in NT7.

      BuySellVolume (as BuySellPressure) is an "official" indicator in both packages.
      I thought there was no major reason to have 2 different logics between NT7 and NT8.

      Then, I did not post in NT8 Bugs section because I do not think it is;
      just a code to be improved for the missing last tick volume (issue #1).

      For the 1-tick lag issue (#2), I did previously receive a first post from you with an example. Unfortunately, the post disappeared.
      I think to have understood your suggestion.
      It's a possibility that I thought about, but did not know it was possible to update the bar in the OnMarketData section.
      I will try it and will come back if necessary.

      Comment


        #4
        Hi alizes,

        I had actually misunderstood your post and had thought that you were modifying the BuySellVolume indicator.

        Once I realized you were reporting that the NT8 version of the script is misbehaving I gave this a test, reproduced, tested with NT7 (could not reproduce), and submitted a bug report.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi, I know this is an old post but I've detected the same issue and didn't found any solution... Bassically when I run the code attached following instructions posted at the official site of NT to BuySell Volume Indicator https://ninjatrader.com/support/help...sellvolume.htm, I printed out the values of BuySell Volume Indicator and found that first tick of Bar is not available on the indicator's value (Image 1) and the last tick doesn't match with graphic Indicator's value (Image 2 and Image 3)


          Thanks in advance for your help
          Attached Files

          Comment


            #6
            Hello ricardo88,

            Thank you for your patience.

            The BuySellVolume sets the plot of the indicator in OnMarketData() based on the Market Data updates. The OnMarketData() function is called after the OnBarUpdate() function. This means on the first tick that calls OnBarUpdate() we do not see the plot yet and on the last tick the Plot has not updated yet.

            The VOL indicator is different in that it pulls the Volume from the Bar directly rather than from a Bid or Ask Market Data update, therefore the VOL indicator's plot is updated immediately in OnBarUpdate().

            Please let me know if you have any questions.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by yertle, Yesterday, 08:38 AM
            7 responses
            28 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by bmartz, 03-12-2024, 06:12 AM
            2 responses
            21 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by funk10101, Today, 12:02 AM
            0 responses
            5 views
            0 likes
            Last Post funk10101  
            Started by gravdigaz6, Yesterday, 11:40 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by MarianApalaghiei, Yesterday, 10:49 PM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X