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

a little trouble whit my strategy

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

    a little trouble whit my strategy

    hi partners of this forum, im glad for write, in this oportunity i have a trouble that is :


    When we do the tests in the backtesting, all the operations carried out, purchases or sales, that use multiple contracts, configure your stop and your target with the number of contracts that were placed at the time of starting the position, for example, 5 contracts are purchased at 7500.00, of which I am assigned 2 contracts at one price and 3 at another, and a stop and a target of 5 contracts are configured. But in the real market when taking a position of multiple contracts, only the stop and the target are configured with the number of contracts that are executed at the first price level, that is, if we buy 5 contracts at 7500.00 and of those 5 contracts I get 2 in 7500.00 and 3 in 7500.25, the target and stop that are configured, are configured based on the order that gave me the first 2 contracts at 7500.00, as a result of this I would have a position of 5 contracts at a value between 7500.00 and 7500.25 with a stop and a target that would only cover 2 of those 5 contracts, leaving after taking the stop or the target 3 contracts without any kind of exit order.

    What should I do to prevent that from happening?? thanks so much.....

    #2
    Hello simonerg,

    I'm not quite sure that I am understanding.

    Is an order method being called with a specific quantity but the order is not being submitted with that quantity?

    Are you asking how to place multiple orders with different quantities and different stop prices?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      hi Chelsea B. thanks for answer me,

      for example, if I buy in 7000.00 5 quantity, but take 3 first and take the other 2 in 7000.25 assuming that we will take profit target. the first 3 take it at 7005.50 and the other two at 7005.75, given that I take 1 tick above those two, the point is that when taking profits it closes the 5 in this case at 7005.50, leaving without fully covering the gain of the other 3, that happens in real time, when the backtest is done it does not happen and it takes the gains as it is, I would like to know what parameter I must configure so that it takes well as it is the profits or the losses

      Comment


        #4
        Hello simonerg,

        Was 5 supplied as the quantity to the order?

        Did you want to supply a value of 8 to the exit order quantity parameter?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          hi again chelsea thnks,
          look at this:

          enterlong quantity: 5, but the order entry whit 3 in 7000,50 and 7000,75 the 2 missing,

          stop: (3) 6995,50, (2) 6995,75

          TARGET (3) 7005,50, (2) 7005,75, THAT SHOULD BE HAPPEN,, IN FACT IT HAPPENS IN THE BACKTESTING, BUT IN REAL TIME IT DOESN'T HAPPEN,

          it happens like this:
          from the previous example

          enterlong quantity: 5, but the order entry whit 3 in 7000,50 and 7000,75 the 2 missing,

          at the time of taking profit take the 5 quantity in 7005,50 and if was stop take in 6995,75, leaving out those 0.25 in both profit and stop,
          It does not take profit or loss where it should be when it is placed in real time, I would like to know if it is for the type of order, or if I need some specific parameter so that it can take the profit or loss as it should be.

          thaks for ur support..... so much..

          Comment


            #6
            hi chelsea, thank...

            What should I do to make the same thing happen in the backtesting?

            What parameter settings should I use to make the same thing happen in real time?

            Comment


              #7
              Hello simonerg,

              When you mention:
              "enterlong quantity: 5, but the order entry whit 3 in 7000,50 and 7000,75 the 2 missing,"

              Are you asking about a partial fill?

              Was the order submitted with a quantity of 5, but only 3 filled? This would be a part fill.

              Does the Log tab of the Control Center show this order with an order state of PartFilled?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                he chelsea thanks again


                yeah, the problem is that the stop and the target are partially configured too

                and they leave me part of the order without stop and without target


                What should I do so that I can obtain the partial order, the stop and the target are configured for the total position?

                Comment


                  #9
                  Hello simonerg,

                  Thank you for your reply.

                  If I'm understanding correctly, you are submitting an order for 5 contracts, and getting a partial fill on 3 for which you get a stop and target placed for those three and then the stop and target for the other two is not submitting at all?

                  Does the same occur when running the strategy on real time data using the Sim101 account when Tools > Options > Trading > Simulator > Enforce Partial Fills is checked?

                  Do any errors appear related to your stop or target in the Log center of the Control Panel? If so, what is the full text of the error?

                  Thanks in advance; I look forward to assisting you further.

                  Kate W.NinjaTrader Customer Service

                  Comment


                    #10
                    hi kate thanks for ur attention,yes tthis happen but whit a real account and real time too, i save the when this happen, look the log at 9:32 {LOG REMOVED},

                    many some diference about that i use SIM101 / Real Account and happen this, without having enabled the option that you indicated Tools > Options > Trading > Simulator > Enforce Partial Fills is checked?.. is only for Sim101? or real account too??

                    very grateful for the support
                    Last edited by NinjaTrader_Kate; 06-03-2020, 07:19 AM. Reason: Log removed due to personal info

                    Comment


                      #11
                      Hello simonerg,

                      Thank you for your reply.

                      I've removed your log file you posted as it contains your account number, which I'll redact from the following analysis. Here is what I see occurring here:
                      2019-11-21 09:32:01:826|1|32|Order='67c3acb8c1f945b2b0cc84f6e f5a189a/MYACCOUNT' Name='Venta' New state='Submitted' Instrument='NQ 12-19' Action='Sell short' Limit price=0 Stop price=0 Quantity=10 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:01:992|1|32|Order='458516455/MYACCOUNT' Name='Venta' New state='Accepted' Instrument='NQ 12-19' Action='Sell short' Limit price=0 Stop price=0 Quantity=10 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:01:992|1|32|Order='458516455/MYACCOUNT' Name='Venta' New state='Working' Instrument='NQ 12-19' Action='Sell short' Limit price=0 Stop price=0 Quantity=10 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:02:062|1|32|Order='458516455/MYACCOUNT' Name='Venta' New state='Partially filled' Instrument='NQ 12-19' Action='Sell short' Limit price=0 Stop price=0 Quantity=10 Type='Market' Time in force=GTC Oco='' Filled=1 Fill price=8275.5 Error='No error' Native error=''
                      2019-11-21 09:32:02:077|1|32|Order='458516455/MYACCOUNT' Name='Venta' New state='Partially filled' Instrument='NQ 12-19' Action='Sell short' Limit price=0 Stop price=0 Quantity=10 Type='Market' Time in force=GTC Oco='' Filled=9 Fill price=8275.27777777778 Error='No error' Native error=''
                      2019-11-21 09:32:02:085|1|32|Order='458516455/MYACCOUNT' Name='Venta' New state='Filled' Instrument='NQ 12-19' Action='Sell short' Limit price=0 Stop price=0 Quantity=10 Type='Market' Time in force=GTC Oco='' Filled=10 Fill price=8275.25 Error='No error' Native error=''

                      First, we see the entry order for 10 contracts partially fill, first for 1 contract, then 9 again to make the full 10.
                      2019-11-21 09:32:02:110|1|8|Execution='273772454669' Instrument='NQ 12-19' Account='MYACCOUNT' Exchange=Globex Price=8275.5 Quantity=1 Market position=Short Operation=Operation_Add Order='458516455' Time='11/21/2019 9:32 AM'
                      2019-11-21 09:32:02:137|1|16|NinjaScript strategy 'venGyS7nten/185709563' submitting order
                      2019-11-21 09:32:02:140|1|16|NinjaScript strategy 'venGyS7nten/185709563' submitting order
                      2019-11-21 09:32:02:143|1|8|Execution='273772454925' Instrument='NQ 12-19' Account='MYACCOUNT' Exchange=Globex Price=8275.25 Quantity=8 Market position=Short Operation=Operation_Add Order='458516455' Time='11/21/2019 9:32 AM'
                      2019-11-21 09:32:02:144|1|8|Execution='273772455437' Instrument='NQ 12-19' Account='MYACCOUNT' Exchange=Globex Price=8275 Quantity=1 Market position=Short Operation=Operation_Add Order='458516455' Time='11/21/2019 9:32 AM'

                      We then see the initial execution update, followed by the strategy starting to place a stop and target for the first partial fill, then two more execution updates in a row for the second partial fill, so now the system knows all of the entry was filled.
                      2019-11-21 09:32:02:145|1|32|Order='16d20297eb124e76b108fb07e 1ab7d5a/MYACCOUNT' Name='Stop' New state='Submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8284 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:02:152|1|32|Order='543355941d2d4d47b604fc3cd f2a0660/MYACCOUNT' Name='Target' New state='Submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:02:174|1|64|Instrument='NQ 12-19' Account='MYACCOUNT' Average price=8275.25 Quantity=10 Market position=Short Operation=Operation_Add
                      2019-11-21 09:32:02:214|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Accepted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8284 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:02:214|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Working' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8284 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:02:218|1|32|Order='458541105/MYACCOUNT' Name='Target' New state='Accepted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:02:219|1|32|Order='458541105/MYACCOUNT' Name='Target' New state='Working' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''

                      The stop and target for the first part of the partial fill get accepted and start working at the exchange.
                      2019-11-21 09:32:18:093|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Change submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8283.5 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:18:155|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Accepted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8283.5 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:18:155|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Working' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8283.5 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''

                      The initial stop then gets moved to 8283.5.
                      2019-11-21 09:32:31:481|1|32|Order='f8933653947c44b3ab9e16290 ce2921b/MYACCOUNT' Name='Stop' New state='Submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8283.5 Quantity=9 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:31:694|1|32|Order='458600303/MYACCOUNT' Name='Stop' New state='Accepted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8283.5 Quantity=9 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:31:694|1|32|Order='458600303/MYACCOUNT' Name='Stop' New state='Working' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8283.5 Quantity=9 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:53:256|1|32|Order='9e7c24347995484ab8690f27f 50b5457/MYACCOUNT' Name='Target' New state='Submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=9 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:53:321|1|32|Order='458516634/MYACCOUNT' Name='Target' New state='Accepted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=9 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                      2019-11-21 09:32:53:322|1|32|Order='458516634/MYACCOUNT' Name='Target' New state='Working' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=9 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''

                      This ended up being longer than I can post in one post, so I'll continue in the next post.
                      Kate W.NinjaTrader Customer Service

                      Comment


                        #12
                        Previous post continued:

                        We then see a second set of stop and target orders submitted at the same prices for the remaining 9 contracts.


                        2019-11-21 09:34:43:405|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Change submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8275.25 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                        2019-11-21 09:34:43:405|1|32|Order='458600303/MYACCOUNT' Name='Stop' New state='Change submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8275.25 Quantity=9 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                        2019-11-21 09:34:43:517|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Accepted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8275.25 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                        2019-11-21 09:34:43:517|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Working' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8275.25 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                        2019-11-21 09:34:43:518|1|32|Order='458600303/MYACCOUNT' Name='Stop' New state='Accepted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8275.25 Quantity=9 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                        2019-11-21 09:34:43:518|1|32|Order='458600303/MYACCOUNT' Name='Stop' New state='Working' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8275.25 Quantity=9 Type='Stop Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''


                        Both the stop for 1 contract and the stop for 9 contracts get moved to 8275.25.


                        2019-11-21 09:36:40:891|1|32|Order='458418541/MYACCOUNT' Name='Stop' New state='Filled' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8275.25 Quantity=1 Type='Stop Market' Time in force=GTC Oco='' Filled=1 Fill price=8275.5 Error='No error' Native error=''
                        2019-11-21 09:36:40:898|1|32|Order='458600303/MYACCOUNT' Name='Stop' New state='Filled' Instrument='NQ 12-19' Action='Buy to cover' Limit price=0 Stop price=8275.25 Quantity=9 Type='Stop Market' Time in force=GTC Oco='' Filled=9 Fill price=8275.5 Error='No error' Native error=''
                        2019-11-21 09:36:40:898|1|8|Execution='273778321165' Instrument='NQ 12-19' Account='MYACCOUNT' Exchange=Globex Price=8275.5 Quantity=1 Market position=Long Operation=Operation_Add Order='458418541' Time='11/21/2019 9:36 AM'
                        2019-11-21 09:36:40:934|1|8|Execution='273778322189' Instrument='NQ 12-19' Account='MYACCOUNT' Exchange=Globex Price=8275.5 Quantity=9 Market position=Long Operation=Operation_Add Order='458600303' Time='11/21/2019 9:36 AM'
                        2019-11-21 09:36:40:945|1|32|Order='458541105/MYACCOUNT' Name='Target' New state='Cancel submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                        2019-11-21 09:36:40:991|1|64|Instrument='NQ 12-19' Account='MYACCOUNT' Average price=0 Quantity=0 Market position=Short Operation=Remove
                        2019-11-21 09:36:41:010|1|32|Order='458541105/MYACCOUNT' Name='Target' New state='Cancelled' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                        2019-11-21 09:37:12:506|1|32|Order='458516634/MYACCOUNT' Name='Target' New state='Cancel submitted' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=9 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
                        2019-11-21 09:37:12:565|1|32|Order='458516634/MYACCOUNT' Name='Target' New state='Cancelled' Instrument='NQ 12-19' Action='Buy to cover' Limit price=8249 Stop price=0 Quantity=9 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''


                        Finally, both stops fill, the associated targets are cancelled, and you are back in a flat position.

                        If your concern is having the two sets of stops and targets placed at the same price, that's happening because you have StopTargetHandling set to By Entry Execution. In cases where the strategy's entry order is partially filled, StopTargetHandling.PerEntryExecution will result in a new set of stop loss and profit target orders for each entry execution. If you would prefer all of your stops and targets to be placed at the same time within the same order, it is suggested to use StopTargetHandling.ByStrategyPosition:



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

                        Comment


                          #13
                          Hello Katie,


                          very grateful for the attention you have given me, I am going to test the strategy in real time under that parameter you gave me, and post after it happens, we need the strategy to enter the market and make those movements ... thank you. .. as soon as something happens I will report it here

                          Comment


                            #14
                            Hello Katie and Chelsea, very grateful for the support and above all your attention, I did the test according to what was recommended by Katie, and I work for now in real-time demo account, I will place it in the real account, and I hope that already the above does not happen but I trust that it will be so, I am very grateful to NINJATRADER as a company, and you are the admins of the forum for the effort they make to support us here.

                            I wish you the best thank you

                            Comment


                              #15
                              hola buenas noches Kate W. un gusto saludarle, agradeciendo de antemano lo antes aportado, a contiunuacion subo el Log del detalle antes mencionado, pero esta vez con la cuenta en vivo y bajo los parametros que me indicaste (.bystrategyPosition), me gustaria si todo salio como deberia ( con 2 quantity en la ejecucion y si sus salidas en este caso fue tambien igual con los 2) muchas gracias
                              Last edited by NinjaTrader_Kate; 08-11-2020, 07:09 AM. Reason: Removed log file as that contains your account number

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by aa731, Today, 02:54 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post aa731
                              by aa731
                               
                              Started by thanajo, 05-04-2021, 02:11 AM
                              3 responses
                              470 views
                              0 likes
                              Last Post tradingnasdaqprueba  
                              Started by Christopher_R, Today, 12:29 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post Christopher_R  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              166 responses
                              2,237 views
                              0 likes
                              Last Post sidlercom80  
                              Started by thread, Yesterday, 11:58 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post thread
                              by thread
                               
                              Working...
                              X