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 wont remain synced.

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

    Strategy wont remain synced.

    Hey everybody,

    I have a little problem. I've got a strategy, and its great, but there's a hitch. For some reason the position and acct position wont remain synced. I'm not doing any discretionary trading, so its not getting thrown off there. Basically if Im long 2 lots, and the signal is given to go short 2 lots, then it will close the 2 long and short 4 more lots, or vice versa. Does anyone have any ideas? I have the order management set to default quantity so the order quantities should be the same across the board, right?

    #2
    Hello,

    Thank you for the post.

    I wanted to check, are you both Exiting and Entering in the same condition?

    What this sounds like to me is that you are Exiting but also Entering which is calling a Reversal.
    Essentially you exit bringing you flat but because the Entry is reading that the position is still short, it exits by 4 to exit and enter 2 in the opposite direction. This brings you to 4 in the opposite direction.

    Without seeing the code this is only a speculation.

    If this is what is happening, the solution could be to only Exit, then wait for the bar to close and then enter on the next bar. Or you could not exit and call the opposite entry if you are trying to Reverse the position which will both exit and enter.

    If you can provide the script that would be helpful to see how the logic is currently set up to better understand what may be happening.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey Jesse,

      Thank you for the reply. Yes it is entering and exiting on the same condition. So I need to remove the exit order? Right now I have code like this :
      // Set 1
      if ((Close[0] > Close[1])
      && (Close[1] > Close[2]))
      {
      EnterShort(Convert.ToInt32(DefaultQuantity), "");
      ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
      }
      // Set 2
      if ((Close[0] < Close[1])
      && (Close[1] < Close[2]))
      {
      EnterLong(Convert.ToInt32(DefaultQuantity), "");
      ExitShort(Convert.ToInt32(DefaultQuantity), "", "");
      }

      Comment


        #4
        Hello,

        Yes, in this case, if you will be reversing you should just use the opposite Entry order method.

        So if you were Short, you would call EnterLong to reverse to long. This will both exit and enter into the new direction.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks Jesse!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Waxavi, Today, 02:10 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Kaledus, Today, 01:29 PM
          5 responses
          13 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Waxavi, Today, 02:00 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by alifarahani, Today, 09:40 AM
          5 responses
          23 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X