Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Entry Price for CreateOrder()

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

    Setting Entry Price for CreateOrder()

    Hello,
    I'm trying to utilize the CreateOrder() and StartAtmStrategy() methods. I created an AddOn order and call it. I want to use a stop order entry at a set price. How do I set the price for the initial Stop Order price?
    Code:
            public static void ExecuteTrade(double entryPrice, double stopPrice, double targetPrice)
            {
                lock (Account.All)
                    account = Account.All.FirstOrDefault(a => a.Name == "SimTest");
                    entryOrder = account.CreateOrder(
                        Cbi.Instrument.GetInstrument("NQ SEP24"),
                        OrderAction.Sell,
                        OrderType.MIT,
                        OrderEntry.Manual,
                        TimeInForce.Day,
                        1,
                        targetPrice,
                        stopPrice,
                        string.Empty,                
                        "Entry",
                        Core.Globals.MaxDate,
                        null
                        );
                NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy("Test", entryOrder);
                Output.Process($"ExecuteTrade {LN()}", PrintTo.OutputTab1);
            }
    ​
    Thanks in advance

    #2
    Hello ramckay,

    The stop distance is controlled by the Atm template. Make changes to the Atm template to change the distance for the stop loss then re-save the template.

    If you want to control the price of the stop from code, then you would not want to use StartAtmStrategy() and you would want to create the order with <Account>.CreateOrder() and submit the stop with <Account>.Submit().

    The ProfitChaseStopTrailAddonExample linked below demonstrates.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,
      I need to rephrase the question. I understand the stop and limit settings in the ATM strategy.

      I have 3 prices to work with:

      1) Entry Price - Enter market on Buy/Sell Stop Order
      2) Stop Price - Exit trade with loss
      3) Limit Price - Exit trade with profit

      Stop and Limit are created and placed by ATMStrategy based on entry price. I've used ATM strategies for years by entering using right click, select 'Buy Stop Market 1 @ xxx' and clicking on chart to place Stop Market trade. Trade Stop and Limit are placed by selected ATM Strategy. I now want to know if I can use StartATMStrategy() to place the entry order (Buy Stop Market) at price x programatically. I don't understand how to give the StartAtmStrategy() the entry price (Buy Stop Market). Can it be done? I'm trying to wire this up to a RiskReward DrawingTool. I'll have the entry, stop, and limit from the RiskReward Drawing Tool and want to place the order by calling StartATMStrategy() from and AddOn.
      Thanks
      Rod

      Comment


        #4
        Hello Rod,

        "I now want to know if I can use StartATMStrategy() to place the entry order (Buy Stop Market) at price x programatically"

        The entry order price is specified in the CreateOrder() method.

        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)

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,
          When I read the instructions for CreateOrder() method I assumed that the Stop and Limit variables were to be used on an as yet unnamed entry price. Nothing like make something simple difficult! Anyway, I've got it.
          Thanks as always,
          Rod

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          52 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          71 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          38 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          99 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          60 views
          0 likes
          Last Post PaulMohn  
          Working...
          X