Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Analyzer / Backtesting usage questions

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

    Strategy Analyzer / Backtesting usage questions

    Hi, new to NT here and am having some issues relating to writing strategies.

    Currently I am using the wizard, but I will go on to coding them myself when I am more familiar with NT.
    1. If I have a strategy analyzer window open and have run a backtest, then wish to tweak the strategy, it seems that if I use the wizard to edit the strategy, all open strategy analyzers will not see the changes. I need to kill open strategy analyzers and reopen them for them to see the new code. Simply running the backtest again will not result in it using the new code.
    2. Each time I do a backtest, I need to re-enter the backtest parameters (Time frame, data series type daily/weekly etc). This is highly annoying when coupled with issue (1).
    3. When using a data series set to "week", bars always end on a friday. Is there a way to change this?
    4. All my backtests use US dollars, even when the instrument they are using is set to GB Pounds. Is there a way to change this?
    5. Is there a way to add date information to the Trades tab in the backtest result? Some way of telling what date it opened and closed a position would be nice without having to go to the chart and figure it out.
    6. Is there not a way to easily select various date ranges for backtests? For example, it should be easy to select a desired time frame, and have the application automatically select the appropriate time range for you based upon the "Data Series Type" (Daily / Weekly etc) and "Min Bars Required" settings.
      For example, let us say I wish to backtest 2013 with Weekly data and my MinBarsRequired is 1. Some easy way to select the last week of 2012 (Thus satisfying the data for MinBarsRequired) plus the whole of 2013 would be nice.


    When answering these questions, if the issue is a non-factor when writing code manually, please let me know as it may well be worth just ditching the wizard.

    TIA

    #2
    Hello evilC,

    1. If the Strategy Wizard is still open you will need to press the Compile Button at the bottom or continue until the Finish Screen before the changes will take effect.

    After the Strategy has been compiled or the Finish Button is pressed you may just rerun the Backtest by pressing the Backtest button to have NinjaTrader show the changed results.

    2. This is because NinjaTrader will revert them back to the default settings of the variables.

    You may right click inside the Parameters section of the Strategy and select "Set Default for <NameOfScript>" to be able to save the settings of a Strategy so that you do not have to keep changing them. Note that these setting will be the same for All Instrument and Time Frames.

    3. Yes, as this is just the end of the Session template but it is limited to a Sunday to Saturday range, so if this is changed you will be missing some days.

    4. This is not a way to change this, but it is on our feedback list.

    5. You should see a Entry Time Column and Exit Time column that will give this information. If you do not see these columns you may right click inside of this tab, select Grid -> Properties and check the "Entry Time" and "Exit Time".

    6. Unfortunately, you would have to set the dates manually for this.

    Let me know if you have any further questions.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply, I have not had a chance to try out your suggestions yet, but IIRC the answer to (1) is incorrect (for me at least).
      If I have an open backtest and wish to tweak it, if I open the strategy edit wizard, make my changes, then finish the wizard, the existing open backtest window will not pick up the changes. In fact, not only do the new changes take effect, but it totally breaks the code.

      Example:
      Tools > New NinjaScript > Strategy.
      Create a strat "test01" that plots a red diamond on the chart.

      File > New > Strategy Analyzer
      Run backtest on "test01" - red diamonds shown.
      Do not close strat analyzer window.

      Tools > Edit > Strategy > Test01
      Change diamond color to purple.
      Click next until the end, then Finish.

      Tab back into strat window, click "Run Backtest" again.
      No diamonds are shown at all.

      To demonstrate that editing the strat broke it:

      Close strat window.

      File > New > Strategy Analyzer
      Run backtest on "test01" - purple diamonds shown.

      Comment


        #4
        Hello evilC,

        Sounds like the strategy is not running at all. Do you see any error message inside of the Log tab of the Control Center?
        JCNinjaTrader Customer Service

        Comment


          #5
          No, nothing new appears in the log window when I click "run backtest".
          The bars draw, but none of the user-defined stuff shows, and no long / short positions are broken, so I think yeah, the script is not running at all.

          Comment


            #6
            Hello evilC,

            What is your condition to plot the Diamond?

            If you use a condition like Close[0] > Open[0] and then just press the Compile button does this work for you?
            JCNinjaTrader Customer Service

            Comment


              #7
              I am using true == true

              Comment


                #8
                Hello evilC,

                Can you send me your log and trace files in a email, so I may investigate this matter further.

                You will find the log file on your PC in the (My) Documents > NinjaTrader 7 > Log folder.

                The log file will be named "log.YYYYMMDD.txt"

                You will find the trace file on your PC in the (My) Documents > NinjaTrader 7 > Trace folder.

                The trace file will be named "trace.YYYYMMDD.txt"

                You may send them to support [at] ninjatrader [dot] com with a subject line of "ATTN: JC" and reference this thread.
                JCNinjaTrader Customer Service

                Comment


                  #9
                  Done.

                  Thankyou.

                  Oh, and FYI, I was not always using True == True, I think at the start I was using close > open or something simple like that, but later I switched to True == true to "give it the best chance"

                  Comment


                    #10
                    Just wanted update this thread.

                    The issue was that opening up the Strategy Wizard inside of the Strategy Analyzer under the Strategies section.

                    To change code then use it inside of the Strategy Analyzer without having to close and reopen it you would want to open it up inside of the Control Center.
                    JCNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks for taking the time to help me there.

                      Can anyone explain to me exactly how the profitability indicator works?

                      For example, in this image in the first bar I take a long position, and the market goes up. Why then are the dots from the 1st to the 2nd bar red?

                      Comment


                        #12
                        Hello EvilC,

                        Thank you for your response.

                        Would you be able to provide a clearer picture of these bars and the profitable line? I see that it should be green as indicated by the position taken.

                        Comment


                          #13
                          Here you go:
                          This is a simple go long if close[0] > close[1] / go short if the opposite strategy.
                          Green up triangles are where it bets long, red are where it bets short.

                          So surely, in theory, if you have two bars the same color, the dotted line between them should always be green?

                          As you can see, this is clearly not the case.


                          Also, why does the line not fall within all the candlesticks? This is very obvious at the start of the image. When it connects to a candlestick, it seems to connect exactly at the open price, so why does it seem to "miss out" some bars and not connect to them at all?
                          Last edited by evilC; 04-23-2014, 08:12 AM.

                          Comment


                            #14
                            Hello evilC,

                            Thank you for your response.

                            The line is not going to go through each bar, it only connects the entry to the exit. If you buy and the price falls to a lower level than you bought at and then you sell, it would be a loss no matter the color of the candles. If you sell and the price rises to a higher level than you sold and then you buy, it will be a loss as well. So my previous post is incorrect, if we sell and the price rises then the line will be unprofitable.

                            Historically the executions are made after the condition is true, so on the open of the next bar. Depending on the order used to enter and the Historical Fill Processing Fill Type the entries and exits could be at different levels.

                            For information on the Historical Fill Processing please visit the following link: http://www.ninjatrader.com/support/h...a_strategy.htm

                            For information on how trade executions are plotted please visit the following link: http://www.ninjatrader.com/support/h..._are_plott.htm

                            Comment


                              #15
                              Hi Patrick,
                              Ahh, the penny finally drops...
                              I had of course not accounted for the fact that I was calculating on bar close, and since I was operating on daily data, I could not change my position until the market opened the next day. Knowing that the lines were from position open to close, it now all makes sense.

                              Apologies for the senior moment, sorry for wasting your time

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by gbourque, Today, 06:39 AM
                              2 responses
                              14 views
                              0 likes
                              Last Post gbourque  
                              Started by rexsole, Today, 08:39 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post rexsole
                              by rexsole
                               
                              Started by trilliantrader, Yesterday, 03:01 PM
                              3 responses
                              30 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              4 responses
                              26 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Brevo, Today, 01:45 AM
                              1 response
                              14 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X