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

Automated Strategy not placing stop loss on live account

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

    Automated Strategy not placing stop loss on live account

    Hi everyone,

    I developing an automated strategy which works as expected in backtesting on account Sim101 but when I run it on a Live account it does not place stop losses. FWIW the account is linked to rithmic trader. This is how I am entering and placing the orders:

    private int STOP = 7;

    protected override void OnBarUpdate()
    {
    if( myConditionsToEnter )
    {
    enterLongC();
    }
    }

    private void enterLongC()
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "C");
    SetStopLoss(CalculationMode.Ticks, STOP );
    }


    I call the method enterLongC whenever I want to enter a trade, is that a valid way to do it? It is very weird because as I said before it works fine on demo but don`t know what happens on live.

    Attached an image showing a short trade taken without stop loss set.
    Attached Files
    Last edited by dbastidas; 04-22-2020, 08:07 AM.

    #2
    Welcome to the forums dbastidas!

    Set methods will prep NinjaTrader to submit the target/stop once NinjaTrader sees the associated entry order filled. They should be submitted before the entry order is submitted.

    Set methods should be called in State.Configure for static stop loss/profit target orders that should not change. For stop loss/profit target orders that should change with the strategy logic or to place the stop loss/profit target using price action (I.E. placing the order in relation to Open/High/Low/Close data) the Set method should be submitted in OnBarUpdate.

    When using Set methods in OnBarUpdate, the stop loss should be reset to an initial level when the strategy is flat and before the next entry is submitted. Please see the example below for using Set methods in OnBarUpdate.

    SamplePriceModification - https://ninjatrader.com/support/help...of_stop_lo.htm

    We look forward to assisting.

    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim, thanks for your help ,

      I modified the order to submit first the SetStopLoss and then the order but still the stop loss is not placed.


      private void enterLongC()
      {
      SetStopLoss(CalculationMode.Ticks, STOP );
      EnterLong(Convert.ToInt32(DefaultQuantity), "LongL");
      }

      Attached a screen with a just taken trade, again without stop loss. Any ideas why that is happening, do I need to switch to the unmanaged approach?
      Attached Files

      Comment


        #4
        Hello i would like to add to this - in using topstep which uses rithimic ... my stop and limit are not being placed when using a simple ATM strategy from the chart trader panel. Or is an issue with working orders being accepted. On Sim account it is fine. Something to do with the Rithmic adapter?
        Have reported this to topstep also

        Comment


          #5
          We are investigating an ongoing issue with Rithmic Connections where ATM strategies stay active after their position has been closed, but this issue has not been confirmed to affect NinjaScript strategies.

          dbastidas, could you confirm that the issue is seen with this test script using Rithmic? You can modify the Stop's distance if you would like. If so, could you let me know which symbol this was reproduced on?

          I look forward to assisting.
          Attached Files
          JimNinjaTrader Customer Service

          Comment


            #6
            Thanks for info Jim - i submitted a few orders today in the topstep account and the ATM stop and limit came up today. It seems to be intermittent and happened in most cases yesterday and the day before. Is this related or a separate problem?

            Comment


              #7
              Hi Jim,

              I debugged my strategy and was able to fix it. It seems there was a problem with a switch statement I was using to redirect the flow and submit the orders based on my logic. I refactor the logic without using the switch and now is placing the stop.

              Do you know about issues using the switch statement?

              I will run the script and notify you if needed.

              Comment


                #8
                Test script executed. The stop was placed correctly using Rithmic connection.

                I guess my issue was solved, not sure if the issue was the switch statement.

                Thanks again for your help Jim

                Comment


                  #9
                  Hello Jim you may have missed my question since dbastidas replied. Any follow up on this ? It seemed ok yesterday but want to know more on this is important
                  thanks

                  Comment


                    #10
                    Hello soulfx,

                    The issue comes up intermittently because it is dependent on how NinjaTrader receives order, execution and position updates from Rithmic. At this time if you get an ATM strategy that is still active, we would recommend disconnecting/reconnecting, and if the issue still persists after that, we would recommend a rename of the database file to work around. (The database file is located here: Documents\NinjaTrader 8\db\NinjaTrader.sdf. It should only be renamed when the platform is closed.)

                    The issue with Rithmic and ATM strategies is being tracked with the internal ticket ID NTEIGHT-14418.

                    We look forward to assisting.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      I am having similar issues in NinjaTrader 8 having ATM's throw random orders out after my profit targets are reached. I am connected to R-Trader and TopSteptrader as well.

                      Comment


                        #12
                        Hello Pattyking,

                        Thanks for your message.

                        We will want to work with you more closely on this item.

                        Could you reach out to me at platformsupport [at] ninjatrader [dot] com with the text "Attn Jim 2517980" and a link to this thread?

                        Please also include your log and trace files and let us know:

                        1. When exactly this had last happened
                        2. The instrument you were trading on
                        3. A break down of symptoms as you see them. I.E. could you elaborate on "random orders" symptoms and what exactly you see when the issue occurs? The issue we have been tracking has to do with a position update not getting received so the ATM appears to stay active and causes issues with additional orders being submitted. We have been suggesting to disconnect and reconnect as a workaround if these symptoms are seen

                        Attaching Log and Trace files

                        Please follow the steps below to manually attach your log and trace files to your email message.
                        • 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 to your email to platformsupport [at] ninjatrader [dot] com
                        • Once complete, you can delete these compressed folders.
                        We look forward to assisting.
                        JimNinjaTrader Customer Service

                        Comment


                          #13
                          Hi Jim,

                          I have sent files to NT support already.

                          Also note, I tried just placing a basic stop loss today without using an ATM and when the stop was hit there were 2 more buy orders added randomly to the order.

                          As for elaborating on ''random orders'' that would be hard because they all seem to be different and I usually close my positions quickly due to losses at this point.

                          As for connecting and disconnecting, this won't be a solution long term. I need to see what is actually going on here.

                          Thank you,

                          Patrick

                          Comment


                            #14
                            Hello Patrick,

                            We are still investigating these issues and will want to work more closely with clients experiencing these symptoms. The workaround is a temporary solution until the matter gets resolved. We are not suggesting this as a permanent fix.

                            As you have already written in to our support team over email, please continue correspondence with us there.

                            If there are any other users seeing these symptoms, please provide the information from post #12 in a message to platformsupport [at] ninjatrader [dot] com so we can work with you more closely as well.
                            JimNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Gerik, Today, 09:40 AM
                            1 response
                            6 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by RookieTrader, Today, 09:37 AM
                            1 response
                            10 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Started by alifarahani, Today, 09:40 AM
                            0 responses
                            5 views
                            0 likes
                            Last Post alifarahani  
                            Started by KennyK, 05-29-2017, 02:02 AM
                            3 responses
                            1,284 views
                            0 likes
                            Last Post NinjaTrader_Clayton  
                            Started by AttiM, 02-14-2024, 05:20 PM
                            11 responses
                            186 views
                            0 likes
                            Last Post NinjaTrader_ChelseaB  
                            Working...
                            X