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!
See more
See less

Partner 728x90

Collapse

I want to execute on "touch" of the EMA's...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    And as you can see, there were also orders executed after the ema's cross! I have the settings to calculate on 'each tick'

    Comment


      #17
      And everytime this error
      Attached Files

      Comment


        #18
        Hello jamalski,

        Thanks for your note.

        I see that you are using the Strategy Builder to create a strategy that uses CrossAbove/CrossBelow conditions.

        CrossAbove/CrossBelow conditions must use a look back period of 1 or more. If the look back period is set to 1, this will check if the crossover occurred on the previous bar. If the look back period is set to 2, this would check if the crossover condition happens 2 bars prior to the currently forming bar.

        If you would like to have the strategy check if the EMA indicators crossover on the currently forming bar, you would need to use Greater/Less when making the indicator comparison instead of using CrossAbove/CrossBelow conditions.

        As for the error message, please check the Log tab of the Control Center when running your strategy for details about any errors that may occur. What exactly does the error message report in the Log tab of the Control Center?

        Also, add prints to your strategy to debug and understand how the strategy is behaving and submitting orders.

        Below is a link to a forum post that demonstrates how to use prints to understand the behavior of a strategy.
        https://ninjatrader.com/support/foru...121#post791121

        Please let us know if we may assist further.
        Last edited by NinjaTrader_BrandonH; 04-22-2022, 12:01 PM.
        Brandon H.NinjaTrader Customer Service

        Comment


          #19
          I'm having a similar problem.
          I'm trying to make a strategy on EMA cross.
          I select the "oneachtick"
          but into strategy analyzer is visible that the trade enter very very late, probably at bar close.
          so into backtest I decided to use tickreplay, but ninjatrader crash everytime.

          Comment


            #20
            Hello hellboy78,

            Thanks for your note.

            When in historical data (backtest/optimization), only the Open, High, Low, and Close will be available 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' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

            Below is a link to the help guide on Calculate.
            https://ninjatrader.com/support/help.../calculate.htm

            To improve the accuracy of a backtest, you may use Tick Replay along with an added 1-tick series to have logic processed intra-bar and have orders filled intrabar. Tick Replay would be used to have the logic process OnEachTick or OnPriceChange with historical data, but this does not allow for intra-bar order fills. You would need to add a single-tick data series and submit orders to that single-tick data series for a strategy that uses Tick Replay.

            Note that Tick Replay will cause your PC to use more resources and will lead to a performance impact. You could consider testing your strategy over a small set of data, such as 1 or 2 days instead of testing say 20+ days. This will reduce the number of resources needed to process.

            From the Tick Replay help guide page:
            Warning: It is important to note that this property implies that more PC resources are used to calculate your indicators and strategies and as a result will lead to a performance impact.

            Performance Tips to optimize platform performance could be found on this help guide page: https://ninjatrader.com/support/help...ance_tips2.htm

            ​Please reference the SampleIntrabarBacktest example and the following Help Guide links for more information.

            SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm

            TickReplay — https://ninjatrader.com/support/help...ick_replay.htm

            Developing for Tick Replay -
            https://ninjatrader.com/support/helpGuides/nt8/developing_for__tick_replay.htm?zoom_highlightsub= developing+for+tick+replay

            Additional information may be found in this NinjaTrader Forum post —
            https://ninjatrader.com/support/foru...mance?t=102504


            Please let us know if we may be of further assistance to you.​​
            Brandon H.NinjaTrader Customer Service

            Comment


              #21
              what you mean with add "1-tick series" ???

              Comment


                #22
                Hello hellboy78,

                Thanks for your note.

                By 'add a 1-tick series', I mean that you must add a secondary 1-tick data series to your strategy. This could be done by using the AddDataSeries() method.

                See this help guide for information about AddDataSeries() and sample code: https://ninjatrader.com/support/help...dataseries.htm

                Then you would need to submit your orders to that added 1-tick data series in your strategy.

                The SampleIntrabarBacktest reference sample linked in post NinjaTrader 8 demonstrates this conecept.

                Please let me know if I may provide further assistance.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #23
                  Originally posted by NinjaTrader_BrandonH View Post
                  Hello hellboy78,

                  Thanks for your note.

                  By 'add a 1-tick series', I mean that you must add a secondary 1-tick data series to your strategy. This could be done by using the AddDataSeries() method.

                  See this help guide for information about AddDataSeries() and sample code: https://ninjatrader.com/support/help...dataseries.htm

                  Then you would need to submit your orders to that added 1-tick data series in your strategy.

                  The SampleIntrabarBacktest reference sample linked in post NinjaTrader 8 demonstrates this conecept.

                  Please let me know if I may provide further assistance.
                  I don't understan, I use strategy builder, where I should add the 1 tick data series? into "additional data" page? or as code line manually?

                  "Then you would need to submit your orders to that added 1-tick data series in your strategy.​" how? manually? without strategy builder?

                  "The SampleIntrabarBacktest reference sample linked in post NinjaTrader 8 demonstrates this conecept.​" here I don't find any demostration, is just a link to a forum homepage.

                  honestly I don't understand why I have the option to use "oneachtick" if eachtick is not available,
                  doesn't make sense to give the option that doesn't work without an extra coding.

                  Comment


                    #24
                    Hello hellboy78,

                    Thanks for your note.

                    That is correct. The additional 1-tick data series would need to be added in the Additional Data screen of the Strategy Builder.

                    However, to add intrabar granularity to a script, you must manually program the script in the NinjaScript Editor window. This is not possible to accomplish using the Strategy Builder.

                    The SampleIntrabarBacktest_NT8.zip file is an example script attached to that forum post that demonstrates how this could be manually programmed. I am linking this script again below.

                    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


                    We also have a link to the reference sample on the NinjaTrader help guide here:https://ninjatrader.com/support/help...ipt_strate.htm

                    Please review the help guide document on the differences on real-time vs backtest (historical).
                    http://ninjatrader.com/support/helpG...ime_vs_bac.htm

                    Let me know if I may assist further.
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #25
                      I tested the "The SampleIntrabarBacktest_NT8.zip" , no idea what is the strategy, but looks the same as close of bar entry.

                      so for what I understood, oneachtick is not working on strategy builder, I have to manually make changes to the code with intrabar granularity, that cannot be done into strategy builder.

                      I have to add 1-tick data series, but nobody said how to submit orders to that added 1-tick data series in the strategy.

                      if I wanna use market replay to have a better backtest, I have to download each day, one by one, I will spend years just for download datas

                      so basically I'm very disapointed about the platform for create strategy and backtests, useless.

                      it's just for nerds or dreamers

                      Comment


                        #26
                        Hello hellboy78,

                        Thanks for your note.

                        The SampleIntrabarBacktest example script is a reference sample that shows how to add a secondary data series and submit orders to that secondary data series that is added. A similar approach would be done to add intrabar granularity to your script.

                        The Strategy Builder does have limitations compared to manually programming a strategy. Unfortunately, adding this intrabar granularity is a limitation of Strategy Builder strategies and this must be manually programmed into the strategy using the NinjaScript Editor window.

                        The Strategy Analyzer window will allow you to run backtests on historical data. When in historical data only the Open, High, Low, and Close will be available and there will be no intra-bar data. This means actions cannot happen intra-bar, and fills cannot happen intra-bar. 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' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

                        You could consider using High Order Fill Resolution when backtesting which will allow you to set a secondary bar series to be used as the price data to fill your orders. This allows you to bring in more granular data than you are currently running the strategy on. For example, you may have a strategy that you run on "Daily" bars but then want to bring in "Minute" bars for the historical fill algorithm to be based on.

                        The secondary bar series will mimic the 'price based on' setting in your Strategy Analyzer settings. (Ask, Bid, Last)

                        Please note, order fill resolution only affects historical orders and does not affect real-time orders.

                        Below is a link to a forum post that details this.
                        https://ninjatrader.com/support/foru...297#post491297

                        Otherwise, to improve the accuracy of a backtest, you would need to manually program your strategy to add a secondary 1-tick data series and submit orders to that added data series.

                        The Playback connection could be used with Market Replay data to test your strategy instead of the Strategy Analyzer.

                        Yes, only one day of Market Replay data is able to be downloaded at a time and there are up to 90 days of Market Replay data that can be downloaded for an instrument. Trying to download more than 90 days back from the current date will result in an error message.

                        See this help guide page for more information about using the Playback connection: https://ninjatrader.com/support/help...connection.htm

                        We currently have a feature request being tracked for downloading multiple days of Market Replay data simultaneously and I have added your vote to the feature request. This request is being tracked under the number SFT-2943.

                        As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

                        Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

                        Please let us know if we may be of further assistance to you.
                        Brandon H.NinjaTrader Customer Service

                        Comment


                          #27
                          I decided to give up with strategy, it's a waste of time.
                          strategy builder was an help but if cannot do all..............I don't wanna hire coders. thats a waste of money, consider how many times I should adjust a strategy.
                          plus all possible bugs can cost huge money,
                          plus, datas are not good, if I do finally a backtest with ES, all different expirations, continuos contract doesn't work too.

                          so

                          I prefer to do manual trading.

                          don't add my vote to feature request. in years I never saw a change or an update.

                          I'm very disapointed.


                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Jonker, Today, 01:19 PM
                          0 responses
                          1 view
                          0 likes
                          Last Post Jonker
                          by Jonker
                           
                          Started by futtrader, Today, 01:16 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post futtrader  
                          Started by Segwin, 05-07-2018, 02:15 PM
                          14 responses
                          1,791 views
                          0 likes
                          Last Post aligator  
                          Started by Jimmyk, 01-26-2018, 05:19 AM
                          6 responses
                          844 views
                          0 likes
                          Last Post emuns
                          by emuns
                           
                          Started by jxs_xrj, 01-12-2020, 09:49 AM
                          6 responses
                          3,296 views
                          1 like
                          Last Post jgualdronc  
                          Working...
                          X