Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Command Parameter 'SIM101" is unknown

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

    Command Parameter 'SIM101" is unknown

    Hello! I have connected to ATI and am sending through orders successfully - although, the system is having a hard time recognizing the account name - I'm using "Sim101" - is there a number that's associated with the SIM accounts?

    Thanks for your help!​

    #2
    Hello Mabaturova,

    There is not a different name for the sim101 account, if you are using the ATI you would also need to make sure a default account is selected in the automated trading settings menu.

    Comment


      #3
      Hi Jesse!

      Thank you so much for your quick response. I made the adjustment and removed Sim101 from any part of the code - I am receiving this error message:

      ❌ Error: Unable to retrieve last price.

      so let me run a few things and see if i can fix that and will come back with any questions.
      Last edited by Mabaturova; 03-12-2025, 04:29 PM.

      Comment


        #4
        Hi Jesse & Team,

        So I fixed the price and removed the need for an account, hoping to have it land on the default account (SIM101) - and am still getting these errors. I tried putting it back to Sim101 -


        Click image for larger version

Name:	image.png
Views:	172
Size:	18.4 KB
ID:	1337570
        Here is the cleaned up code (no identifiers):

        using System;
        using System.Threading;
        using MailKit.Net.Imap;
        using MailKit;
        using MimeKit;
        using MailKit.Search;
        using NinjaTrader.Client;

        class Program
        {
        private static Client ntClient = new Client();
        private static ImapClient imapClient = new ImapClient();
        private static readonly int checkInterval = 2000;

        // Set your NinjaTrader account name exactly as it appears in the Accounts tab
        private static string account = "Sim101";

        static void Main(string[] args)
        {
        // Placeholder Gmail credentials (change to your actual or environment variables)
        var emailUser = "[email protected]";
        var emailPass = "myAppPasswordHere";

        Console.WriteLine("Starting Minimal ATI Test...");

        try
        {
        // 1) Connect to Gmail IMAP
        imapClient.Connect("imap.gmail.com", 993, MailKit.Security.SecureSoc****ptions.SslOnConnect) ;
        imapClient.Authenticate(emailUser, emailPass);
        Console.WriteLine("IMAP Connected.");
        }
        catch (Exception ex)
        {
        Console.WriteLine($"IMAP Error: {ex.Message}");
        return;
        }

        // 2) Open Inbox
        var inbox = imapClient.Inbox;
        inbox.Open(FolderAccess.ReadWrite);

        while (true)
        {
        try
        {
        Console.WriteLine("\nChecking for unread emails...");
        var uids = inbox.Search(SearchQuery.NotSeen);
        if (uids.Count > 0)
        {
        // Just take the most recent unread for demonstration
        var latestUid = uids[uids.Count - 1];
        var message = inbox.GetMessage(latestUid);

        Console.WriteLine($"Found Unread Email: Subject = {message.Subject}");

        // === Placeholder order action ===
        // In real usage, you'd parse email content or subject to decide BUY vs SELL, etc.
        PlaceNinjaTraderMar****rder("BUY", 400, 800);

        // Mark the email as read so it won't trigger repeatedly
        inbox.AddFlags(latestUid, MessageFlags.Seen, true);
        Console.WriteLine("Email marked as read.");
        }
        else
        {
        Console.WriteLine("No new emails.");
        }
        }
        catch (Exception ex)
        {
        Console.WriteLine($"Main Loop Error: {ex.Message}");
        }

        Thread.Sleep(checkInterval);
        }
        }

        /// <summary>
        /// Simple ATI example: Place a market order, then a STOP for SL and a LIMIT for PT.
        /// </summary>
        private static void PlaceNinjaTraderMar****rder(string action, double stopLossDollars, double profitTargetDollars)
        {
        Console.WriteLine($"Placing {action} order on account: {account}");

        // 1) Subscribe to Market Data
        try
        {
        ntClient.SubscribeMarketData("NQ 06-25");
        Thread.Sleep(500); // wait for data
        }
        catch (Exception ex)
        {
        Console.WriteLine($"SubscribeMarketData Error: {ex.Message}");
        return;
        }

        // 2) Get last price
        double entryPrice = ntClient.MarketData("NQ 06-25", 0);
        if (entryPrice <= 0)
        {
        Console.WriteLine("Error: entryPrice <= 0");
        return;
        }

        // 3) Unsubscribe
        try
        {
        ntClient.UnsubscribeMarketData("NQ 06-25");
        }
        catch (Exception ex)
        {
        Console.WriteLine($"UnsubscribeMarketData Error: {ex.Message}");
        }

        // Convert dollars => ticks => final price
        double tickSize = 0.25;
        double tickValue = 5.00;
        double stopLossTicks = stopLossDollars / tickValue;
        double profitTargetTicks = profitTargetDollars / tickValue;

        double stopLossPrice = (action == "BUY")
        ? entryPrice - (stopLossTicks * tickSize)
        : entryPrice + (stopLossTicks * tickSize);

        double profitTargetPrice = (action == "BUY")
        ? entryPrice + (profitTargetTicks * tickSize)
        : entryPrice - (profitTargetTicks * tickSize);

        // 4) Place Market Order
        int marketCode = ntClient.Command(
        account,
        "PLACE",
        "NQ 06-25",
        action,
        1,
        "MARKET",
        0.0,
        0.0,
        "DAY",
        "", "", "", ""
        );
        Console.WriteLine($"Market order result code: {marketCode}");
        if (marketCode != 0) return;

        Thread.Sleep(500);

        // 5) Stop-Loss
        int slCode = ntClient.Command(
        account,
        "PLACE",
        "NQ 06-25",
        action == "BUY" ? "SELL" : "BUY",
        1,
        "STOP",
        0.0,
        stopLossPrice,
        "DAY",
        "", "", "", ""
        );
        Console.WriteLine($"Stop-Loss result code: {slCode}");

        // 6) Profit Target
        int ptCode = ntClient.Command(
        account,
        "PLACE",
        "NQ 06-25",
        action == "BUY" ? "SELL" : "BUY",
        1,
        "LIMIT",
        profitTargetPrice,
        0.0,
        "DAY",
        "", "", "", ""
        );
        Console.WriteLine($"Profit Target result code: {ptCode}");
        }
        }

        ​------------------------------------------------------------------------------------------------

        Why does Sim101 appear as unknown in the logs, or how to properly pass the account if an empty string is also failing?
        Attached Files
        Last edited by Mabaturova; 03-12-2025, 05:58 PM.

        Comment


          #5
          Hello Mabaturova,

          It looks like the OIF string has the incorrect parameters. You need the command parameter first and then the account, you have the account and then the command.

          It should look like this:

          PLACE;<ACCOUNT>;<INSTRUMENT>;<ACTION>;<QTY>;<ORDER TYPE>;[LIMIT PRICE];[STOP PRICE];<TIF>;[OCO ID];[ORDER ID];[STRATEGY];[STRATEGY ID]

          You need all the commas but the values with brackets [] don't need a value, the ones with <> do need a parameter.

          Comment


            #6

            Hi Jesse!

            THANK YOU SO MUCH! It worked! It's taking in the buy/sell order - but I'm still getting an error for the stop loss:

            Click image for larger version

Name:	image.png
Views:	188
Size:	3.1 KB
ID:	1337640

            This is the cleaned up code without any identifiers:

            ----------------------------------------------------------------------------------------------------------

            using System;
            using NinjaTrader.Client; // Reference to NinjaTrader.Client.dll

            class Program
            {
            private static Client ntClient = new Client();

            static void Main(string[] args)
            {
            string account = "Sim101";
            string instrument = "NQ 06-25";
            string action = "BUY";
            double stopLossPrice = 19568.0;
            double profitTargetPrice = 19600.0;

            Console.WriteLine("Testing NinjaTrader Order Placement...");

            // Attempt to place a market order
            int mar****rderResult = ntClient.Command(
            "PLACE",
            account,
            instrument,
            action,
            1,
            "MARKET",
            0.0,
            0.0,
            "DAY",
            "",
            "",
            "",
            ""
            );

            Console.WriteLine(mar****rderResult == 0 ? "Market Order Placed Successfully." : $"Error: {mar****rderResult}");

            // Attempt to place a stop order
            int stopOrderResult = ntClient.Command(
            "PLACE",
            account,
            instrument,
            action == "BUY" ? "SELL" : "BUY",
            1,
            "STOP",
            stopLossPrice,
            0.0,
            "DAY",
            "",
            "",
            "",
            ""
            );

            Console.WriteLine(stopOrderResult == 0 ? "Stop Order Placed Successfully." : $"Error: {stopOrderResult}");
            }
            }

            --------------------------------------------------------------------------

            Could you clarify:
            Whether the "STOP" order type is supported?
            If "STOP" is not a valid order type, what alternative should I use for a stop-loss order?
            Any required parameters I may be missing?

            Looking forward to your guidance. Thanks!
            ​​

            Comment


              #7
              Hello Mabaturova,

              STOP is not a valid parameter, you will need to reference the help guide to see the valid parameters:

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              55 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              37 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              17 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              17 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              49 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X