is there a script where I can put in the code to reload all historical data after every trade? because when I reload manually the chart and entries/exit are different than what happened in real life.
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
reload all historical data
Collapse
X
-
Hello babouin77,
Thank you for your reply.
While there is a ReloadAllHistoricalData method, this is not supported to be called outside of OnConnectionStatusUpdate and may cause undesired behavior.
https://ninjatrader.com/support/help...oricaldata.htm
The better question is are the order prices/times shown changing from the submission price shown on the log tab?
Keep in mind that reloading all historical data will stop and restart your running strategies. When the strategy is restarted, it won't show you the actual live trades that were taken, it will show you what it calculated as historical trades on that data. When processing over historical data, it's essentially running a backtest, much like if you tested the strategy using the Strategy Analyzer. Fills on the historical data are determined based on 4 data points, OHLC of a bar since that is the only information that is known and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.
Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick'.
Also, here is a link to the differences on real-time vs backtest (historical).
http://ninjatrader.com/support/helpG...ime_vs_bac.htm
Adding intra-bar granularity can help with this.
Intra-bar granularity adds a second data series such as a 1 tick series so that the strategy has finer granularity in the historical data in between the OHLC of the primary series. This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with.
In NinjaTrader 8, there have been two new enhancements so that programmers do not have to manually add this secondary series and code the script to for high accuracy fills (Order Fill Resolution) and for intra-bar actions (TickReplay).
Here is a link to our forums that goes into depth on using Order Fill Resolution and Tick Replay to ensure your backtests are as close to real time results as possible:
https://ninjatrader.com/support/foru...mance?t=102504
High Fill Order Resolution and TickReplay cannot be used together. If it is necessary to have both, it is still possible to add intra-bar granularity to a script in the code itself for order fill accuracy and use TickReplay to update indicators with Calculate set to OnPriceChange or OnEachTick historically.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
-
Comment
-
Hello babouin77,
Thank you for your reply.
Is your PC clock properly synced? I ask because I am seeing differences between the bars on the two charts.
Please use the steps below to change/check your Time Zone and sync the PC clock:- Shutdown NinjaTrader
- Right-click the clock in the lower right corner of your desktop
- Select Adjust date/time
- For Windows 10 click 'Date, Time, and regional formatting' -> Then click 'Additional date, time, and regional settings' -> then click 'Set the time and date'
- Select the 'Internet Time' tab at the top
- Set the server to time.nist.gov and then click Update.
- If the message that appears says successful your PC clock should now be updated.
- If not, select a different server from the Server: drop-down and try again (repeat until one of the servers is successful)
After updating the PC clock, please restart NinjaTrader, then right-click the chart and select Reload All Historical Data. Once complete, please test with the same strategy on real time data without refreshing, take a screenshot, then refresh the historical data and take another screenshot.
Thanks in advance; I look forward to assisting you further.
Kate W.NinjaTrader Customer Service
Comment
-
Hello babouin77,
Thank you for your reply.
The Heiken-Ashi candle presents false information concerning each candle.
Here is how the Heiken-ashi is calculated:
HAClose = ((Open[0] + High[0] + Low[0] + Close[0]) * 0.25); // Calculate the close
HAOpen = ((HAOpen[1] + HAClose[1]) * 0.5); // Calculate the open
HAHigh = (Math.Max(High[0], HAOpen[0])); // Calculate the high
HALow = (Math.Min(Low[0], HAOpen[0])); // Calculate the low
When you place an order it can only fill on real price data.
When you reload the historical data NinjaTrader does not know what the base data is that created the Heiken-Ashi bar and it will process the updated historical data based on the false information presented.
A work around would be to use the indicator HeikenAshi8 in your strategy and use standard bars in the chart/analyzer so that the backtest results are based on real data points and your strategy can use the Heiken-ashi values for the conditional entries.
The HeikenAshi8 indicator can be found on our publicly available User App Share here: https://ninjatraderecosystem.com/use...heiken-ashi-8/
Please let us know if we may be of further assistance to you.
The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.Kate W.NinjaTrader Customer Service
Comment
-
Hello babouin77,
Thanks for your replies.
It's a little late in the day today, but I will work up an example showing how to use the HeikenAshi8 values to calculate indicators from within a strategy. I should have that for you tomorrow.
Thanks in advance for your patience; I look forward to assisting you further.Kate W.NinjaTrader Customer Service
Comment
-
Hello babouin77,
Thank you for your patience.
In looking into the indicators you're using both of these will use the underlying High, Low, Open and Close of the data series to process and you can't just use the HeikenAshi8 indicator as an input since it has 4 plots, for the calculated OHLC of the heiken ashi bars it creates. You'd need a modified version of the indicator. I've created modified versions of these that are hardcoded to use the HeikenAshi8 values and then created an example script you can test that enters long if the ADX plot of the DM indicator is below 21 and submits a stop order that follows the path of the modified Parabolic SAR. I'd take a look at the modified indicators to understand how to use the HeikenAshi8 values to modify similar indicators.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by naanku, Today, 07:25 PM
|
0 responses
2 views
0 likes
|
Last Post
by naanku
Today, 07:25 PM
|
||
Started by milfocs, Today, 07:23 PM
|
0 responses
1 view
0 likes
|
Last Post
by milfocs
Today, 07:23 PM
|
||
Started by PaulMohn, Today, 06:59 PM
|
0 responses
6 views
0 likes
|
Last Post
by PaulMohn
Today, 06:59 PM
|
||
Started by bortz, 11-06-2023, 08:04 AM
|
48 responses
1,748 views
0 likes
|
Last Post
by carnitron
Today, 06:57 PM
|
||
Started by Jonker, 04-27-2024, 01:19 PM
|
3 responses
23 views
0 likes
|
Last Post Today, 05:45 PM |
Comment