Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Auto refresh
Collapse
X
-
ballboy11,
ForceRefresh() would be suggested for refreshing plots: https://ninjatrader.com/support/help...b=ForceRefreshJosh G.NinjaTrader Customer Service
Comment
-
Hello Josh,Originally posted by NinjaTrader_JoshG View Postballboy11,
ForceRefresh() would be suggested for refreshing plots: https://ninjatrader.com/support/help...b=ForceRefresh
The link provided does not work. Was it supposed to refer here:
I have been trying to make ForceRefresh() work with static data for the S&P500 Cash index ($SPX) and $VIX data. These simply require a refresh every 1 sec. in order to populate a chart with the currrent value.
ForceRefresh() will accomplish this, however testing the method by pasting the code snippet into a new indicator (attached) and applying it to either chart does not work.
Another forum thread suggests adding a line which plots a dot then on the next line removes said dot causing a NinjaScript refresh. Is this correct?
Thank youAttached Files
Comment
-
Hello culpepper,
Below is an updated link.
The script you have provided is a closed source dll where we cannot view the code (and cannot import due to our policy).
To confirm, you are trying to do the same thing and refresh when clicking a button?
Are you also setting plot series from the button .Click event handler method?
If so, are you calling TriggerCustomEvent() in the button .Click event handler method before setting or using series values?
Chelsea B.NinjaTrader Customer Service
Comment
-
Chelsea, thanks for posting a response.
My requirement is similar, but not quite the same as the needs of ballboy11. I simply need to refresh chart data every one second programmatically (exactly as the code snippet in topic: ForceRefresh() intends). Yes, this will consume system resources. The system has plenty to spare.
I am not mapping a button. F5 is already that button and am not calling TriggerCustomEvent() since there is no button. In essence duplicating the function of F5 within the indicator using the ForceRefresh() command.
There are no plots or plot series' on the chart. No indicators or strategies whatsover. There is only pure price structure of one symbol only needing to be refreshed each 1 second as in the snippet.
The indicator below should work theoretically however I am probably not pasting the ForceRefresh() snippet in the correct place (minimal coding experience).
DateTime lastTimeCalled = DateTime.MinValue; may need to be somewhere else. Perhaps a declaration is missing.
Any pointers you could provide will be greatly appreciated. Thank you.
Comment
-
Hello culpepper,
"In essence duplicating the function of F5 within the indicator using the ForceRefresh() command."
The ForceRefresh() causes the chart to re-render on the next render pass.
Pressing F5 reloads all NinjaScripts (which reprocess the historical data).
These do not do the same thing.
The code you have suggested, does not render anything that would need to be refereshed..
Can you clarify what you are trying to achieve?Chelsea B.NinjaTrader Customer Service
Comment
-
Hi Chelsea,
Ok, will clarify. There are two solutions as I see it. Solution 2 is covered in other threads.
Solution 1 conforms to the subject of this thread. A visual model / chart will help.
Please call up symbol $SP500 (S&P500 Cash Index) on a time based chart. Settings: 1 minute, 3 days back, <use instrument settings>, any bar style.
The chart will populate. Hopefully your chart is not updating, therefore the objective is simple: Programmatically load the next tick, and the next, and the next, every 1 second (or less) in order to stay current with the last print of the $SP500 index value. No other functions are required. In essence this is a synthetic data feed.
If your chart is updating then any index/market internal with static data will suffice. Likely candidates are $PCR or $VIX. Also $COMP, $NDX, $NYA, $RUA, $RUI, $RUT, or one of the more esoteric symbols.
Let's assume you have a static chart up. When F5 is pressed the last price updates and the chart is re-populated with all historical data including all ticks generated at the exchange since the last refresh (along with a full refresh of indicator & plot values).
For this use case and solution (rapid next tick loading) there is no purpose behind reloading "all historical data". The data already exists on the chart. There are no plots to refresh. Only the last available value is required, called each 1 second (or less). One indicator will perform a spread calculation once the new tick is present.
At my end Ninjatrader is fed by CQG with CME and NYSE Market Internals enabled. This data does not include the $SP500 value for the spread calculation or $VIX for market sentiment.
Data for these two symbols are fed into Excel via LSEG (formerly Refinitiv). For years I have had to keep an Excel workbook open on the desktop to monitor these symbols and preform the spread calculation. Yes, live data for $SP500 & $VIX are available for Ninjatrader. It would be redundant to subscribe to the same data already being received by Excel. You will deduce "Solution 2" is to somehow feed/import the live Excel data into Ninjatrader.
Bringing us to the ultimate objective: Eliminate Excel. Dedicate all data/charting/trading functions to Ninjatrader.
Once a solution is working, a new Ninjatrader chart will be added containing two data series: $SP500 and ES 12-24 (front month futures contract) and one indicator. The spread is calculated by an indicator Jim created and you embellished (Spread-Indicator-With-Candlesticks). The result is the Premium. ($PREM on some data feeds). Studies by institutional specialists have proven the $PREM value calculated by many data vendors/brokers to be inaccurate, therefore the user needs to calculate the Premium within their own charting platform. To address speed, 10ms precision is needed in an institutional environment but completely unnecessary in this case. A 1 second (or the 230ms refresh rate I have read about) is fast enough. No need for microscopic granularity.
I hope this clarification is sufficient. Thanks for reading.
If solution 2 needs to be explored then I will find an appropriate Excel/Ninjatrader thread.
Comment
-
Hello culpepper,
ForceRefresh() only causes render on the next render pass. This doesn't cause new data to be pulled.
This is used when you are rendering something, and no real-time data is streaming so the chart is not re-rendering.
If you don't have a real time data streaming for the instrument, reloading all historical data would load new historical data on the chart, but ForceRefresh() would not.Chelsea B.NinjaTrader Customer Service
Comment
-
Hello Chelsea,
I appreciate your explanation of ForceRefresh(), in particular what it does NOT do. Apparently ForceRefresh() is not the easy solution I hoped for. Unfortunately, I am not aware of any other class, function, etc. in Ninjatrader 8 that would accomplish a call for the next tick of outside data. I'm a trader, not a programmer. Thus ends my pursuit of a "call next tick" solution.
Instead of chasing ForceRefresh() I should have pursued the obvious (and more robust) solution, the Excel/Ninjatrader API. Seamlessly connecting Ninjatrader to the Microsoft 365 suite has major implications. It also implicates the majors (lol). I'll elaborate on the riddle in the proper thread.
An API or platform to platform connection of some sort is the solution Ninjatrader users need in order to read and/or write data to/from Excel, whatever their purpose may be. Since it's a separate topic I'll start a new and focused discussion soon. Tentatively titled: Pursuing Seamless Desktop Interoperability - Ninjatrader, Excel and External Data.
Thanks again, Chelsea. Your knowledge of the platform saves folks like me from getting tangled in the weeds.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment