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

Strategy Supertrend multi array

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

    #16
    Hello marubozu79,

    Thanks for your reply.

    Are you using CalculateOnBarClose = false ?

    Paul H.NinjaTrader Customer Service

    Comment


      #17
      Yes sure ,
      otherwise I could not manage the closing of the price in real time << if (Close [0] <Low [1]) then ExitShort; ) >>.

      Comment


        #18
        Hello marubozu79,

        Thanks for your reply.

        The entry orders will be placed multiple times with your strategy when using CalculateOnBarClose = false because your entry conditions remain true for many ticks. An easy solution would be to create an int variable called savedBar and the first time your entry conditions are true you save the current bar number into it. You entry conditions would add a check to see if thee saved bar is not equal to the current bar number. If it is equal then no further entries, at least until the next bar. Example:

        if (your entry conditions && savedBar != CurrentBars[0]) // is the savedBar not equal to the currentbar being processed
        {
        // your entry order
        savedBar = CurrentBars[0]; // save the current bar number to prevent further entries, until the next bar.
        }

        Paul H.NinjaTrader Customer Service

        Comment


          #19
          Hi,
          you confirm that even by entering the control of (savedBar! = CurrentBars [0]), as soon as the order is entered it is immediately deleted.
          What could be the cause ?
          Thanks again

          Comment


            #20
            Hello marubozu79,

            Thanks for your post.

            Please check your "log" tab of the control center for any error messages that may provide a clue.

            If no error messages then all I can suggest is that the order is being removed at the end of the bar if it is not filled and this would be expected in the Managed approach. From the help guide: "By default, orders submitted via Entry() and Exit() methods automatically cancel at the end of a bar if not re-submitted" Link: https://ninjatrader.com/support/help...d_approach.htm

            Alternately (instead of resubmitting the order) you could use the advanced entry order method where you can specify a bool for the parameter liveUntilCancelled, Link: https://ninjatrader.com/support/help...rlonglimit.htm
            Paul H.NinjaTrader Customer Service

            Comment


              #21
              Hi Paul,
              the order is canceled immediately after entering and not at the end of the bar.

              The use of liveUntilCancelled = true solves but the collateral problem is created that orders are kept pending even if the entry conditions are missing.

              Check all the logs again tonight and I'll let you know.
              thanks again for the availability

              Comment


                #22




                good evening Paul,
                after having enabled the "trace order" in the log, I get the following message which shows that after the pending order is entered, a delete occurs immediately.
                protected override void Initialize()
                {
                TraceOrders = true;
                }
                24/06/2019 10:30:00 Entered internal PlaceOrder() method at 24/06/2019 10:30:00: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=1 LimitPrice=12278,0 StopPrice=0 SignalName='' FromEntrySignal=''

                24/06/2019 10:30:00 Cancelled expired order: BarsInProgress=1: Order='2a4c3a64eeae4f538c00cc4cf8076ecf/Replay101' Name='Sell short' State=Working Instrument='FDAX 09-19' Action=SellShort Limit price=12278 Stop price=0 Quantity=1 Strategy='Test1ScalperUnlockTSS' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='2a4c3a64eeae4f538c00cc4cf8076ecf' Gtd='01/12/2099 00:00:00'

                Comment


                  #23
                  Hello marubozu79,

                  Thanks for your reply.

                  Please post your updated code so I can better understand what you are working with.

                  If you prefer not to post your code in public, you are welcome to write into PlatformSupport[at]NinjaTrader[dot]Com, mark the e-mail Atten:Paul , ticket # 2348966. Please attach your source code file and include a link to this thread.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #24
                    good evening Paul,
                    as you told me I sent you the code.

                    I hope there is a solution for this problem of immediate cancellation of the pending order entered.

                    thanks
                    Chris

                    Comment


                      #25
                      Hello Paul,
                      thanks for now.
                      If I remove the array [2] can I therefore leave liveUntilCancelled = false?
                      if I set it to true I will have to go to manage many different Cancel.Order conditions that I am not currently managing.

                      furthermore I ask you if I can condition the "Add (PeriodType.Minute, 5);" method only if the current TF is different from 5min so that I can use the strategy also for example on TF 2min but that still controls the supertrend on TF5min .

                      thank you so much
                      Chris

                      Comment


                        #26
                        Hello marubozu79,

                        Thanks for your reply.

                        No, you will have to continue forward with liveUntilCanceled true and you will have to add code to handling canceling orders as needed.

                        You should be able to add other time frames that are not the same as the chart bars.

                        Paul H.NinjaTrader Customer Service

                        Comment


                          #27
                          Hello Paul,
                          would you have an example of how to send CancelOrder () in relation to using "liveUntilCanceled = true"?
                          Thanks again

                          Comment


                            #28
                            Hello marubozu,

                            Thanks for your reply.

                            I am not sure why but today I was notified of your reply back in 12-18-2019.

                            To answer your question, please see the educational example "SampleCancelOrder" at this link: https://ninjatrader.com/support/help...thod_to_ca.htm
                            Last edited by NinjaTrader_PaulH; 04-06-2020, 07:36 AM. Reason: Corrected link for NT7.
                            Paul H.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by pibrew, Today, 06:37 AM
                            0 responses
                            0 views
                            0 likes
                            Last Post pibrew
                            by pibrew
                             
                            Started by rbeckmann05, Yesterday, 06:48 PM
                            1 response
                            12 views
                            0 likes
                            Last Post bltdavid  
                            Started by llanqui, Today, 03:53 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post llanqui
                            by llanqui
                             
                            Started by burtoninlondon, Today, 12:38 AM
                            0 responses
                            11 views
                            0 likes
                            Last Post burtoninlondon  
                            Started by AaronKoRn, Yesterday, 09:49 PM
                            0 responses
                            15 views
                            0 likes
                            Last Post AaronKoRn  
                            Working...
                            X