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

Simple Strategy with "Buy at Open"

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

    Simple Strategy with "Buy at Open"

    I'm a newbie trying to simulate a very simple strategy with daily prices:

    Buy XYZ stock at the open
    Take Profit at +3%
    Trailing Stop at -1%

    However, I can't figure out how to instruct to EnterLong (or EnterLongLimit) with the day's opening price.

    Is there a simple code example?

    #2
    Hello Caudergo,

    Thank you for you note.

    This would be easy to build using the strategy builder. I have attached a strategy which does what you specify. After you import the strategy you should go to control center>new>NinjaScript Editor. Then select MyCustomStrategy6, (the strategy), which will pull up the strategy builder and you can click next>next to see how the logic was set up.

    To Import a NinjaScript into NinjaTrader 8 do the following:
    From the Control Center window select Tools -> Import-> NinjaScript...
    Find the file location.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan! A subsequent question... is there a way to set the initial cash balanced available for investment?

      Comment


        #4
        I get this error: "Current CurrentDayOHL only works on intraday levels."
        I'm trying to use daily prices... is it possible?

        If I try it using minutes, the error disappears but I still get no trades.

        Comment


          #5
          Hello Caudergo,

          To set the cash value of an account, you could click on the accounts tab of the control center, right click edit account and revise the initial size. If this is not the initial cash balance you are referring to please provide more information on what it is exactly you are trying to do.

          I have revised the initial strategy I posted and used IsFirstBarOfSession to set a price variable for which I then pass to the enterlonglimit method. I also used a different syntax for enterlonglimit, which submits a good till cancel order, which prevents the order from being canceled if the entry conditions no longer evaluate to true.

          Please let us know if you need further assistance.
          Attached Files
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            I'm really sorry but it seems like it isn't working as expected, as Bars.IsFirstBarOfSession is always false... I tried with several stocks and futures and different time periods. Am I doing something wrong on my side?

            Comment


              #7
              Hello caudergo,

              I have revised the strategy to add a 1 minute secondary data series for which I set the open to a variable from within and submit a long entry order on.

              Please let us know if you need further assistance.
              Attached Files
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Still nothing... BarsInProgress is always 0 and Bars.IsFirstBarOfSession is always false.

                Comment


                  #9
                  Hello caudergo,

                  I am unable to replicate, both on an intraday and daily data series I'm seeing historical trades when the strategy is applied.

                  In the support department at NinjaTrader we do not create, debug, or modify code for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.

                  You can also contact a professional NinjaScript Consultants who would be eager to create or modify this script at your request or assist you with your script. Please let me know if you would like our business development follow up with you with a list of professional NinjaScript Consultants who would be happy to create this script or any others at your request.

                  Please let us know if you need further assistance.
                  Attached Files
                  Alan P.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello NinjaTrader_AlanP ,
                    Thank you for your post!

                    I can ask you for an e-mail professional NinjaScript Consultants?
                    For to create this script or any others at my request.

                    Alex .

                    Comment


                      #11
                      Hello Alex,

                      This is Ryan L. from the NinjaTrader Ecosystem responding on behalf of my colleague Alan.

                      You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!

                      This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

                      Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
                      Ryan L.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bmartz, 03-12-2024, 06:12 AM
                      4 responses
                      31 views
                      0 likes
                      Last Post bmartz
                      by bmartz
                       
                      Started by Aviram Y, Today, 05:29 AM
                      4 responses
                      12 views
                      0 likes
                      Last Post Aviram Y  
                      Started by algospoke, 04-17-2024, 06:40 PM
                      3 responses
                      28 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      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