Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using the phrase "while" on 8.1

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

    Using the phrase "while" on 8.1

    Hi, I’m trying to create a strategy that upon a trigger for a long or short entry, it will place an opposite direction entry, exit it, and then place the actual entry order. The reason why I am experimenting with this is because I’ve had success with this method when trading manually and saw far less chop in the market after placing a trade. The issue I’m having with the code (which was coded by someone else) is that upon placing the strategy on the chart, it causes the chart to freeze and show “calculating” indefinitely. The person who wrote the code has shown that it works on his chart replay, but I have not been able to get it to work for me and the strategy before was fully functional. Can you please review the code below that directly follows a long entry trigger and let me know if something is wrong with the logic or it’s possibly something else. Thank you, Kyle

    Attached Files

    #2
    Hello Kyle,

    Calling Thread.Sleep() freezes the thread. Using sleep is not supported by NinjaTrader.

    Also a while loop that is infinite will use unlimited CPU time and will also freeze the thread.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X