• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Coffee (KC) futures EOD auto close

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

    Coffee (KC) futures EOD auto close

    Hello,

    We currently testing our strategy in coffee futures (KC symbol on ICE exchange) in market replay. I am coming accords a weird issue. Coffee closes for trading at 1:30pm Eastern Time. If I have a open position, Ninja closes it. Every strategy has standard setting to close at end day, and I have it set to false. It is my custom strategy, but the trade is closed by ninja since my custom logic writes tons of things to output window when it closes the trade. And there is nothing there apart from standard ninja things. Same exact strategy on oil (CL) has no issues, but oil does not close midday, it just does not trade between 5-6pm EST like the rest of products on CME.

    Any help with this issue is very much appreciated.

    Thanks,
    redduke

    #2
    Hello RedDuke,
    Thanks for your post.

    What TIF setting are you using for your orders?

    Do you have TraceOrders set to "true"? What does TraceOrders report in your Output window?

    Is there an error on the Logs tab of your Control Center when this occurs? If so, what does it say?
    JoshNinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      TIF: is GTC

      No errors anywhere, just regular order submissions in Logs tab,

      I will enable trace and check if I can get anything there.

      Regards,
      redduke

      Comment


        #4
        RedDuke,

        Sounds good. While you are doing that also test with the 'SampleMACrossover' strategy with the same settings as your strategy and see if the same exit behavior occurs.
        JoshNinjaTrader Customer Service

        Comment


          #5
          TIF is for active entry & exit orders, not active positions, so it should not apply here.

          What is the value of ExitOnClose?
          What is the value of ExitOnCloseSeconds? <-- less important
          Last edited by bltdavid; 03-07-2019, 05:51 PM.

          Comment


            #6
            Originally posted by bltdavid View Post
            TIF is for active entry & exit orders, not active positions, so it should not apply here.

            What is the value of ExitOnClose?
            What is the value of ExitOnCloseSeconds? <-- less important
            ExitOnClose is false
            Where can I see ExitOnCloseSeconds?

            Thanks

            Comment


              #7
              Trace did not help. There was nothing in output window apart form line form cancelled take profit order. Completely surprised.

              SampleMACrossover had multiple entries and exits but it kept position on at close , however it has no take profit or SL orders.

              Comment


                #8
                Originally posted by RedDuke View Post
                ExitOnClose is false
                Where can I see ExitOnCloseSeconds?
                Did you try printing it?

                Add these lines to OnStartUp,
                Code:
                Print("ExitOnClose="+ExitOnClose);
                Print("ExitOnCloseSeconds="+ExitOnCloseSeconds);
                See also:
                https://ninjatrader.com/support/help...xitonclose.htm
                https://ninjatrader.com/support/help...oseseconds.htm
                Last edited by bltdavid; 03-08-2019, 10:55 AM. Reason: Added ExitOnClose for completeness

                Comment


                  #9
                  If the 'SampleSMACrossover' strategy worked we know that the issue is something with your specific strategy. I'm with bltdavid that you should try printing ExitOnCloseSeconds from your strategy.

                  bltdavid,
                  TIF is for active entry & exit orders, not active positions, so it should not apply here.
                  TIF would certainly apply here or anywhere else there was an open position. That position was opened with an order, and that order had a TIF setting. With a time in force of GTC though it should not exit on close.

                  RedDuke,
                  Every strategy has standard setting to close at end day, and I have it set to false. It is my custom strategy, but the trade is closed by ninja since my custom logic writes tons of things to output window when it closes the trade.
                  What all does NinjaTrader write to your output window when it closes the trade? Please copy/paste that information here.
                  JoshNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_JoshG View Post
                    TIF would certainly apply here or anywhere else there was an open position. That position was opened with an order, and that order had a TIF setting. With a time in force of GTC though it should not exit on close.
                    Ok, thanks.

                    I thought after the order was Filled it reached a terminating state and the TIF setting would be moot.
                    Why does the TIF setting affect an active position?

                    Seems like I could build a position from X number of orders, some of which could be DAY and some
                    of which could be GTC ... if all these orders Filled are you saying the aggregate position is somehow
                    subject to the various TIF settings of the orders that made up the position?

                    I thought TIF applied to orders only, ie, the TIF was effective until the order was executed or cancelled.
                    Are you saying the TIF setting also has an effect after the order has executed?
                    Last edited by bltdavid; 03-08-2019, 11:43 AM. Reason: Better summary question

                    Comment


                      #11
                      The output is always "False 30" for Print(ExitOnClose+" "+ExitOnCloseSeconds);

                      It is False all the way to the end. I will clean up the output to not display my own "crap" and will post it here a bit later, so only Ninja Trace is displayed

                      Comment


                        #12
                        With trace on, nothing at all was printed in output window. I added custom output in OnOrderUpdate method, below are the result that were triggered 2 seconds before market closes at 1:30pm EST.

                        4 lines came out, the format is Method Name, Current Price, Order Status, iOrder object to string

                        OnOrderUpdate: 97.15 Profit PartFilled Order='1648558ddaed4a86bfcdb835ddaeb4cd/Replay101' Name='KCShortProfit' State=PartFilled Instrument='KC 05-19' Action=BuyToCover Limit price=83.65 Stop price=0 Quantity=2 Type=Limit Tif=Gtc OverFill=False Oco='' Filled=1 Fill price=0 Token='1648558ddaed4a86bfcdb835ddaeb4cd' Gtd='1/1/0001 12:00:00 AM'

                        OnOrderUpdate: 97.15 Loss PendingCancel Order='fd770218b03a4babbcfb392af324f4c8/Replay101' Name='KCShortLoss' State=PendingCancel Instrument='KC 05-19' Action=BuyToCover Limit price=0 Stop price=98.65 Quantity=2 Type=Stop Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='fd770218b03a4babbcfb392af324f4c8' Gtd='1/1/0001 12:00:00 AM'

                        OnOrderUpdate: 97.15 Loss Cancelled Order='fd770218b03a4babbcfb392af324f4c8/Replay101' Name='KCShortLoss' State=Cancelled Instrument='KC 05-19' Action=BuyToCover Limit price=0 Stop price=98.65 Quantity=2 Type=Stop Tif=Gtc OverFill=False Oco='' Filled=0 Fill price=0 Token='fd770218b03a4babbcfb392af324f4c8' Gtd='1/1/0001 12:00:00 AM'

                        OnOrderUpdate: 97.15 Filled Order='1648558ddaed4a86bfcdb835ddaeb4cd/Replay101' Name='KCShortProfit' State=Filled Instrument='KC 05-19' Action=BuyToCover Limit price=83.65 Stop price=0 Quantity=2 Type=Limit Tif=Gtc OverFill=False Oco='' Filled=2 Fill price=0 Token='1648558ddaed4a86bfcdb835ddaeb4cd' Gtd='1/1/0001 12:00:00 AM'

                        This is a short trade. I always have take profit and stop loss orders for every position. As you can see my profit target exit limit price is 83.65, the market last traded price was 97.15, and somehow it got triggered. The execution then cancelled stop loss. SampleMACrossover only had open position and no exit orders, where my strategy always has exit orders on. Totally out of ideas.

                        Thank you,
                        redduke
                        Last edited by RedDuke; 03-09-2019, 11:42 AM.

                        Comment


                          #13
                          SampleMACrossover only places a trade and has no exit orders for it. I always have stop loss and profit orders on. Something triggered my profit limit, but the price was nowhere near it.

                          Comment


                            #14
                            bltdavid,
                            You are correct. The TIF would not have any concept of a position. It would only be for limit orders.

                            RedDuke,
                            Can you post a sample script here? I would like to test on my end.
                            JoshNinjaTrader Customer Service

                            Comment


                              #15
                              Hi Josh,
                              Let me develop is quickly, as mine has tons of things. Will post a bit later today.
                              Thanks

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Newtrader101, Today, 05:07 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Newtrader101  
                              Started by Newtrader101, Today, 04:46 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Newtrader101  
                              Started by cupir2, Today, 04:12 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post cupir2
                              by cupir2
                               
                              Started by Newtrader101, Today, 03:50 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Heath  
                              Started by wishing, Today, 03:21 PM
                              2 responses
                              15 views
                              0 likes
                              Last Post wishing
                              by wishing
                               
                              Working...
                              X