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

NinjaTrader Strategy Continues to add contracts in opposite directions

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

    NinjaTrader Strategy Continues to add contracts in opposite directions

    Hello,

    I have built a strategy on NT8 and sometimes when it should exit a position and enter another it will close the position and then reverse the other way with 2 contracts. This will continue to pyramid until I take manual action. How can I stop this from occurring? I only want it to take one position at a time.

    I have attached an example. You can see it sold short @ 11654.0 and also sold 2 more short @ 11653.75. Then covered 2 @ 1160.75 and continued to pyramid.

    Please advise. Thank you.


    ​​

    #2
    Hello dgutz15,

    The Strategy Builder uses the managed approach. Do not call an exit order before calling an entry order or the position will double when it reverses or there will be an overfill.

    Call the entry in the opposite direction without calling an exit order to reverse the position.

    Below is a link to a forum post that details.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea, however I believe my entry "sets" are clashing. You can see in the screenshot that the close position order is placed at the same time as the sell short order. Is there any way to delay the sell short order by a few seconds?

      I am not intentionally reversing the position, the strategy is just following the rule set which is triggering a different set of rules.

      Comment


        #4
        Hello dgutz15,

        The Close position order is the order automatically submitted by the managed approach when reversing the position. The forum post I have linked details this.

        You will want to explicitly set the conditions to not evaluate as true at the same time to prevent an entry and an exit to be submitted at the same time.

        As an example if one condition is true when the close is greater than the open, then the other condition would compare the close to be less than the open, so that both cannot be true at the same time.

        To delay an order by a few seconds, the script would need to be unlocked and a 1 second (or 3 second) series be added with AddDataSeries(). Then you would use logic, such as a bool, to submit the order on the next update of the BarsInProgress of the added second series. This would wait for the added series to bar close, 1 second (or 3 seconds) after the condition is true.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I see, so hypothetically if I coded my exits using the 59 second time frame and my entries on the 1 minute time frame this should be avoided then?

          Comment


            #6
            Hello dgutz15,

            Yes, if you were to add a 1 second series and exit at 59 seconds and this immediately fills, then submit an entry 1 second later after the position has changed, it would avoid the issue.

            This would be much more complex than adjusting the conditions in the strategy builder to not evaluate as true at the same time.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            10 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            14 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            14 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,983 views
            3 likes
            Last Post jhudas88  
            Working...
            X