Problem with OnMarketData() - NinjaTrader Programming | futures io social day trading
futures io futures trading


Problem with OnMarketData()
Updated: Views / Replies:3,793 / 35
Created: by ketron82 Attachments:0

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 90,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
 
Thread Tools Search this Thread
 

Problem with OnMarketData()

  #1 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received

Problem with OnMarketData()

My ideas is simply cumulate ask volume and bid vol.
I simply have to compare last price with ask or bid price...and so:
if Last Price==Ask Price --> Volume of last price is ASK
if Last Price==Bid Price --> Volume of last price is BID

and I made this code to begin work but have some problem yet.I made other tests but I cannot solve this problem....with this simple function, in the Output Windows I sometime read that "last price" is not equal at askprice or bid price....and this is strange.

DropZone

Any ideas?


 
Code
protected override void OnMarketData(MarketDataEventArgs e)
			{	
    // Print some data to the Output window
    if (e.MarketDataType == MarketDataType.Last) 
         { 
			Print("### Last = " + e.Price + " " + e.Volume +  " Bid Price= " + GetCurrentBid() + "  Ask Price= " + GetCurrentAsk());
			
		
		 }	

			
			
	     
//	else if (e.MarketDataType == MarketDataType.Ask)
//		{
//        Print("Ask = " + e.Price + " " + e.Volume);
//	  
//		}	
//	else if (e.MarketDataType == MarketDataType.Bid)
//		{
//	    Print("Bid = " + e.Price + " " + e.Volume);
//	    
//	    }
	

	
			}


Last edited by ketron82; October 11th, 2013 at 06:41 AM.
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received



ketron82 View Post
My ideas is simply cumulate ask volume and bid vol.
I simply have to compare last price with ask or bid price...and so:
if Last Price==Ask Price --> Volume of last price is ASK
if Last Price==Bid Price --> Volume of last price is BID

and I made this code to begin work but have some problem yet.I made other tests but I cannot solve this problem....with this simple function, in the Output Windows I sometime read that "last price" is not equal at askprice or bid price....and this is strange.

DropZone

Any ideas?

You can have many Ask/Bid changes in between getting a Last (actual trade) price so you need to store latest Bid and Ask values in local variables, plus as you say the trade price can be above or below (or in-between (i.e. unclassifiable or neutral)) so your tests should be 'price >= askPrice' or 'price <= bidPrice', and not just ==.

Travel Well
Reply With Quote
 
  #4 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received

Ok...I am comparing MarketDelta Time and Sales with output windows of mi indicator in ninja and same datafeed IQfeed.
I will post now a screenshot of the results

Reply With Quote
 
  #5 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received

DropZone

This is the screenshot where I compare MarketDelta (iqfeed) and Ninja (iqfeed).
I think that there is some problem using getcurrentask() or getcurrentbid() in onmarketdata() function....I make a conceptual error but I haven't found a correct logical working of onmarketdata()

How is a best way to use onmarketdata() ?

I made other test without getcurrentask and getcurrentbid but using

else if (e.MarketDataType == MarketDataType.Ask)

but something go wrong however.

Any ideas?

Reply With Quote
 
  #6 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received


ratfink View Post
You can have many Ask/Bid changes in between getting a Last (actual trade) price so you need to store latest Bid and Ask values in local variables, plus as you say the trade price can be above or below (or in-between (i.e. unclassifiable or neutral)) so your tests should be 'price >= askPrice' or 'price <= bidPrice', and not just ==.

Ok many many thanks...I saw what you told me....like in this screenshot DropZone

but How can I capture the ASK and BID (price) corresponding to the lastprice?

Tnx again


Last edited by ketron82; October 11th, 2013 at 07:06 AM.
Reply With Quote
The following user says Thank You to ketron82 for this post:
 
  #7 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


ketron82 View Post
DropZone

This is the screenshot where I compare MarketDelta (iqfeed) and Ninja (iqfeed).
I think that there is some problem using getcurrentask() or getcurrentbid() in onmarketdata() function....I make a conceptual error but I haven't found a correct logical working of onmarketdata()

How is a best way to use onmarketdata() ?

I made other test without getcurrentask and getcurrentbid but using

else if (e.MarketDataType == MarketDataType.Ask)

but something go wrong however.

Any ideas?

What I do:

 
Code
static private double askPrice = 0;
static private double bidPrice = 0;
static private double upVol = 0;
static private double downVol = 0;
static private double neutralVol = 0;

protected override void OnMarketData(MarketDataEventArgs e)
{
    if (e.MarketDataType == MarketDataType.Ask)
    {
        askPrice = e.Price;
        return;
    }
			
    if (e.MarketDataType == MarketDataType.Bid)
    {
        bidPrice = e.Price;
        return;
    }
			
    if (e.MarketDataType != MarketDataType.Last || ChartControl == null || askPrice == 0 || bidPrice == 0)
        return;

    if (e.Price >= askPrice) 
    {
	upVol += e.Volume;
    }
    else  if (e.Price <= bidPrice)
    {
        downVol += e.Volume;
    }
    else
    {
        neutralVol += e.Volume;
    }
}

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #8 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received

OK....I will test now...good idea....I'm trying to understand the logic....many thanks for now.
I will post the results and screenshot for other interested users.


ratfink View Post
What I do:

 
Code
static private double askPrice = 0;
static private double bidPrice = 0;
static private double upVol = 0;
static private double downVol = 0;
static private double neutralVol = 0;

protected override void OnMarketData(MarketDataEventArgs e)
{
    if (e.MarketDataType == MarketDataType.Ask)
    {
        askPrice = e.Price;
        return;
    }
			
    if (e.MarketDataType == MarketDataType.Bid)
    {
        bidPrice = e.Price;
        return;
    }
			
    if (e.MarketDataType != MarketDataType.Last || ChartControl == null || askPrice == 0 || bidPrice == 0)
        return;

    if (e.Price >= askPrice) 
    {
	upVol += e.Volume;
    }
    else  if (e.Price <= bidPrice)
    {
        downVol += e.Volume;
    }
    else
    {
        neutralVol += e.Volume;
    }
}


Reply With Quote
 
  #9 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received

DropZone

Many many thanks.....your code seems to work well but I'm still trying to understand the different logical condition in onmarketdata() function.
You used "return;" in ask and bid call.....and so...good idea.
I will tell more

Many many thanks for now


ratfink View Post
What I do:

 
Code
static private double askPrice = 0;
static private double bidPrice = 0;
static private double upVol = 0;
static private double downVol = 0;
static private double neutralVol = 0;

protected override void OnMarketData(MarketDataEventArgs e)
{
    if (e.MarketDataType == MarketDataType.Ask)
    {
        askPrice = e.Price;
        return;
    }
			
    if (e.MarketDataType == MarketDataType.Bid)
    {
        bidPrice = e.Price;
        return;
    }
			
    if (e.MarketDataType != MarketDataType.Last || ChartControl == null || askPrice == 0 || bidPrice == 0)
        return;

    if (e.Price >= askPrice) 
    {
	upVol += e.Volume;
    }
    else  if (e.Price <= bidPrice)
    {
        downVol += e.Volume;
    }
    else
    {
        neutralVol += e.Volume;
    }
}


Reply With Quote
The following user says Thank You to ketron82 for this post:
 
  #10 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received


Many thanks also to ratfink user that have tanked me

Now I would proceed step by step.

I would now create a "Class" for store ask and bid that have the same last price although not ranked.

Have you an idea yet?

I am testing some example....I will post in the next minutes.

Reply With Quote

Reply



futures io > > > > > Problem with OnMarketData()

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
CalculateOnBarClose = false versus OnMarketData() MWinfrey NinjaTrader Programming 8 September 30th, 2013 01:52 PM
OnMarketData Problem humy65 NinjaTrader Programming 3 October 16th, 2012 11:17 AM
OnMarketData serious issue baberg NinjaTrader Programming 13 September 27th, 2011 10:04 AM
BUG for OnMarketData timmyb NinjaTrader Programming 12 February 5th, 2011 10:32 PM
Programming Indicators Using OnMarketData in NT7!!! RJay NinjaTrader Programming 3 December 16th, 2010 01:16 PM


All times are GMT -4. The time now is 06:39 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, 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
Page generated 2017-12-13 in 0.13 seconds with 19 queries on phoenix via your IP 54.90.92.204