Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Backtesting if bar open and close?

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

    Backtesting if bar open and close?

    Hello,

    I am a newbie NinjaTrader user and just started learning programming.

    Can i program and backtest this below?

    If candle open and close above X price, then enter limit order Y ticks above X price if current market price is above X + Y.

    If candle open and close above X price, enter market order if current price is below X + Y.

    X and Y is certain calculated prices.

    Thank you.

    #2
    Hello simple_goodoboy,

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

    You could in fact program this into a strategy that you could then backtest in the Strategy Analyzer.
    Below are resources for learning NinjaTrader's programming language NinjaScript and an example of what the code would look like in your example.
    Code:
    if (Close[0] > myXprice && Open[0] > myXprice)
    {
        if (Close[0] > myXprice + (myYticks * TickSize))
            EnterLongLimit(myXprice + (myYticks * TickSize));
        else if (Close[0] < myXprice + (myYticks * TickSize))
            EnterLong();
    }
    If you would like to take on learning NinjaScript, we have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.
    A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...stribution.htm

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm

    You will find Reference Samples online as well as some Tips and Tricks for both indicators and strategies:
    Click here to see our NinjaScript Reference Samples: http://www.ninjatrader.com/support/f...splay.php?f=30
    Click here to see our NinjaScript Tips: http://www.ninjatrader.com/support/f...ead.php?t=3229

    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    There is a also a growing library of user submitted custom indicators (100+) that can be downloaded from our support form. Please look in the NinjaScript File Sharing section of our support forum as you may find what you are looking for there: http://www.ninjatrader.com/support/f...splay.php?f=37

    Please let me know if you have any questions.

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.
      .
      Thank you so much PatrickH. I appreciate it the code, help, and recommendations.

      I am confused between programming an indicator vs a strategy. Maybe its the terminology I am not familiar with. Is indicator the same as strategy? I think of indicator as RSI or MACD, and strategy as entire trading plan that may involve an indicator.

      Thanks for the help.

      Comment


        #4
        Originally posted by simple_goodoboy View Post
        Thank you so much PatrickH. I appreciate it the code, help, and recommendations.

        I am confused between programming an indicator vs a strategy. Maybe its the terminology I am not familiar with. Is indicator the same as strategy? I think of indicator as RSI or MACD, and strategy as entire trading plan that may involve an indicator.

        Thanks for the help.
        That would be correct. In NinjaTrader the strategies place and manage orders based on conditions, where as the indicators plot information based on calculations and conditions.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          That would be correct. In NinjaTrader the strategies place and manage orders based on conditions, where as the indicators plot information based on calculations and conditions.
          Thank you Patrick.

          Just so I understand why i am brainstorming my ideas and preparing to code and backtest.

          1. Will a programmed strategy show the entries, exits on the chart? Or if i want to see where the strategy enter and exit, i have to build an indicator to show me this information and a strategy to execute it?

          Basically, before automating a strategy, i would like to backtest it to see if entry and exit or calculating correctly.

          For example, if i want to backtest yesterday market action using a strategy I develop, how can I confirm the strategy took the correct entries I programmed?

          Thank you,
          Last edited by simple_goodoboy; 12-28-2016, 11:44 AM.

          Comment


            #6
            Hello simple_goodoboy,

            Thank you for your response.

            The strategy when enabled on the chart will show it's historical and realtime entries and exits. You can also right click on the strategy on the Strategies tab of the Control Center > select Strategy Performance > and the desired performance report.

            For information on running a strategy please visit the following link: http://ninjatrader.com/support/helpG...strategies.htm

            Please let me know if you have any questions.

            Comment


              #7
              Originally posted by NinjaTrader_PatrickH View Post
              Hello simple_goodoboy,

              Thank you for your response.

              The strategy when enabled on the chart will show it's historical and realtime entries and exits. You can also right click on the strategy on the Strategies tab of the Control Center > select Strategy Performance > and the desired performance report.

              For information on running a strategy please visit the following link: http://ninjatrader.com/support/helpG...strategies.htm

              Please let me know if you have any questions.
              Thank you soo much PatrickH.

              This will be great for me. This way I can see in real time day to day after market close if my entry and exit are per my design strategy basis.

              Thank you,

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Aviram Y, Today, 05:29 AM
              3 responses
              11 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by algospoke, 04-17-2024, 06:40 PM
              3 responses
              26 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by bmartz, 03-12-2024, 06:12 AM
              3 responses
              30 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by gentlebenthebear, Today, 01:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by cls71, Today, 04:45 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X