Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple backtest not working

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

    Simple backtest not working

    I have created a simple strategy from the wizard using a channel indicator that buys on crossing above and sells when crossing below. I have set the strategy on a AAPL daily chart and I am not getting any signals. Is there something wrong with the way the wizard set up the code:
    private int lengthMA = 10; // Default setting for LengthMA
    private int lengthATR = 10; // Default setting for LengthATR
    private double offset = 1; // Default setting for Offset
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {
    Add(ddKeltnerChannel(LengthATR, Offset, LengthMA));
    Add(ddKeltnerChannel(LengthATR, Offset, LengthMA));

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(Close, ddKeltnerChannel(LengthATR, Offset, LengthMA).Upper, 1))
    {
    EnterLongStop(DefaultQuantity, 0, "");
    }

    // Condition set 2
    if (CrossBelow(Close, ddKeltnerChannel(LengthATR, Offset, LengthMA).Lower, 1))
    {
    EnterShortStop(DefaultQuantity, 0, "");
    }
    }

    I have a more complex intraday strategy that is also not producing any back-tested results all of the sudden. It used to work fine. What could the problem be?

    #2
    Asing,

    I am happy to assist you.

    You are using "EnterShortStop" and "EnterLongStop". I would suggest using "EnterLong" or "EnterShort" instead.

    I am not familiar with the ddKeltnerChannel indicator so I cannot comment much further. Is it the same as the default one that comes with NinjaTrader?

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      hi Adam, the dd channel is slightly modified, but I actually am working with the NT keltnerChannel and neither is producing signals. I also have a proprietary code that uses intraday bars and it was working until recently. I am trying to do historical backtests and i am not getting any signals at all from any of these strategies.

      Comment


        #4
        Asing,

        Are you wanting to enter market orders on these signals?

        If you could, please post your strategy here. It is located in My Documents / NinjaTrader 7 / bin / custom / strategy.

        I look forward to assisting you in resolving your issue.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          hi Adam, I changed the entries from stops to just vanilla entry and now I am getting signals, My question is how is this executed in real time, as market orders? "Enter Long", Enter Short"

          Comment


            #6
            Asing,

            Yes, these are market orders.

            I am happy you have resolved your issue. Please let me know if you require additional assistance.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Just a question as to how these entries are executed in real time. Enter long is a market order that gets executed on the next bar's open after a signal is generated from the closing of the previous bar?

              Comment


                #8
                The problem that I have now is hat the strategy buys and exits on the same bar. It is the strategy that was posted earlier in this chain

                Comment


                  #9
                  I am wondering if this is related to time zone as this has caused all kinds of problems in the past with charts and strategies . I am trading from Asia time zone, but I am using a a day bar for this backtest and I did not think it would matter, Can you think of any other reason why the strategy would enter and exit at the open of the same bar?

                  Comment


                    #10
                    If I use the sample MA strategy provided by NT the same thing happens whether with daily or intraday data. Enter and exit on the open of same bar.

                    Comment


                      #11
                      Asing,

                      Just a question as to how these entries are executed in real time. Enter long is a market order that gets executed on the next bar's open after a signal is generated from the closing of the previous bar?
                      This depends on what CalculateOnBarClose is set to. If its false, it will submit an order intra-bar and then get filled shortly thereafter. If its set to true then it will be on the open of the next bar since a bar just closed prior. Please be aware that in backtesting COBC = true effectively.

                      The problem that I have now is hat the strategy buys and exits on the same bar. It is the strategy that was posted earlier in this chain

                      I am wondering if this is related to time zone as this has caused all kinds of problems in the past with charts and strategies . I am trading from Asia time zone, but I am using a a day bar for this backtest and I did not think it would matter, Can you think of any other reason why the strategy would enter and exit at the open of the same bar?

                      If I use the sample MA strategy provided by NT the same thing happens whether with daily or intraday data. Enter and exit on the open of same bar.
                      Are you using EnterLong() and EnterShort() now or still using the stop orders? If you recently added a stop-loss or take-profit this could occur.

                      I look forward to assisting you.
                      Last edited by NinjaTrader_AdamP; 01-10-2012, 08:48 AM.
                      Adam P.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Adam, I am only using the Enter Long and Enter Short. And as I said, as a test I used the sample MA strategy provided by NT on an AAPL daily chart and had the same problem of enter and exit on the same daily bar at the same price

                        Comment


                          #13
                          Asing,

                          Please be sure that in the strategy analyzer properties, you are setting the "Time in force" property to "GTC" not "Day".

                          Please let me know if I may assist further.
                          Adam P.NinjaTrader Customer Service

                          Comment


                            #14
                            Yes, it has always been set to GTC.

                            Comment


                              #15
                              Asing,

                              What session template are you using? Could you possibly take a screen shot of all of your settings you have for your back test in the Strategy Analyzer? Could you also please take a screen shot of the chart showing the orders?

                              The complete guide to capturing screenshots on Windows Need to take a screenshot on your Windows PC? Whether you want to capture the full screen or just one window or area, there are several quick and easy ways to take screenshots in...


                              I cannot reproduce your issue on my end with SampleMACrossOver, ExitOnClose = true, Time in Force = GTC, on the ES being back-tested over the last 2 months of data. I get trades over multiple days.

                              I look forward to helping you resolve your issue.
                              Last edited by NinjaTrader_AdamP; 01-10-2012, 09:07 AM.
                              Adam P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, Yesterday, 10:06 AM
                              0 responses
                              22 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              19 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              14 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              41 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X