• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to backtest strategy for CandleStickPattern

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

    How to backtest strategy for CandleStickPattern

    How would I use the CandleStickPattern indicator in a strategy? Let's say I want to run a strategy for 1 year of historical data, and place an order every time just the Hanging Man pattern appears. I see that the indicator plots a 1 or 0 depending on whether any pattern is found, but there it nothing for the strategy to know *which* pattern was found on a bar.

    Is this possible to do?

    Is a Plot() object the only thing I can use to backtest in the Strategy Analyzer, or can I use BarSeries or other series as well?

    Thanks!
    Bryan
    cassb
    NinjaTrader Ecosystem Vendor - Logical Forex

    #2
    Hello Bryan,

    Thanks for your post.

    You are correct, the CandleStickPatterns indicator plots 1 no matter what pattern is found.

    You could modify this indicator and make a custom version that plots a different value for each pattern type.

    The plot will be all that can be called from the indicator as it is.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by cassb View Post
      How would I use the CandleStickPattern indicator in a strategy? Let's say I want to run a strategy for 1 year of historical data, and place an order every time just the Hanging Man pattern appears. I see that the indicator plots a 1 or 0 depending on whether any pattern is found, but there it nothing for the strategy to know *which* pattern was found on a bar.

      Is this possible to do?

      Is a Plot() object the only thing I can use to backtest in the Strategy Analyzer, or can I use BarSeries or other series as well?

      Thanks!
      Bryan
      The pattern is an enum, and is an input, exposed as a public parameter. Call the indicator with the correct pattern, and that is the only one that it will identify with a "1".

      Comment


        #4
        Originally posted by koganam View Post
        The pattern is an enum, and is an input, exposed as a public parameter. Call the indicator with the correct pattern, and that is the only one that it will identify with a "1".
        Ah, good idea koganam, thank you!

        And thanks, Chelsea. Can you tell me also whether only Plot values can be used in Strategy Analyzer, or is there a way to use a DataSeries object in a strategy to backtest in SA? In other words, can I have the strategy enter long/short based on a value of "Hammer" or "Doji" if I put those values into a DataSeries?

        Thanks!
        Bryan
        Last edited by cassb; 01-05-2015, 08:25 PM.
        cassb
        NinjaTrader Ecosystem Vendor - Logical Forex

        Comment


          #5
          Hi Bryan,

          Yes, dataseries, boolseries, dateseries, intseries, and stringseries can be made public as well.

          Making a dataseries public is the same as for a plot, similar to how this is done in the MACD indicator for the Avg, and Diff dataseries.

          For example:
          In #region Variables:
          private DataSeries myDataSeries;

          In Initialize():
          myDataSeries = new DataSeries(this);

          In OnBarUpdate() or other method:
          MyDataSeries.Set(100);

          In #region Properties:
          [Browsable(false)]
          [XmlIgnore()]
          public DataSeries MyDataSeries
          {
          get { return Values[1]; }
          }

          http://www.ninjatrader.com/support/h...ries_class.htm
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            OK, so if the series is declared public, then it can be picked up in the Strategy Analyzer? Even string values?
            cassb
            NinjaTrader Ecosystem Vendor - Logical Forex

            Comment


              #7
              Hi Bryan,

              The public data series from an indicator allows for you to call the value from a strategy. So if you want the SMA value, call SMA(period)[0] and this will return the last value from the dataseries.

              If you are asking how to make optimizable variables, this will not be involved with dataseries.

              The Strategy Analyzer will run the code of the strategy and can change the parameters fed to the strategy. It is up to the strategy to make calulations and call dataseries. The Strategy Analyzer is not able to directly call indicators or dataseries, or run logic on its own.

              What is your goal in using these dataseries?
              Last edited by NinjaTrader_ChelseaB; 01-06-2015, 09:19 AM.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                What is your goal in using these dataseries?
                Yes, I understand how the SA works with strategies. What I was thinking is if I could create a DataSeries in the CandleStickPattern indicator with the text of the pattern name as the trigger. Like if a Hangman happens, then the text "Hangman" would trigger the trade.

                Bryan
                cassb
                NinjaTrader Ecosystem Vendor - Logical Forex

                Comment


                  #9
                  Hi Bryan,

                  That would work fine.

                  This would be essentially the same as plotting a number to correspond with the selected pattern type.

                  Again this would be available to the strategy itself as it runs, whether this is running in the Strategies tab of the Control Center, or a Chart, or the Strategy Analyzer.

                  In other words the Strategy Analyzer will not call the pattern, but yes you could use a string series and return a string to the strategy that is running.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    OK, thank you Chelsea!
                    cassb
                    NinjaTrader Ecosystem Vendor - Logical Forex

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by epitoma, Today, 05:21 PM
                    1 response
                    12 views
                    0 likes
                    Last Post NinjaTrader_ShawnB  
                    Started by BatBart, Today, 01:24 PM
                    1 response
                    22 views
                    0 likes
                    Last Post NinjaTrader_Melissa  
                    Started by ezrakoper, Today, 03:05 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by asmmbillah, Today, 02:23 PM
                    1 response
                    17 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by steveg, Today, 02:44 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Heath  
                    Working...
                    X