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

Two Exits Created A New Entry/Position

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

    Two Exits Created A New Entry/Position

    My strategy has a Long Entry "LONG". My Strategy has two exits:
    1. ...ExitLong("LONG EXIT #1", "LONG");
    2. ...ExitLong("LONG EXIT #2", "LONG");
    Coincidently both #1 and #2 exits triggered at exactly the same time, exiting the long and entering a short which should not happen. The short entry name is "LONG ENTRY #2". Now all of the short exits are ignored because:

    Reason='SignalName does not have a matching FromEntrySignal to exit'

    How can this scenario of a false entry (with an incorrect signal name) be prevented?

    #2
    Hello ScorpioTravis,

    Thanks for your post.

    You would need to modify your script so that it doesn't allow the logic to make two Exit methods at the same time on the same entry signal.

    Also, you would need to ensure that your short Exit method uses the same FromEntrySignal name as the Short entry order SignalName called 'LONG ENTRY #2'. Otherwise, the Exit method would not tie to the Short Entry order method.

    See this help guide documentation for more information about Managed Approach Order Methods: https://ninjatrader.com/support/help...d_approach.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello ScorpioTravis,

      Thanks for your post.

      You would need to modify your script so that it doesn't allow the logic to make two Exit methods at the same time on the same entry signal.
      That's my question - is there a specific technique for that?

      Also, you would need to ensure that your short Exit method uses the same FromEntrySignal name as the Short entry order SignalName called 'LONG ENTRY #2'. Otherwise, the Exit method would not tie to the Short Entry order method.
      It does. However, in this case, an unwanted short was created and given the name for the long exit. Therefore there is no FromEntrySignal name for the unwanted short.

      Comment


        #4
        Hello ScorpioTravis,

        Thanks for your note.

        You would need to separate the Exit methods in your script. There is no specific technique to use as long as the Exit methods are called in separate conditions. You could consider creating separate Exit method conditions in your script and call 1 Exit method in each condition. That way, you are not calling both Exit methods in the same condition at the same time and on the same bar. For example, see below.

        Code:
        if (Exit condition 1)
        {
            ExitLong("LONG EXIT #1", "LONG");
        }
        
        if (Exit condition 2)
        {
            ExitLong("LONG EXIT #2", "LONG");
        }
        Ultimately, to understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121

        Let us know if we may assist further.



        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello ScorpioTravis,

          Thanks for your note.

          You would need to separate the Exit methods in your script.
          I have that exactly as you show. The issue is that sometimes condition 1 and condition 2, even though completely different, occurred at the close of the same bar. I thought there might be a programming technique to prevent that.

          Comment


            #6
            Hello ScorpioTravis,

            Thanks for your note.

            If you submit two Exits at the same time it would seem likely that both could be filled at the same time. ExitLong() is a sell market order so the first one filled would close the position and the other would then leave you with a short position. Something you could consider is writing the Exit like this: if (Condition 1 || Condition 2) ExitLong(). This way you are only calling ExitLong() one time when either Condition 1 or Condition 2 become true.

            To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

            In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

            See the forum post linked in post #4 for more information about debugging using prints to understand how the strategy is behaving.

            Let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Leeroy_Jenkins, Today, 06:35 AM
            0 responses
            2 views
            0 likes
            Last Post Leeroy_Jenkins  
            Started by moneyexe, Today, 01:38 AM
            3 responses
            17 views
            0 likes
            Last Post bltdavid  
            Started by coviraca, Today, 03:11 AM
            0 responses
            7 views
            0 likes
            Last Post coviraca  
            Started by coviraca, Today, 03:10 AM
            0 responses
            7 views
            0 likes
            Last Post coviraca  
            Started by EmmaaPerkin, Today, 12:29 AM
            0 responses
            7 views
            0 likes
            Last Post EmmaaPerkin  
            Working...
            X