Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Allowing the strategy for PlayBack and Sim only

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

    Allowing the strategy for PlayBack and Sim only

    I am trying to allow my strategy to run only on PlayBack and Sim. I have this code so far but it does not recognize the name of the account. I have not idea what is the problem. Would you please help me?

    Click image for larger version

Name:	error accountname.png
Views:	161
Size:	11.5 KB
ID:	1112063

    //Account check "Sim101"
    if (Account.Name != "Sim101")
    {
    Draw.TextFixed(this, "BR", "ALGORITHM IS ON TRIAL MODE AND UNLICENSED FOR REAL ACCOUNT", TextPosition.BottomRight);
    PlaySound(NinjaTrader.Core.Globals.InstallDir + @"\sounds\Announcement.wav");
    CloseStrategy("Not Licensed " + Time[0].ToString());
    return;
    }

    //Account check "Playback101"
    if (Account.Name != "Playback101")
    {
    Draw.TextFixed(this, "BR", "ALGORITHM IS ON TRIAL MODE AND UNLICENSED FOR REAL ACCOUNT", TextPosition.BottomRight);
    PlaySound(NinjaTrader.Core.Globals.InstallDir + @"\sounds\Announcement.wav");
    CloseStrategy("Not Licensed " + Time[0].ToString());
    return;
    }

    #2
    Hello Jorge.andres.o,

    Thanks for your post.

    Account.Name will return the name of the account the strategy is using, which is assigned when you apply the strategy.

    Your logic is causing the issue, you have two separate if statement. If the account used is the Sim101 then this statement if (Account.Name != "Playback101") will be true. If the account used is Playback101 then this statement will be true if (Account.Name != "Sim101")

    You need to combine them into one if statement and one set of actions:

    if (Account.Name != "Playback101" && Account.Name != "Sim101") /// if account is not Playback101 AND is not Sim101 then...
    {
    // your actions
    }


    Comment


      #3
      Paul,

      thank you for the fast answer. I will fix it that way. Just making sure I understand the “&&”, does it have to be both true or just one has to be true.

      I thought there was code equivalent to “or”.

      Comment


        #4
        Hello Jorge.andres.o,

        Thanks for your reply.

        Because you are using Not equals you need both sides to be true if account is not Playback101 AND is not Sim101 then.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        43 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        30 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        47 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        38 views
        0 likes
        Last Post CarlTrading  
        Working...
        X