Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Profit Targets with EOD data in Backtesting

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

    Profit Targets with EOD data in Backtesting

    Hi, Forgive me if this is a naive question or it's already been answered, I'm new to NT7, though I've been coding strategies for various platforms for some time. I was running a back test using a fairly simple short filter on EOD data that requires a 2% profit target. However, in the back test, the profit target never seems to be met. i.e. When a trade exits, it's never at 2%. It's as if the back test doesn't monitor the intra-day movements to see if the stock dropped 2%, instead it only seems to exit the next day. Any help getting this working as expected? I'm just using a simple SetProfitTarget(CalculationMode.Percent, 2); in the Initialize function. Thanks in advance for any help.

    #2
    snozzberries,

    You would need to add intra-bar granularity for this to occur.

    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


    It would also require a data provider that offers historical intra-bar data.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. I use TD Ameritrade, not sure if they offer intra-day or not. Any suggestions? And, I didn't know TS offered an API for .NET?
      Originally posted by NinjaTrader_AdamP View Post
      snozzberries,

      You would need to add intra-bar granularity for this to occur.

      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


      It would also require a data provider that offers historical intra-bar data.

      Comment


        #4
        snozzberries,

        I am not sure about TS API. You can use TS as a data provider for NinjaTrader.

        TDA does offer historical minute data you could use to simulate down to the minute level.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Maybe I should explain a little bit better... Basically I have a set of criteria, based on EOD data, that I use to enter short into a stock. Then, I look for a 2% profit target, or I exit if the daily RSI crosses below a certain point any day after the initial position entry. I'd only like to enter a position from about 3:30 - 4 pm. The profit target can be hit at anytime during the following days, but I would only like to exit if the daily RSI crosses below a certain point from 3:30 - 4 pm. Sort of like you were trading on actual EOD data, but entering/exiting just before the market closes. Make sense? I'm not sure how to code/back test this with NT7. This is what I got so far:

          Code:
                  protected override void Initialize()
                  {
                      // Not exactly sure what this does, other than graph a 5-minute bar chart?
                      Add(PeriodType.Minute, 5);
          
                      // Exit with a 2% profit anytime after you enter your position.
                      SetProfitTarget(CalculationMode.Percent, 2);
          
                      CalculateOnBarClose = true;
                  }
          
          
                  protected override void OnBarUpdate()
                  {
                      
                      //When the OnBarUpdate() is called from the primary bar series (1 day series in this example), do the following:
                      if (BarsInProgress == 0)
                      {
          
                          // If the current day's daily RSI(15) > 95 enter short.
                          if (RSI(15, 0)[0] > 95 && Volume > 50000)
                          {
                              EnterShort(5,1000,"S5");
                          }
                          // If the current day's daily RSI(10) < 50, exit your position.
                          else if (CrossBelow(RSI(10, 0), 50, 1))
                          {
                              ExitShort(5,1000,"ES5","S5");
                          }
                      }
                      
                      // When the OnBarUpdate() is called from the secondary bar series, do nothing.
                      else
                      {
                          return;
                      }
                      
              }
          Last edited by snozzberries; 05-06-2012, 06:46 PM.

          Comment


            #6
            Snozzberries,

            The line below :

            CalculateOnBarClose = true;

            Will cause the strategy to only perform logic on the closing of a bar. So if you are using daily bars, the logic would only ever occur after each bar closes. In backtesting, CalculateOnBarClose is automatically set to true essentially. This is why you would need intrabar granularity to get data to backtest properly according to your strategy description you gave me.

            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


            As far as using times to determine exit conditions, here is a reference sample on using a time filter.

            Adam P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rocketman7, Today, 02:12 AM
            7 responses
            31 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by guillembm, Yesterday, 11:25 AM
            3 responses
            16 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by junkone, 04-21-2024, 07:17 AM
            10 responses
            149 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by tsantospinto, 04-12-2024, 07:04 PM
            6 responses
            101 views
            0 likes
            Last Post tsantospinto  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            7 responses
            28 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X