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

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.
    Brandon H.NinjaTrader Customer Service

    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 CortexZenUSA, Today, 12:53 AM
      0 responses
      1 view
      0 likes
      Last Post CortexZenUSA  
      Started by CortexZenUSA, Today, 12:46 AM
      0 responses
      0 views
      0 likes
      Last Post CortexZenUSA  
      Started by usazencortex, Today, 12:43 AM
      0 responses
      2 views
      0 likes
      Last Post usazencortex  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      168 responses
      2,262 views
      0 likes
      Last Post sidlercom80  
      Started by Barry Milan, Yesterday, 10:35 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X