Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting data

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

    Backtesting data

    Hi,
    I am new here and i would like to have some help with backtesting historical data. I set my conditions and everything is ok but entries and exits are enter next day. Please, I need some help with this to make enter and exit market same day my conditions are met.

    Thanks very much
    Bill

    #2
    Hello Bill,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    Backtesting is performed on Historical Bars, this means that calculations are done on the close of the bar rather than intra-bar.

    However, you can add an additional data series to your strategy to simulate intra-bar fills. For a reference sample of this please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=6652

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hi Patrick, thanks for your help, bellow is my code i need to change.Please can you enter the additional code for me

      Thanks



      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// Enter the description of your strategy here
      /// </summary>
      [Description("Enter the description of your strategy here")]
      public class RSI4 : Strategy
      {
      #region Variables
      // Wizard generated variables
      // 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(RSI(4, 3));
      Add(EMA(200));
      Add(RSI(4, 3));
      Add(RSI(4, 3));
      Add(EMA(200));
      Add(RSI(4, 3));

      CalculateOnBarClose = true;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (CrossBelow(RSI(4, 3), 25, 1)
      && Close[0] > EMA(200)[0])
      {
      EnterLong(DefaultQuantity, "GO LONG");
      }

      // Condition set 2
      if (CrossAbove(RSI(4, 3), 55, 1))
      {
      ExitLong("EXIT LONG", "GO LONG");
      }

      // Condition set 3
      if (CrossAbove(RSI(4, 3), 75, 1)
      && Close[0] < EMA(200)[0])
      {
      EnterShort(DefaultQuantity, "GO SHORT");
      }

      // Condition set 4
      if (CrossBelow(RSI(4, 3), 45, 1))
      {
      ExitShort("EXIT SHORT", "GO SHORT");
      }
      }

      #region Properties
      #endregion
      }
      }

      Comment


        #4
        Hello Bill,

        Thank you for your response.

        While we can provide assistance in developing custom indicators and strategies, we do not provide programming services.

        For information on using multiple time frames and instruments in your code please visit the following link: http://www.ninjatrader.com/support/h...nstruments.htm

        If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
        Click here for a list of certified NinjaScript Consultants

        We also have Premium Paid Educational events where you will join a NinjaScript expert for a pair of 6-8 hour long intensive courses designed to provide you with in-depth training on how to create, test and deploy fully automated strategies: http://www.ninjatrader.com/PremiumEducation.php

        Please let me know if you have any questions.

        Comment


          #5
          Ok,
          I need to know then if i can use intrabar technique to change entry and exit in case i have only end of the day data.

          Comment


            #6
            Hello vapapa1,

            Thank you for your response.

            You could setup a StopWatch for your strategy to measure the time elapsed since the last close (EOD): http://www.dotnetperls.com/stopwatch

            This is considered unsupported in NinjaScript as it is general C# programming.

            Please let me know if you have any questions.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by helpwanted, Today, 03:06 AM
            1 response
            8 views
            0 likes
            Last Post sarafuenonly123  
            Started by Brevo, Today, 01:45 AM
            0 responses
            7 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            5 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            242 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            385 views
            1 like
            Last Post Gavini
            by Gavini
             
            Working...
            X