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 NullPointStrategies, Today, 05:17 AM
    0 responses
    48 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    66 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X