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!
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
NinjaTrader
historical bid ask data
Collapse
X
-
Hello ballboy11,
Thank you for your post.
Is this indicator using GetCurrentBid() and/or GetCurrentAsk()? It would be expected for these to only function on real time data. For the indicator to function on historical data, Tick Replay would need to be used:
Here's the example of how to access historical bid/ask prices using Tick Replay from the above link:
Code:protected override void OnMarketData(MarketDataEventArgs marketDataUpdate) { // TickReplay events only occur on the "Last" market data type if (marketDataUpdate.MarketDataType == MarketDataType.Last) { if (marketDataUpdate.Price >= marketDataUpdate.Ask) { Print(marketDataUpdate.Volume + " contracts traded at asking price " + marketDataUpdate.Ask); } else if (marketDataUpdate.Price <= marketDataUpdate.Bid) { Print(marketDataUpdate.Volume + " Contracts Traded at bidding price " + marketDataUpdate.Bid); } } }
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
-
Kate if you want to take the above script, which i have try without success and calculate the spread where would i place the following into that script
Spread[0] = (marketDataUpdate.Ask - marketDataUpdate.Bid);
or do i not actually need all of that script, thanks
Comment
-
Hello DTSSTS,
Thank you for your reply.
You'd want to assign a non- Series<T> double variable the spread you calculate in OnMarketData. You can then use that variable in OnBarUpdate to assign the value to your Series<T> variable.
I've attached a simple example script that shows how you could accomplish this. It requires Tick Replay to be turned on for it to function correctly.
Please let us know if we may be of further assistance to you.Attached FilesKate W.NinjaTrader Customer Service
Comment
-
Kate with you help I have an indicator that plots oneachtick the spread. If the chart remains open the plot continues through out the session. Of course if instruments are changed on the chart the plot starts with zero historical and creates a new plot for the new instrument. Point is the chart instrument has to remain live for the indicator to show any history
Question is. If I create a condition in my Strategy using the indicator, (understand will not work on backtesting) After applying strategy to a chart the Spread Tracker would of course work same as it does as an indicator on a chart.
IF I PLACE MY STRATEGY ON A INSTRUMENT LIST IN THE CONTROL CENTER (no charts) WILL THAT STILL TRACK THE SPREAD for all instruments the strategy is applied to
Thanks, Hap
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by frslvr, 04-11-2024, 07:26 AM
|
9 responses
123 views
1 like
|
Last Post
by caryc123
Today, 03:12 PM
|
||
Started by rocketman7, Today, 09:41 AM
|
4 responses
16 views
0 likes
|
Last Post
by rocketman7
Today, 02:56 PM
|
||
Started by selu72, Today, 02:01 PM
|
1 response
9 views
0 likes
|
Last Post Today, 02:17 PM | ||
Started by WHICKED, Today, 02:02 PM
|
2 responses
18 views
0 likes
|
Last Post
by WHICKED
Today, 02:15 PM
|
||
Started by f.saeidi, Today, 12:14 PM
|
8 responses
21 views
0 likes
|
Last Post
by f.saeidi
Today, 01:55 PM
|
Comment