Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	137
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
    }


    Paul H.NinjaTrader Customer Service

    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.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GLFX005, Today, 03:23 AM
        0 responses
        1 view
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        11 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        6 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Started by TradeForge, Today, 02:09 AM
        0 responses
        12 views
        0 likes
        Last Post TradeForge  
        Started by Waxavi, Today, 02:00 AM
        0 responses
        2 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Working...
        X