Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetState(State.Terminated) does not disable the strategy on the Strategies window

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

    SetState(State.Terminated) does not disable the strategy on the Strategies window

    I am using NT 8 beta 11. I have code to disable the strategy if certain conditions are not met.

    The sample code are as followed:

    protected override void OnBarUpdate()
    {
    if (State == State.Historical)
    return;

    if (entryOrder == null && ToTime(Time[0]) >= 90000)
    {
    if (GetCurrentBid() > 50
    && GetCurrentBid() <51
    && longEnabled == true)
    { // Go Long
    entryOrder = EnterLong (1,Name);

    //Print("JQ OnBarUpdate entryOrder = " + entryOrder);
    }
    else
    if (GetCurrentAsk() < ShortMaxEntry
    && GetCurrentAsk() > ShortMinEntry
    && shortEnabled == true)
    // Go Short
    entryOrder = EnterShort (1,Name);
    else
    {
    SetState(State.Terminated);
    Print("Condition not met. Disabling " + Name + " Strategy" + " " + State + " " + ToTime(Time[0]));
    }

    }

    The SetState code does fires and the "Enabled" checkbox does get unchecked, however, when I go to edit the strategy, I get the following message:

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    A sample video of this is provided below:

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    Can someone let me know if this is a bug in NT 8 beta 11 or is my code incorrect to disable the strategy?

    #2
    Hello hotsalami,

    Thank you for writing in.

    I was able to reproduce this on my end and will be submitting this as a bug report to our development team. Thank you very much for catching this!

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    45 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    30 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    99 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    177 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    170 views
    0 likes
    Last Post CarlTrading  
    Working...
    X