Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

The First Exit Will Sometimes Get Me All Out

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

    The First Exit Will Sometimes Get Me All Out

    Hi, I have a strat going that once i enable it, it will get me in, get a first off, and then get me out of the remaining position. The bot works as it should for like 2 or 3 trades and then randomly during another trade, it goes to get my half my position off and instead it gets me all out. Additionally, it will sometimes get my first off properly and then when it goes to get my 2nd off it will properly get me out but then also put me into a trade with half my normal position in the opposite direction. It's very strange, I wonder if there's a setting I'm not clicking? I was thinking it might be something like the first order not getting filled right away, so it puts in another order, and both get filled? I'm not sure if this is actually the problem just an idea.

    Thank you all for your help!

    #2
    Hello MikePari,

    Thanks for your post.

    Debugging steps would need to be taken to determine how the strategy is behaving and placing orders.

    To understand why the script is behaving as it is, such as placing orders or not placing orders 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).

    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.

    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 me know if I 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

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    95 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    153 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    80 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    54 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    70 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X