Announcement
Collapse
No announcement yet.
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:
Basically you'd want to separate your logic out so that on real time, it uses GetCurrentBid and GetCurrentAsk but on Historical data it uses the above approach. Tick replay would need to be turned on on the chart the indicator is applied to for the historical portion to function.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 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 Files
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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
601 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
347 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
559 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
558 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment