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:	159
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 NullPointStrategies, Today, 05:17 AM
        0 responses
        19 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        119 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        63 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        45 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X