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:	166
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 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
        135 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
        69 views
        0 likes
        Last Post PaulMohn  
        Working...
        X