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 not exiting on stop loss/profit target

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

    Strategy not exiting on stop loss/profit target

    I'm using some unmanaged orders and when I run the Strategy Analyzer, it only shows 1 trade without an exit. Not sure why it's not exiting trades. Any help would be appreciated to show what would need to be done to exit the trades. I've attached the strategy to view the code.
    Attached Files
    Last edited by Lumbeezl; 05-05-2018, 11:14 PM. Reason: Add attachment

    #2
    Hello Lumbeezl,

    Thank you for your note.

    I would suggest seeing the following example on multiseries scripts, noting how Bars In Progress is used. Your strategy adds a secondary tick series however doesn’t seem necessary.



    When you apply the strategy in the strategy analyzer you’ll notice your final trade is exiting because the backtest period is ending however there are no exits.

    I would suggest adding prints where your profit targets and stop loss orders are being submitted to confirm they are being submitted.

    For example on line 80 of your strategy,

    Code:
    Print("Stop/PT being submitted");
    I’ve provided a link to a youtube video which covers an example of using prints to understand behavior:

    Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.NinjaTrader 7 is an award winning end to end online ...


    I’ve provided a link covering debugging which you may find helpful.
    Debugging: http://ninjatrader.com/support/forum...ead.php?t=3418

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the response. A few questions. Why is it adding a secondary tick series and how do I get rid of that? I noticed it's not submitting the stop losses/profit targets and is there anything in the code to indicate why it would do that? Did I code them correctly using the unmanaged approach?

      Comment


        #4
        Hello Lumbeezl,

        What is the purpose of the secondary tick series you added?

        When you added print statement sot the script, what did it reveal in regards to why the PT and SL were not submitted?

        The helpguide states the Unmanaged Approach is reserved for very experienced programmers, have you considered working more within the managed approach?


        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          It did not show any PT/SL orders in the print, I'm not sure if I coded it correctly, but it did show the entry in the log. I am pretty experienced in C/C++ and C# isn't much different from what I've coded in NinjaTrader, but I struggle learning the classes, functions, etc.

          I would love to work with the Managed Approach but from my understanding if I want to submit 2 Entry Stop Orders (one short, one long) then I have to work with the Unmanaged Approach. If I could do this in the Managed Approach, I would definitely prefer that.

          Comment


            #6
            Hello Lumbeezl,

            Correct, to work an entry on both sides you'd have to use the unmanaged approach.

            Did you write the strategy you attached? I'm curious why the tick series was added.

            I look forward to your reply.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              I did write it. I wanted to trade on the 500 tick bars so I assumed I coded it correctly. I'm just having an issue with the exits. Not sure why it's not registering the exit trades.

              Comment


                #8
                Hello Lumbeezl,

                If you apply the strategy to a 500 tick bar chart or data series you could remove the added data series and unnecessary updates and considerations necessary for a multi series script.

                Debugging customer code is out of the scope of NinjaScript support however if you’d like I could have someone from our business development team pass over a list of third party developers that you could contact about debugging your code.

                Please let us know if you need further assistance.
                Alan P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by algospoke, Yesterday, 06:40 PM
                2 responses
                23 views
                0 likes
                Last Post algospoke  
                Started by ghoul, Today, 06:02 PM
                3 responses
                14 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                45 views
                0 likes
                Last Post jeronymite  
                Started by Barry Milan, Yesterday, 10:35 PM
                7 responses
                22 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by AttiM, 02-14-2024, 05:20 PM
                10 responses
                181 views
                0 likes
                Last Post jeronymite  
                Working...
                X