Possible issue with Buy, sell, and net volume - NinjaTrader | futures io social day trading
futures io futures trading


Possible issue with Buy, sell, and net volume
Updated: Views / Replies:525 / 22
Created: by Cheech Attachments:2

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 2  
 
Thread Tools Search this Thread
 

Possible issue with Buy, sell, and net volume

  #1 (permalink)
Mesa, AZ/USA
 
Trading Experience: Intermediate
Platform: NinjaTrader, ThinkorSwim
Broker/Data: AMP Futures/CQG, TDA
Favorite Futures: Currency Futures, my Harley Davidson
 
Posts: 107 since Jun 2012
Thanks: 43 given, 131 received

Possible issue with Buy, sell, and net volume

I am really perplexed on the condition stated here and request some input.

I recently wrote and posted an indicator to plot buy, sell, net, and total volumes which was based on NT’s BuySellVolume (BSV) indicator. No issues with the indicator as is however, as I was writing another indicator to do more analysis on the buy and sell volume I realized there was something that I completely missed because I did not bother investigating why the BSV indicator categorized the trade volume as either a Buy or Sell. The basis for that decision can be seen in the code below (directly from the BSV indicator in a truncated form) which is in the OnMarketData section:
if(e.Price >= e.Ask)
buys += (Instrument.MasterInstrument.InstrumentType == … (truncated here)
else if (e.Price <= e.Bid)
sells += (Instrument.MasterInstrument.InstrumentType == … (truncated here)
While it looks pretty straight forward notice that both “if” statements test for the “=” condition. This would mean that when the condition is such that the Price = Ask = Bid the volume for that trade is put into the Buy Volume. If the order of condition test were reversed, then that volume under the same conditions would be Sell Volume.

Is this an arbitrary condition or is there a legitimate reason for testing in this order, a question I have raised with NT support (and have not heard back yet other than it is being investigated)? It seems to me that if there isn’t a legitimate reason for testing in this order that the volume, under the mentioned condition, would be skewed to the buy volume.
To see how prevalent this condition might occur, I modified the inprogress of Version 2 of my indicator with the code below (again truncated for clarity and in the same section):
if(e.Price > e.Ask)
buys += (Instrument.MasterInstrument.InstrumentType == … (truncated here)
else if (e.Price < e.Bid)
sells += (Instrument.MasterInstrument.InstrumentType == … (truncated here)
else if ( counter == 0 )
{
buys += (Instrument.MasterInstrument.InstrumentType == … (truncated here)
counter++;
buyCounter++;
}
else
{
sells += (Instrument.MasterInstrument.InstrumentType == … (truncated here)
counter--;
sellCounter++;
}
This code handles the Price=Ask=Sell condition differently by splitting the matches equally between the Buys and Sells, arbitrarily putting the even trades as buys and the odd trades as sells. It also counts the number of times each section of the code was entered for each bar which get printed when the bar is closed. The results surprised me.

Using a 300 tick bar (with tick replay) on over 5000 bars all but 3 or 4 matched the condition. This count included both historical and real time data with the historical making up a major part of the count. The screen shot shows how different the results are with only the code change above.

Unless I am missing something (entirely possible), the issue is that unless there is a justifiable reason for categorizing the trades that meets the condition as Buy volume then it must be arbitrary therefore is not justified. Does this or does it not call into question the value of even using buy/sell volume under these circumstances?

Thoughts!

Attached Thumbnails
Possible issue with Buy, sell, and net volume-buy-sell_issue.png  

Last edited by Cheech; April 5th, 2019 at 04:48 PM.
Reply With Quote
 
  #2 (permalink)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,631 since Dec 2012
Thanks: 16,954 given, 8,228 received


Cheech View Post

While it looks pretty straight forward notice that both “if” statements test for the “=” condition.

Not so, one condition is testing for >= and the other is testing for <=.

i.e. the code caters for prices equal to or worse than the ask, and equal to or worse than the bid.

There are many ways to code this area but the original is an ok one.

Travel Well
Reply With Quote
 
  #3 (permalink)
Mesa, AZ/USA
 
Trading Experience: Intermediate
Platform: NinjaTrader, ThinkorSwim
Broker/Data: AMP Futures/CQG, TDA
Favorite Futures: Currency Futures, my Harley Davidson
 
Posts: 107 since Jun 2012
Thanks: 43 given, 131 received



ratfink View Post
Not so, one condition is testing for >= and the other is testing for <=.

i.e. the code caters for prices equal to or worse than the ask, and equal to or worse than the bid.

There are many ways to code this area but the original is an ok one.

Well, but what about the condition that I mentioned when Bid and Ask are both equal to Price?? It seems to me that the first "if" would detect the equal condition therefore put the volume in the Buy category.

Reply With Quote
 
  #4 (permalink)
Mesa, AZ/USA
 
Trading Experience: Intermediate
Platform: NinjaTrader, ThinkorSwim
Broker/Data: AMP Futures/CQG, TDA
Favorite Futures: Currency Futures, my Harley Davidson
 
Posts: 107 since Jun 2012
Thanks: 43 given, 131 received


ratfink View Post
Not so, one condition is testing for >= and the other is testing for <=.

i.e. the code caters for prices equal to or worse than the ask, and equal to or worse than the bid.

There are many ways to code this area but the original is an ok one.

Also, maybe you missed the part where the equal tests were removed from the NT tests and fell through to the added code. This would mean the neither the Price was > Ask nor the Price was < Bid, therefore both Bid and Ask were equal to Price.

That is the condition that I'm questioning.

I suppose one could question why the other possible conditions (Price < Ask or Price > Bid) weren't included in any test but neither of those would make sense to me in a completed trade.

Am I still missing something here?

Reply With Quote
 
  #5 (permalink)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,631 since Dec 2012
Thanks: 16,954 given, 8,228 received

Here's my NT7 code (non=PC 'returns' because it's c30% faster)

 
Code
protected override void OnMarketData(MarketDataEventArgs e)
{
    if (e.Price == 0)
        return;
			
    if (e.MarketDataType == MarketDataType.Ask)
    {
        askPrice = e.Price;
        return;
    }
			
    if (e.MarketDataType == MarketDataType.Bid)
    {
         bidPrice = e.Price;
         return;
    }
			
    if (e.MarketDataType != MarketDataType.Last)
	 return;
					
    if (e.Price >= askPrice)
    {
        upVol += e.Volume;
        buying = true;
        return;
    }
			
    if (e.Price <= bidPrice)
    {
        downVol += e.Volume;
        buying = false;
        return;
    }

    if (buying)
    {
        upVol += e.Volume;
        return;
    }

    downVol += e.Volume;
}
As an aside I've stopped using OMD in more recent stuff and use separate Ask and Bid series in OBU where needed.

Travel Well
Reply With Quote
 
  #6 (permalink)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,631 since Dec 2012
Thanks: 16,954 given, 8,228 received


Cheech View Post
Am I still missing something here?

Just that Price can be in between a widened spread Ask and Bid (i.e. neutral and therefore not registered in some code variants), or equal to Bid or equal to Ask (and be valid Buys or Sells but therefore forced into your modified code arbitrary second version allocation scheme counters), or less than Bid or greater than Ask and be rightly classed as desperate Sells or Buys. Furthermore Bid/Ask should never meet or cross or the exchange screwed up. Notwithstanding OMD also gets hit with lots of other stuff as well as what you want to see, including zero prices (meaning unchanged Bid/Ask) from some datafeeds.

Hope that and the code helps, TGIF + beer or wine also does, Cheers @Cheech.

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #7 (permalink)
Mesa, AZ/USA
 
Trading Experience: Intermediate
Platform: NinjaTrader, ThinkorSwim
Broker/Data: AMP Futures/CQG, TDA
Favorite Futures: Currency Futures, my Harley Davidson
 
Posts: 107 since Jun 2012
Thanks: 43 given, 131 received


ratfink View Post
Here's my NT7 code (non=PC 'returns' because it's c30% faster)

 
Code
protected override void OnMarketData(MarketDataEventArgs e)
{
    if (e.Price == 0)
        return;
			
    if (e.MarketDataType == MarketDataType.Ask)
    {
        askPrice = e.Price;
        return;
    }
			
    if (e.MarketDataType == MarketDataType.Bid)
    {
         bidPrice = e.Price;
         return;
    }
			
    if (e.MarketDataType != MarketDataType.Last)
	 return;
					
    if (e.Price >= askPrice)
    {
        upVol += e.Volume;
        buying = true;
        return;
    }
			
    if (e.Price <= bidPrice)
    {
        downVol += e.Volume;
        buying = false;
        return;
    }

    if (buying)
    {
        upVol += e.Volume;
        return;
    }

    downVol += e.Volume;
}
As an aside I've stopped using OMD in more recent stuff and use separate Ask and Bid series in OBU where needed.

Sorry, maybe I'm being dense here but I would like to see those rules in English as I still don't understand what it is you are doing and under what premise. I'm not saying they are wrong or anything but it still isn't clear to me that when a trade is completed when Bid=Ask=Price as per the NT code under what rules can be it classified as either a buy or sell trade

Reply With Quote
 
  #8 (permalink)
Oxford UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: YM
 
Posts: 10 since Apr 2019
Thanks: 4 given, 5 received

Bid < Price < Ask


Cheech View Post
Also, maybe you missed the part where the equal tests were removed from the NT tests and fell through to the added code. This would mean the neither the Price was > Ask nor the Price was < Bid, therefore both Bid and Ask were equal to Price.

That is the condition that I'm questioning.

I suppose one could question why the other possible conditions (Price < Ask or Price > Bid) weren't included in any test but neither of those would make sense to me in a completed trade.

Am I still missing something here?

I think it would mean that the Price was somewhere between the Bid and the Ask, not that the Bid and Ask were the same.

Reply With Quote
The following user says Thank You to Cilla for this post:
 
  #9 (permalink)
Oxford UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: YM
 
Posts: 10 since Apr 2019
Thanks: 4 given, 5 received


ratfink View Post
Just that Price can be in between a widened spread Ask and Bid (i.e. neutral and therefore not registered in some code variants), or equal to Bid or equal to Ask (and be valid Buys or Sells but therefore forced into your modified code arbitrary second version allocation scheme counters), or less than Bid or greater than Ask and be rightly classed as desperate Sells or Buys. Furthermore Bid/Ask should never meet or cross or the exchange screwed up. Notwithstanding OMD also gets hit with lots of other stuff as well as what you want to see, including zero prices (meaning unchanged Bid/Ask) from some datafeeds.

Hope that and the code helps, TGIF + beer or wine also does, Cheers @Cheech.

Sorry - newbie error - missed Ratfink's post!

Reply With Quote
The following user says Thank You to Cilla for this post:
 
  #10 (permalink)
Market Wizard
Birmingham UK
 
Trading Experience: Intermediate
Platform: NinjaTrader
Broker/Data: TST/Rithmic
Favorite Futures: YM/Gold
 
ratfink's Avatar
 
Posts: 3,631 since Dec 2012
Thanks: 16,954 given, 8,228 received



Cilla View Post
Sorry - newbie error - missed Ratfink's post!

No problem, you clarified a point I only covered indirectly anyway.

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:

Reply



futures io > > > > Possible issue with Buy, sell, and net volume




Upcoming Webinars and Events (4:30PM ET unless noted)
 

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now
 

Thanks for everything -- $250 in Amazon Gift Cards ready to give away

Right now
 

Journal in July -- over $2,500 in prizes w/NinjaTrader

July
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
esignal classic not providing sell and buy volume johnEdweeno eSignal 1 October 31st, 2018 01:51 AM
Volume histogram with Buy n Sell volume roomyd MultiCharts 5 July 11th, 2014 12:05 PM
The imbalance is the net of all the stocks to buy and sell on the cash close (MOC) Danny Riley Traders Hideout 1 November 25th, 2013 01:51 PM
Is it possible to show Buy/Sell strength in NT6.5? steveg NinjaTrader 1 March 15th, 2011 12:40 PM
Buy Sell indicator based on traded volume, not price kronie The Elite Circle 6 November 21st, 2009 09:14 AM


Tags
backtesting, barsinprogress, bid and ask, bid/ask, buy, buysellvolume, code, data, dow, error, es, est, futures, historical data, indicator, indicators, instrument, ma, market replay, market_replay, namespace, newbie, ninjascript, ninjatrader, nt7, nt7 code, nt8, onmarketdata, real time, replay, replay data, sma, split, spread, stoploss, strategies, strategy, superdom, support, t3, tick, type, update, variable, volume

All times are GMT -4. The time now is 05:09 PM. (this page content is cached, log in for real-time version)

Copyright © 2019 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432 WhatsApp Business, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts