• 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

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.
    Patrick H.NinjaTrader Customer Service

    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.
        Patrick H.NinjaTrader Customer Service

        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.
            Patrick H.NinjaTrader Customer Service

            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 gngmpwdws, Today, 09:58 PM
              0 responses
              2 views
              0 likes
              Last Post gngmpwdws  
              Started by darkgreen, Today, 03:35 PM
              1 response
              14 views
              0 likes
              Last Post lmatiukas  
              Started by imalil, Today, 09:46 PM
              1 response
              7 views
              0 likes
              Last Post Epistemophilic  
              Started by SAITON, Today, 09:03 PM
              0 responses
              6 views
              0 likes
              Last Post SAITON
              by SAITON
               
              Started by suprsnipes, Today, 08:26 PM
              0 responses
              5 views
              0 likes
              Last Post suprsnipes  
              Working...
              X