NexusFi: Find Your Edge


Home Menu

 





Using OnMarketData() on Historical data with a recording engine


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one gomi with 34 posts (87 thanks)
    2. looks_two aviat72 with 10 posts (2 thanks)
    3. looks_3 danjurgens with 9 posts (3 thanks)
    4. looks_4 Michael.H with 8 posts (0 thanks)
      Best Posters
    1. looks_one gomi with 2.6 thanks per post
    2. looks_two Zondor with 1 thanks per post
    3. looks_3 danjurgens with 0.3 thanks per post
    4. looks_4 aviat72 with 0.2 thanks per post
    1. trending_up 51,270 views
    2. thumb_up 104 thanks given
    3. group 28 followers
    1. forum 115 posts
    2. attach_file 23 attachments




 
Search this Thread

Using OnMarketData() on Historical data with a recording engine

  #101 (permalink)
 aviat72 
San Francisco Bay Area
 
Experience: Intermediate
Platform: NT,TOS,IB
Trading: ES,CL,TF
Posts: 281 since Jun 2010
Thanks Given: 161
Thanks Received: 273


danjurgens View Post
BDB accepts duplicate keys and duplicate key/data pairs just fine. You just have to use a construct they call a cursor to access all the data with duplicate keys. The conflict between realtime writers and backfill writers resolves itself when you force the backfill writer to provide all the tick data for each unique time stamp at once. Then you just delete and replace all the data for each time stamp with the back filled data.

Yes. That is exactly what I had in mind; overwriting the existing data is important.


Quoting 

It's theoretically possible you would lose some ticks if you back fill up to the current real time second, but I don't see that being possible in my initial implementation. To download back fill for the current partial second and get it processed and to the server while a real time writer is still writing that tick is race the user can avoid by not back filling up to right now, just go a second back.

There will be some latency from the time you make the request and till you get the data. You can not be sure of the time-stamp of the information returned by the historical data request. What you could do is buffer the live data while you are requesting historical data and then using time-stamps, and some local tick matching, find where the historical data tick ends and then store the buffered live data.

Visit my NexusFi Trade Journal Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
What broker to use for trading palladium futures
Commodities
About a successful futures trader who didn´t know anyth …
Psychology and Money Management
Quant vue
Trading Reviews and Vendors
MC PL editor upgrade
MultiCharts
 
  #102 (permalink)
 paolfili 
italy
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Zen-Fire
Trading: ES
Posts: 33 since Nov 2009
Thanks Given: 51
Thanks Received: 11

GomCD CalculateDeltaIndicator method can use BidAsk (Price >=Ask Price<=Bid), UpDownTick (TickUp=+1,TickDown=-1) UpDownTickWithContinuation...
I need to count the Ticks on Bid and and the Ticks on Ask. (No Up or Down....in the while the Bid/ask can change).
Some suggestions on this subject before I modify the GomdeltaIndicator to insert this culculation mode?

Thanks

Paolo

Reply With Quote
  #103 (permalink)
 danjurgens 
Austin, TX
 
Experience: Advanced
Platform: TradeStation, TWS
Broker: TradeStation, IB .. for now
Trading: 6E, ES
Posts: 28 since May 2010
Thanks Given: 0
Thanks Received: 28



pfx111 View Post
GomCD CalculateDeltaIndicator method can use BidAsk (Price >=Ask Price<=Bid), UpDownTick (TickUp=+1,TickDown=-1) UpDownTickWithContinuation...
I need to count the Ticks on Bid and and the Ticks on Ask. (No Up or Down....in the while the Bid/ask can change).
Some suggestions on this subject before I modify the GomdeltaIndicator to insert this culculation mode?

Thanks

Paolo

So you want to filter out ticks that are AboveAsk/BelowBid/Between?

Without having the code right in front of me I might be slightly off the mark, but I think you need to Add a calculationModeType for Delta at Bid/Ask assume you call it AtBidAsk.

then in the CalcDelta function add a case for your new type as such:
else if ((calcmode==GomCDCalculationModeType.AtBidAsk) && (tickType!=TickTypeEnum.Unknown))
{
if ((tickType==TickTypeEnum.AtBid))
delta =-volume;
else if ((tickType==TickTypeEnum.AtAsk))
delta=volume;
}

Reply With Quote
  #104 (permalink)
 
Zondor's Avatar
 Zondor 
Portland Oregon, United States
 
Experience: Beginner
Platform: Ninjatrader®
Broker: CQG, Kinetick
Trading: Gameplay Klownbine® Trading of Globex
Posts: 1,333 since Jul 2009
Thanks Given: 1,246
Thanks Received: 2,731

The tickTypes are BelowBid, AtBid, BetweenBidAsk, AtAsk, and AboveAsk.

So, in GomOnMarketData() you just respond to those incoming ticks with the tickTypes representing the types of trades you want to count.

Or you respond to them selectively. For example, trades that are above the ask and below the bid can be counted in the Grande Totals of buyvolume and sellvolume, but also can be counted separately. If you do this, in a bar chart showing buyvolumes and sellvolumes, the "outside" trades can be shown as comprising PORTIONS of the buyvolume and sellvolume bars, whilst also being counted within the totals of buyvolume and sellvolume. See the Buy/Sell Volume indicators I have posted in the Elite downloads section for code examples.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #105 (permalink)
 
RJay's Avatar
 RJay 
Hartford, CT. USA
 
Experience: Intermediate
Platform: NinjaTrader
Broker: AMP/CQG, Kinetick
Trading: RTY
Posts: 683 since Jun 2009
Thanks Given: 758
Thanks Received: 787


pfx111 View Post
GomCD CalculateDeltaIndicator method can use BidAsk (Price >=Ask Price<=Bid), UpDownTick (TickUp=+1,TickDown=-1) UpDownTickWithContinuation...
I need to count the Ticks on Bid and and the Ticks on Ask. (No Up or Down....in the while the Bid/ask can change).
Some suggestions on this subject before I modify the GomdeltaIndicator to insert this culculation mode?

Thanks

Paolo

I assume you want the ticks that are completed orders on the bid and ask sides of the market.

Non Gomi indicator.

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

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)return;


if((LastPrice >= AskPrice) && (AskPrice!=0)) AskTickTotal ++;
else if((LastPrice <= BidPrice) && (BidPrice!=0)) BidTicktotal--;

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

Gomi indicator:

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

if ((tickType==TickTypeEnum.AboveAsk) || (tickType==TickTypeEnum.AtAsk)) AskTickTotal ++ ;

else if ((tickType==TickTypeEnum.BelowBid) || (tickType==TickTypeEnum.AtBid)) CurrentBidVolumeBidTicktotal--;

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

RJay

Reply With Quote
Thanked by:
  #106 (permalink)
 danjurgens 
Austin, TX
 
Experience: Advanced
Platform: TradeStation, TWS
Broker: TradeStation, IB .. for now
Trading: 6E, ES
Posts: 28 since May 2010
Thanks Given: 0
Thanks Received: 28

My first attempt at the Database using Tick server is available for your downloading pleasure:


Reply With Quote
Thanked by:
  #107 (permalink)
 gomi 
Paris
Market Wizard
 
Experience: None
Platform: NinjaTrader
Posts: 1,270 since Oct 2009
Thanks Given: 282
Thanks Received: 4,505

Here's a new beta version of the recorder
features:
* Added "Volume Split" setting, that will split ticks on constant volume charts. It works on historical (gom file) and real time data. Disable it if you do any kind of volume filtering.
* Improved the tick rendering in "non split" mode, to minimize difference between non-split volume and the constant volume series NT maintains.
* Rewrote tick rendering engine. Now 100% the same as Volume[0] on second,tick,volume and range charts. In history and real time. With CalculateOnBarClose=true or false
* NT7 "new tick model" with OnMarketData firing before OnBarUpdate is now OK. NT 6.5 compatibility has been dropped
*Added Ninja file format availability in Read Only mode. This way you can export data from NT and use it directly in Gom indicators (extension .Ninja.txt) to check how the tick engine handles the ticks
* Dropped the "compress ticks" mode that was pretty much useless and made the recording functions a real pain to write, so simplified the recording methods as well
*Added a GomOnStartUp for those wishing access to NT7's OnStartUp
*Changed session handling so there shouln't be problems with multiple session templates

I also include a new DeltaIndicator class, that implements Zondor's "Delta Completion" idea, meaning that when the ticktype is unknown or betweenbidask, we use updowntick mode to assign a delta. So each tick has a delta, and when you sum buy delta and sell delta, you get the total volume of the bar. This setting can be changed (It's called delta completion)

I also include GomVol, that basically plots volume that you can directly compare to Volume[0]. It also show how to correctly implement recorder indies :
*Initialize bars in GomOnBarUpdate
*Do your internal stuff in GomOnMarketData
*Set the values to the indicator time series in GomOnBarUpdate Done

I also include GomVolTest, that will show bar and cumulative difference between Volume[0] and GomVol[0]. It is reset on each session start

I also include GomDeltaVolume for basic delta checks.

Any feedback is most welcome.

Attached Files
Elite Membership required to download: beta.zip
Started this thread Reply With Quote
  #108 (permalink)
 Michael.H 
CA
 
Experience: Master
Platform: Marketdelta and Ninja
Broker: Velocity
Trading: NQ
Posts: 663 since Apr 2010
Thanks Given: 64
Thanks Received: 529

I get this error when i imported the indicator into the folder... I was trying to use your GOm CD and ladder

Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	282
Size:	6.0 KB
ID:	25713  
Reply With Quote
  #109 (permalink)
 gomi 
Paris
Market Wizard
 
Experience: None
Platform: NinjaTrader
Posts: 1,270 since Oct 2009
Thanks Given: 282
Thanks Received: 4,505

? Maybe your template file is corrupt. Could you try again on a plain new chart ?

Started this thread Reply With Quote
  #110 (permalink)
 
Silvester17's Avatar
 Silvester17 
Columbus, OH
Market Wizard
 
Experience: None
Platform: NT 8, TOS
Trading: ES
Posts: 3,603 since Aug 2009
Thanks Given: 5,139
Thanks Received: 11,527



gomi View Post
Here's a new beta version of the recorder
features:
* Added "Volume Split" setting, that will split ticks on constant volume charts. It works on historical (gom file) and real time data. Disable it if you do any kind of volume filtering.
* Improved the tick rendering in "non split" mode, to minimize difference between non-split volume and the constant volume series NT maintains.
* Rewrote tick rendering engine. Now 100% the same as Volume[0] on second,tick,volume and range charts. In history and real time. With CalculateOnBarClose=true or false
* NT7 "new tick model" with OnMarketData firing before OnBarUpdate is now OK. NT 6.5 compatibility has been dropped
*Added Ninja file format availability in Read Only mode. This way you can export data from NT and use it directly in Gom indicators (extension .Ninja.txt) to check how the tick engine handles the ticks
* Dropped the "compress ticks" mode that was pretty much useless and made the recording functions a real pain to write, so simplified the recording methods as well
*Added a GomOnStartUp for those wishing access to NT7's OnStartUp
*Changed session handling so there shouln't be problems with multiple session templates

I also include a new DeltaIndicator class, that implements Zondor's "Delta Completion" idea, meaning that when the ticktype is unknown or betweenbidask, we use updowntick mode to assign a delta. So each tick has a delta, and when you sum buy delta and sell delta, you get the total volume of the bar. This setting can be changed (It's called delta completion)

I also include GomVol, that basically plots volume that you can directly compare to Volume[0]. It also show how to correctly implement recorder indies :
*Initialize bars in GomOnBarUpdate
*Do your internal stuff in GomOnMarketData
*Set the values to the indicator time series in GomOnBarUpdate Done

I also include GomVolTest, that will show bar and cumulative difference between Volume[0] and GomVol[0]. It is reset on each session start

I also include GomDeltaVolume for basic delta checks.

Any feedback is most welcome.

question from a clueless:

if you have other indicators using the recorder with the code "protected override void OnStartUp()", is it OK with the new recorder just to change that code to "protected override void GomOnStartUp()" ?

Reply With Quote




Last Updated on March 6, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts