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

Prior Bar High Or Low OCO Order

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

    Prior Bar High Or Low OCO Order

    Guys,

    I know this has already been done in this forum. Buy I can't find it. I have done all the seraches I know. Can anyone help. I am very new at programming C# but ok at cut and paste by example.

    I want to do an OCO order to buy or sell short the prior bar as compared to current bar, only have one position open at a time, and set a profit and stop loss bracket around the trade.

    Any help would be appreciated.

    Thanking you in advance.

    jstockman

    #2
    Unfortunately we are unable to implement actual strategies for bandwidth reasons. But maybe the community can contribute.

    We will enhance the list of sample strategies shortly.

    Comment


      #3
      Bandwidth

      Originally posted by NinjaTrader_Dierk View Post
      Unfortunately we are unable to implement actual strategies for bandwidth reasons. But maybe the community can contribute.

      We will enhance the list of sample strategies shortly.
      Dierk,

      What do you mean by bandwidth reasons?

      jstockman

      Comment


        #4
        It means that our current policy is to provide application level support and are unable to provide support at a level where we provide sample code upon request or analyze user code.

        Thanks for understanding.
        RayNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Ray View Post
          It means that our current policy is to provide application level support and are unable to provide support at a level where we provide sample code upon request or analyze user code.

          Thanks for understanding.

          Ray,

          How do you suggest we get answers then if we can't find it on the forum?

          jstockman

          Comment


            #6
            You can get answers to product questions in our forum.

            We will absolutely provide answers to questions related to the operation of our product. To help in the area of programming logic, we are doing the following:

            - Developing a comprehensive reference sample library
            - Developing a "NinjaScript" online live training course
            - Hiring more NinjaScript support engineers

            This is all work in progress and we hope to have these additional resources available to the community sooner than later.

            Thanks for understanding.
            RayNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Ray View Post
              You can get answers to product questions in our forum.

              We will absolutely provide answers to questions related to the operation of our product. To help in the area of programming logic, we are doing the following:

              - Developing a comprehensive reference sample library
              - Developing a "NinjaScript" online live training course
              - Hiring more NinjaScript support engineers

              This is all work in progress and we hope to have these additional resources available to the community sooner than later.

              Thanks for understanding.
              Ray,

              That gives me future hope. Press On!

              jstockman

              Comment


                #8
                jstockman there are two ways to proceed with what you are trying to accomplish. You can use ATM strategies or you can use things like EntriesPerDirection and EntriesHandling to achieve the effect you want.

                For the ATM strategy approach:
                This link will help you on coding your entries http://www.ninjatrader-support.com/H...egyCreate.html.
                This one shows you how to cancel previous orders http://www.ninjatrader-support.com/H...egyActive.html.
                This one shows you how to modify previous orders instead of canceling it http://www.ninjatrader-support.com/H...helpguide.html.
                With ATM strategy, you create the entry and then you can manually manage the stop/profit targets from within any order entry windows.
                Check out the Video library section on ATM strategies on how to maximize its efficiency http://www.ninjatrader-support.com/H...l?VideoLibrary.

                For the non-ATM approach:
                You can use things like EnterLong/EnterShort with this method. What you want to do in the Initialize() section of your code is add two lines.
                Code:
                EntriesPerDirection = 1;
                EntryHandling = EntryHandling.AllEntries;
                Basically what those two lines are doing is forcing NinjaTrader to ignore all additional entry conditions if you already have a position. You can review the exact method of using them with these two links http://www.ninjatrader-support.com/H...Direction.html


                Please note that EntriesPerDirection and EntryHandling DO NOT affect ATM strategies. For ATM strategies you might need to add some programming checks to insure you don't enter while you have a position open. I believe you can use something like this to check if you have a position open or not.
                Code:
                Position.MarketPosition==MarketPosition.Flat
                I am not 100% sure if that will work on ATM strategies, but you can give it a try. You can also have Position.MarketPosition checked against MarketPosition.Long and MarketPosition.Short if you have a need for that.

                Personally I have not experimented much with the ATM strategy approach, but it might be more suitable if you want to manually manage your positions after your strategy enters them. In the non-ATM approach you will need to manually program ExitLong() and ExitShort() at where you want the profit target and where you want the stop loss to be.

                I hope this helps jstockman. If you are still having problems why don't you post up your strategy and I'll take a look and see if I can give you any pointers?
                Last edited by NinjaTrader_JoshP; 08-19-2007, 11:58 AM.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  uacvax,

                  Thank-you for the help. I want to take a look at TRO Trillion using this method.

                  jstockman
                  Last edited by jstockman; 08-19-2007, 12:18 PM. Reason: Too much space

                  Comment


                    #10
                    I've only heard about the TRO Trillion strategy. Never really looked deep into it. Please let me know how it goes.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by Josh View Post
                      jstockman there are two ways to proceed with what you are trying to accomplish. You can use ATM strategies or you can use things like EntriesPerDirection and EntriesHandling to achieve the effect you want.

                      For the ATM strategy approach:
                      This link will help you on coding your entries http://www.ninjatrader-support.com/H...egyCreate.html.
                      This one shows you how to cancel previous orders http://www.ninjatrader-support.com/H...egyActive.html.
                      This one shows you how to modify previous orders instead of canceling it http://www.ninjatrader-support.com/H...helpguide.html.
                      With ATM strategy, you create the entry and then you can manually manage the stop/profit targets from within any order entry windows.
                      Check out the Video library section on ATM strategies on how to maximize its efficiency http://www.ninjatrader-support.com/H...l?VideoLibrary.

                      For the non-ATM approach:
                      You can use things like EnterLong/EnterShort with this method. What you want to do in the Initialize() section of your code is add two lines.
                      Code:
                      EntriesPerDirection = 1;
                      EntryHandling = EntryHandling.AllEntries;
                      Basically what those two lines are doing is forcing NinjaTrader to ignore all additional entry conditions if you already have a position. You can review the exact method of using them with these two links http://www.ninjatrader-support.com/H...Direction.html


                      Please note that EntriesPerDirection and EntryHandling DO NOT affect ATM strategies. For ATM strategies you might need to add some programming checks to insure you don't enter while you have a position open. I believe you can use something like this to check if you have a position open or not.
                      Code:
                      Position.MarketPosition==MarketPosition.Flat
                      I am not 100% sure if that will work on ATM strategies, but you can give it a try. You can also have Position.MarketPosition checked against MarketPosition.Long and MarketPosition.Short if you have a need for that.

                      Personally I have not experimented much with the ATM strategy approach, but it might be more suitable if you want to manually manage your positions after your strategy enters them. In the non-ATM approach you will need to manually program ExitLong() and ExitShort() at where you want the profit target and where you want the stop loss to be.

                      I hope this helps jstockman. If you are still having problems why don't you post up your strategy and I'll take a look and see if I can give you any pointers?

                      Josh,

                      Please confirm my thinking.

                      I can create an ATM strategy using the wizard. When I want engage this ATM strategy I use the above command. (Or is it just the opposite). I create the above strategy and then somehow using the Superdom ( which will show me the trade postion) I manage it manually?

                      Thanks for the clarification.

                      jstockman

                      Comment


                        #12
                        Are you referring to the NinjaScript Strategy Wizard? I do not believe you can automatically create ATM strategies straight from that wizard, but you can definitely use the wizard to create your strategy and then add in the ATM strategy stuff.

                        What happens when you run your NinjaScript strategy with ATM strategies coded inside is it will execute orders that you will be able to manually manage through any of NinjaTrader's order management windows (e.g. SuperDOM).
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by Josh View Post
                          Are you referring to the NinjaScript Strategy Wizard? I do not believe you can automatically create ATM strategies straight from that wizard, but you can definitely use the wizard to create your strategy and then add in the ATM strategy stuff.

                          What happens when you run your NinjaScript strategy with ATM strategies coded inside is it will execute orders that you will be able to manually manage through any of NinjaTrader's order management windows (e.g. SuperDOM).
                          Josh,

                          I get it!

                          Is there a way around limitations on EntriesPerDirection etc.?

                          "ATM Strategies operate in real-time only and will not execute on historical data thus they
                          .Executions resulting from an ATM Strategy that is created from within a NinjaScript
                          automated strategy will not plot on a chart during real-time operation
                          .Strategy set up parameters such as EntriesPerDirection, EntryHandling, ExitOnClose do not
                          apply when calling the
                          AtmStrategyCreate() method"

                          jstockman

                          Comment


                            #14
                            What you could try is just pass around a variable that is 1 when you already have an ATM position open and 0 when it is flat. Basically just have an if statement checking if this variable is 1 or 0 and only allow for a new AtmStrategyCreate() when it is 0.

                            You can use GetAtmStrategyMarketPosition() to determine if you have an ATM strategy position open or not. Just pass along the AtmStrategyId to it and you should be good to go.

                            Last edited by NinjaTrader_JoshP; 09-06-2007, 11:34 PM.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              NinjaScript and ATM Strategy

                              Josh,

                              Thank-you for pointing me in the right direction. I have just read the docs in NT regarding this area. Looks pretty straight forward. The stategy I am heading for is found in the Tradestation Forum under Trillion Dollar. Using daily bars I look to go long on first current bar that crosses above prior day high or go short if crosses below prior days low. The trick is to have one position open either long or short depending what broke open first. TRO sets his profit about 5 and stop about 7. It is kind of backwards to what all the books teach. But the stats bear out good percentages for the trade.

                              I'll keep you posted.

                              Regards,

                              jstockman

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Aviram Y, Today, 05:29 AM
                              3 responses
                              10 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