Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit Long Position

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

    Exit Long Position

    I am trying to make a stop to break even on strategy developer. I keep going over all the code and it should work but doesn't.

    I have a bool that turns to false after price goes 10 ticks above my average position price. I print this on the Output window and see that it does for sure go to false. I then have a set where if that bool is false then it will exitlongstopmarket at the averagepositionprice+1. However, when price gets there nothing happens. I reference the entry name and everything but its like nothing is even there and price just goes right under where that order should be.

    Also, am I supposed to see an order placed when price goes above 10 ticks? Because I don't. Nohting is there.

    #2
    Hello Shiner452,

    Thanks for your post.

    If the expected trade(s) are not appearing, this would indicate that the condition to place the order is not evaluating as true or the order is being ignored for other reasons.

    Is the only condition for the exit order that the bool is set to false? Or, do you have other conditions in your exit order condition?

    Do you have any error messages in the Log tab of the Control Center? If so, what do they report?

    In the strategy add prints (outside of any conditions) that print the values of every variable used in your conditions that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window). By adding prints for every variable used in your conditions, you could compare how the conditions are evaluating to determine how the script is behaving and where orders are being placed.

    Also, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    See the educational examples in the forum thread below that my colleague Chelsea has created regarding breakeven and trailing stop using the Strategy Builder.
    https://ninjatrader.com/support/foru...der#post806596

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

    Please let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Actually I figured this out. Turns out I'm the bonehead that had a >= instead of a <= on one of the conditions thus the order wouldn't fire properly. Ugh...live and learn.

      Thanks for taking the time to respond!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      52 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      43 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      47 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X