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

Different starting schemes of a trading system

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

    Different starting schemes of a trading system

    Just a simple system:

    Inputs: direction
    Variables: long or short

    calculate on bar close



    The direction long or short, is set manually, the system buys or sells (long or short) daily on the opening, x no. of contracts until the y maximum no. of contracts is reached. It calculates the money stopp loss and stopp profit every day according to the no. of contracts.

    There is a Re-Entry Rule, once a position is closed, a new one is only started to be built after 3 days.

    I can chose between immediately syncronize or sync once the next signal is triggered. I have set immediately sync.

    BUT !!! when I change the direction f.e. from long to short the system don´t starts with the first leg of the size, but with the position size the system would have at this moment if the new direction was ever been like this.

    Example:

    The position size is 1 contract, maximum 10 contracts. I have closed a position according to a signal that direction changes from Short to Long. I set the variable dir from Short to Long and tick the box with imm. sync. The System should start with 1 contract, but the system starts for example with 6 contracts.

    Thats what I don´t want, it should always start with 1 contract, not with the size of contracts the system would have. .....but don´t know how to set this in strategy builder?

    #2
    Hello pmmkm,

    Thank you for your post.

    So that I may accurately assist you, may I confirm the version of NinjaTrader you are using? I ask because you've posted in the NinjaTrader 7 forum, but the strategy creator in NT7 is called the Strategy Wizard. In NinjaTrader 8 it is called the Strategy Builder. I want to make sure I give you correct information.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Yes I use NT 8 with the Strategy Builder

      Comment


        #4
        Hello pmmkm,

        Thank you for your reply.

        Just a heads up, I've moved this over to the NT8 Strategy Development forum rather than NT7 so we don't confuse anyone.

        When you say you manually choose short or long, do you mean when you set up the strategy preferences?

        Would you be able to provide a reduced version of your strategy so I may test the behavior on my end? Alternatively, would you be able to post some screenshots of your exit and entry logic?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hi Kate,

          thank you for your efforts.

          The system is not deciding for itself if it is long or short. I set this in a variable. The phases of long or short are normally quite long, for several weeks normally.

          I can send you the file ....it is neither a mystery nor a secret :-) .but don´t know how to export it. I will check it. Where to send?

          Comment


            #6
            Ok got it, find it here attached TripleM_Crude.zip

            it is the one for Crude, but they are all the same from the logic
            Attached Files

            Comment


              #7
              Hello pmmkm,

              Thank you for your reply.

              I believe you're running into issues with how strategies sync with your account.

              When you enable a strategy, it's basically processing the historical data on your chart like you're running a backtest up until the most recent bar. These positions are shown on your chart for a few reasons:
              • Position or risk management - if the historical performance isn't ideal, you may want to stop the strategy from firing live orders right away.
              • Processing on historical data can help you manage your strategy should it be disabled and then restarted, for example, in case of a power outage or computer crash.
              • If your strategy is started in the middle of what would be a position it would have been in had it started earlier, it can help keep your strategy from making orders unexpectedly.
              In your case, what is happening is that when you start the strategy, you're already in the middle of a position it would have been in had it been started earlier. Because you have it set to immediately submit and sync, the strategy will automatically submit live orders to bring your account position to what it would be in the strategy had you started the strategy earlier. This is why it's not spacing them out as you'd expect.

              To force your strategy to only process on real time data, so it doesn't start with the historical processing, you can add a check to ensure you're on real time data prior to submitting using the strategy builder:

              Click image for larger version

Name:	2019-06-27_1459.png
Views:	265
Size:	46.4 KB
ID:	1062174

              This way, it begins at the beginning when you start the strategy instead of potentially in the middle of a position.

              Here's a useful link to our help guide section on syncing account positions:



              Please let us know if we may be of further assistance to you.
              Kate W.NinjaTrader Customer Service

              Comment


                #8
                Ok, understand, well, what will happen if I restart the strategy, may be on a power failure, or only if I start the computer new, then I want to have the position as it was before. I mean if I restart the strategy immediately does it start from the position before? Or is it necessary to copy the strategy and start with a version without the state check?

                Thank you!

                Comment


                  #9
                  Hello pmmkm,

                  Thank you for your reply.

                  I would recommend the latter approach - if you're going to restart the strategy after you've started it, and you want it to go right back to where it was, you wouldn't want the State check; you want it to start from your current position.

                  Please let us know if we may be of further assistance.
                  Kate W.NinjaTrader Customer Service

                  Comment


                    #10
                    Hello Kate,

                    that all doesnt work at all.

                    When I add the state check I got no execution .....thats the first I dont understand why

                    If I make one strategy with the check and one without the check there ist also another case that won´t fit. The "rhythm" does not fit. It is not possible to start with a special number of contracts and add every day a default number of contracts what is not the same size as the first default. ......

                    In the properties section I can only add if the size will be set by strategy or by default. If set to strategy there is used either the historical or from zero. If by default I cant start the position with a size I had before, for example after the weekend.

                    An example, where I want to get. ES future, 20 contracts maximum executions 10 times, means 200 contracts max, Stopp Loss is 37.500USD Stopp Profit is 75.000USD

                    1. Once I got the direction signal (f.e. LONG) immediately sync, starting with default size = 20 contracts.
                    2. The money stopp is setting a stopp profit and stopp loss according to the number of contracts and the prices where the stopps should be to reach the targets profit or loss.
                    3. After passing three days we have 60 contracts, the stopps are automatically nearing to the price, depending if raising or falling.
                    4. THEN an event occurs, f.e. a connection failure, power failure etc.. I restart the strategy, and the strategy should resume with the 60 contracts.
                    5. THEN a stopp occurs. The position is zero and the Re-Entry Void becomes valid. Set to 3 days, means on the fourth day it starts again with 20 conctracts.

                    .....so far everything works

                    Then I got the direction signal in the other direction !!!!! The direction SHORT

                    The strategy "assume" that it has been always short and for example if I had been SHORT then it is actually 120 contracts and it starts with 120 contracts, but it should start with the default by strategy starting size = 20 contracts. ....

                    What I need is something like a reset a zero point ???.

                    Comment


                      #11
                      Hello Kate,

                      that all doesnt work at all.

                      When I add the state check I got no execution .....thats the first I dont understand why

                      If I make one strategy with the check and one without the check there ist also another case that won´t fit. The "rhythm" does not fit. It is not possible to start with a special number of contracts and add every day a default number of contracts what is not the same size as the first default. ......

                      In the properties section I can only add if the size will be set by strategy or by default. If set to strategy there is used either the historical or from zero. If by default I cant start the position with a size I had before, for example after the weekend.

                      An example, where I want to get. ES future, 20 contracts maximum executions 10 times, means 200 contracts max, Stopp Loss is 37.500USD Stopp Profit is 75.000USD

                      1. Once I got the direction signal (f.e. LONG) immediately sync, starting with default size = 20 contracts.
                      2. The money stopp is setting a stopp profit and stopp loss according to the number of contracts and the prices where the stopps should be to reach the targets profit or loss.
                      3. After passing three days we have 60 contracts, the stopps are automatically nearing to the price, depending if raising or falling.
                      4. THEN an event occurs, f.e. a connection failure, power failure etc.. I restart the strategy, and the strategy should resume with the 60 contracts.
                      5. THEN a stopp occurs. The position is zero and the Re-Entry Void becomes valid. Set to 3 days, means on the fourth day it starts again with 20 conctracts.

                      .....so far everything works

                      Then I got the direction signal in the other direction !!!!! The direction SHORT

                      The strategy "assume" that it has been always short and for example if I had been SHORT then it is actually 120 contracts and it starts with 120 contracts, but it should start with the default by strategy starting size = 20 contracts. ....

                      What I need is something like a reset a zero point ???.

                      Comment


                        #12
                        Hello pmmkm,

                        Thank you for your reply.

                        Let's tackle the State check first. Would you be able to provide a screenshot showing how you've got your conditions and actions set up with it?

                        I'm a little confused by this: "The "rhythm" does not fit. It is not possible to start with a special number of contracts and add every day a default number of contracts what is not the same size as the first default."

                        Are you changing the number of contracts the strategy should take from day to day?

                        Thanks in advance; I look forward to assisting you further.
                        Kate W.NinjaTrader Customer Service

                        Comment


                          #13
                          The strategy buy or sell every day X number of contracts, X is every day the same
                          Attached Files

                          Comment


                            #14
                            Hello pmmkm,

                            Thank you for your reply.

                            Have you added the State check to all three sets of conditions?

                            ​​​​​​​Also, I'm still not certain what you mean by "The "rhythm" does not fit. It is not possible to start with a special number of contracts and add every day a default number of contracts what is not the same size as the first default." Could you clarify?

                            Thanks in advance; I look forward to assisting you further.
                            Kate W.NinjaTrader Customer Service

                            Comment


                              #15
                              Yes I added fhe state check to all three conditions.

                              I will try to explain in another way what I mean with rhythm

                              ....the system trades

                              LONG 20 ......40......60......80.......100.......120...... ...140.........160..... each day plus 20 contracts

                              OR

                              LONG 20........40.......60........80....STOPP(Loss or Profit) ........0.......0........0..(Re-Entry Rule 3 days) .....20........40.........60.......80

                              if no stopp the system runs to the maximum set to 10 times

                              LONG .20.......40......60 .....#200

                              IF somewhere in between the Signal turn from LONG to SHORT

                              LONG 20 ......40..... .60... ...80......."SHORT" (the LONG Position is closed and
                              I
                              SHORT 20... ...40...... 60...... 80........100.......120.........140.........160... ..

                              SHORT 20.......40.........0.........0. ........0........"120".(the new Shortposition starts with 120 contracts,
                              because the rhythm told the system it is 120 time for. But should start with 20........



                              EDIT: Regarding "no execution" I realized that the execution is only done "On bar close" means on a daily bar that the strategy is executed on the next day. So I have to add a check, that if no position, the strategie is calculated on the next tick. ......​​​​​​
                              Last edited by pmmkm; 07-04-2019, 03:31 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by RookieTrader, Today, 07:41 AM
                              1 response
                              4 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by kujista, Today, 05:44 AM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by elderan, Yesterday, 08:03 PM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by samish18, Yesterday, 08:57 AM
                              8 responses
                              25 views
                              0 likes
                              Last Post samish18  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Working...
                              X