Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CreateOrder() Parameters confusion

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

    CreateOrder() Parameters confusion

    I am having difficulty understanding where I am going wrong with this script. I am trying to create 2 orders. I am trying to follow the syntax listed in the parameters. When I get to the OCO and name parameters (which require "strings") the compiler gives me an error message for both lines of code.

    Error: "CS1503" - "Argument 1: cannot convert from 'string' to 'NinjaTrader.Cbi.Instrument'.

    I don't even have any OCO orders. I'm not sure why I MUST place a value for this parameter in the first place. Is it possible to have a "null" placeholder.

    PLEASE LET ME KNOW WHAT I AM MISSING!!! Thank You in advance.

    Please see below for codes:

    longLimitOrder = myAccount.CreateOrder("ES", OrderAction.Buy, OrderType.Limit, OrderEntry.Automated, TimeInForce.Gtc, 2, buyLimitPrice, 0, "myOCO", "longLimitOrder", Core.Globals.MaxDate, null);

    shortLimitOrder = myAccount.CreateOrder("ES", OrderAction.SellShort, OrderType.Limit, OrderEntry.Automated, TimeInForce.Gtc, 2, sellLimitPrice, 0, "myOCO", "shortLimitOrder", Core.Globals.MaxDate, null);​

    #2
    Hello jm_test19,

    Below is the method signature from the help guide.

    CreateOrder(Instrument instrument, OrderAction action, OrderType orderType, OrderEntry orderEntry, TimeInForce timeInForce, int quantity, double limitPrice, double stopPrice, string oco, string name, DateTime gtd, CustomOrder customOrder)


    For the first parameter 'Instrument' you are supplying a string with the text "ES" and not an Instrument object.

    Use Instrument.GetInstrument("ES 12-24") or Instrument.GetInstrument("ES DEC24") to get an instrument object from a string. (Depending on the symbology display you have selected)



    Use string.Empty for the OCO if you do not want OCO.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X