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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    62 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    34 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    53 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    59 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    48 views
    0 likes
    Last Post CarlTrading  
    Working...
    X