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

Why strategy is NOT holding steady ?

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

    Why strategy is NOT holding steady ?

    Hello NT Team,

    I made a strategy and tested it few times, but still can NOT cross some borders, and I need your advice to do so please.

    1- I disabled "Exit On Session Close" check box to keep the strategy running non stop even after 10 P.M which is the "EndTradingDayLocal", but still the strategy is completely deactivate after 10 P.M and I have to manually restart it every single day at midnight. why is that ?

    2- today at midnight, I opened 7 charts of 7 different markets, and 7 different Sim Accounts that I created purposely for testing, I run the strategy for every single one of them, and today morning I found that some charts hold the strategy working as it should be with TP levels, and SL levels and everything, some of them they kept ONLY an open position without having any TP or SL levels set as pending orders, some of them I found that everything was closed, and only some pending orders are left there, why all that ? please take into consideration that when I'm running the strategy while staying next to it, these things don't happen, so could it be because of "Connection Loss" ? but I already set it to "Keep running" mode, or it could be because of something else ?

    Thank you


    #2
    Hello MohammedAmine,

    Thanks for your post.

    1- I disabled "Exit On Session Close" check box to keep the strategy running non stop even after 10 P.M which is the "EndTradingDayLocal", but still the strategy is completely deactivate after 10 P.M and I have to manually restart it every single day at midnight. why is that ?
    Exit On Session Close will not disable a strategy, it will simply prevent an exit from being triggered before the session close. (The session close is noted by the EOD set in the Trading Hours template that is applied to the data series the strategy runs on.)

    A strategy will disable for the following reasons:
    1. It is disabled manually
    2. It hits a programming error
    3. It hits an Order Error or order rejection, and RealtimeErrorHandling is set to StopCancelClose
    You may check the Log tab of the Control Center when the strategy disables to check log messages to see if #2 or #3 are the case for the strategy disabling.

    2- today at midnight, I opened 7 charts of 7 different markets, and 7 different Sim Accounts that I created purposely for testing, I run the strategy for every single one of them, and today morning I found that some charts hold the strategy working as it should be with TP levels, and SL levels and everything, some of them they kept ONLY an open position without having any TP or SL levels set as pending orders, some of them I found that everything was closed, and only some pending orders are left there, why all that ? please take into consideration that when I'm running the strategy while staying next to it, these things don't happen, so could it be because of "Connection Loss" ? but I already set it to "Keep running" mode, or it could be because of something else ?
    I would recommend reviewing the Log tab of the Control Center to see why the strategies have disabled, and this may also be referenced to see when orders are submitted and filled vs. the time that the strategy disabled (and why the strategy disabled.) It is possible that the strategy was flat with pending orders, then disabled and could not cancel orders, which then filled later to enter your position. This is a hypothetical scenario, but if you cannot figure out how the positions were entered when reviewing your logs, you could write in to platformsupport [at] ninjatrader [dot] com with your log and trace files and as much detail as you can describe leading up to the occurrence (when the strategy disabled, when the orders that entered your position were submitted, and the Order ID's of the orders involved would be helpful for us to help track down in the log and trace files.) You may send those files to me with that detail by writing in with the text "Attn Jim - 3285929" also including a link to this thread.

    Note that if you may need scripting help other than just a review of the log and trace files, you may use our scriptingsupport [at] ninjatrader [dot] com email address.

    Attaching Log and Trace files
    • Open your NinjaTrader folder under My Documents.
    • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
    • Send the 2 compressed folders as attachments in an email to Platform Support or Scripting Support
    • Once complete, you can delete these compressed folders.
    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello NT Team,

      I effectively tracked down the orders and executions in log file trying to figure out what was wrong, I just got the same thing as happened tonight, and when I tracked down things I fouond the following : Plz check the attached images.

      at the first image "Yellow White One", I show you the first 2 orders highlighted in "yellow and green", there u can see that each time and "AT THE EXACT SAME TIME" that Profit Target id Filled, my strategy IMMEDIATELY submit a Cancel request to cancel the StopLoss order, first and second time as u can see it happened perfectly, but the third time "highlighted in yellow and red", u can see that the strategy didn't submit a "cancel order" for stoploss, why ??? I dono ... moreover, it stayed from 14:19 P.M till 14:52 P.M doing nothing till it Filled the StopLoss order why ? because SL order was not cancelled on time. does it mean that the connection was lost between 14:19 and 14:52 ??? well i dono because i was out, but log file didn't log any connection loss between those 2 times.

      One thing that garbed my attention is the third row "highlighted in red in image 1" logged as "Execution", why it didn't happen the same thing for previous orders ? what was different this time ? the strategy is doing a simple iteration to repeat the same thing each time, i dono why sometimes it does funny things like this.

      second image "Black One", u can see the executions, the red one is the one that generated the problem.

      Thank you very much

      Comment


        #4
        Hello MohammedAmine,

        I do not have enough information with what is provided to answer accurately.

        Please write in with the log and trace files and I will be able to give a more thorough review.
        JimNinjaTrader Customer Service

        Comment


          #5
          here u go, plz filter by account "Sim101"
          Attached Files

          Comment


            #6
            Hello MohammedAmine,

            We would really prefer to have the log and trace text files sent in over email for order analysis. We have tools on our end that make these files easier to analyze, and sometimes we need to peek into the trace file for further diagnostics.

            The Profit Target order and Stop Loss submitted from 'Optimized_Martingale/235750640' were not tied with an OCO (One Cancels Other) ID, and the strategy was disabled before the Profit Target filled.

            OCO ID's are automatically applied with Profit Target and Stop Loss orders with Set methods, but Exit methods will use internal logic of the Managed Approach to cancel other Exit orders when a position is closed.

            Since the Profit Target filled after the strategy was disabled, and there was no OCO ID given with the order, it would not automatically cancel.

            If you have other questions that would need log and trace analysis, please send the log and trace files over email, and let us know what you would like us to look into.
            JimNinjaTrader Customer Service

            Comment


              #7
              Hi Jim,

              appreciated man, thank you very much

              1 - but I would like to ask, don't u know why the strategy was disabled ?
              2 - how to tie the "Profit target" and "Stop Loss" orders with a OCO ID

              Thank you

              Comment


                #8
                Hello MohammadAmine,

                I do not see any specific details for the strategy aborting out of order error or programming error. Typically if we see Disabling NinjaScript strategy XXX... without an error message, the strategy would have processed some code that would cause it to disable (like calling SetState(State.Terminated); or CloseStrategy() or the strategy was disabled externally (for example, clicking the Enable check box on the strategy in the Strategies tab of the Control Center to disable it.)

                If you you think the strategy had disabled on it's own, I may suggest reproducing the occurrence using the Playback Connection so that behavior can be better looked into.

                Playback - https://ninjatrader.com/support/help...l?playback.htm

                OCO ID's are applied to stop and target orders when you use Set methods of the Managed Approach. With The Unmanaged Approach, you can applied OCO ID's freely to any orders you submit.

                SetProfitTarget - https://ninjatrader.com/support/help...ofittarget.htm

                SetStopLoss - https://ninjatrader.com/support/help...etstoploss.htm

                Unmanaged Approach - https://ninjatrader.com/support/help...d_approach.htm

                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                8 responses
                31 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by helpwanted, Today, 03:06 AM
                2 responses
                21 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by DayTradingDEMON, Today, 09:28 AM
                0 responses
                9 views
                0 likes
                Last Post DayTradingDEMON  
                Started by navyguy06, Today, 09:28 AM
                0 responses
                2 views
                0 likes
                Last Post navyguy06  
                Started by rjbtrade1, 11-30-2023, 04:38 PM
                2 responses
                77 views
                0 likes
                Last Post DavidHP
                by DavidHP
                 
                Working...
                X