Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi instrument, two orders

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

    Multi instrument, two orders

    Hello. I simply need to execute two entry orders on two instruments triggered by condition on the first one. The only request is that this orders are executed at the same time.

    Here is the non working code


    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class ES : Strategy
    {
    #region Variables
    // Wizard generated variables
    private int myInput0 = 1; // Default setting for MyInput0
    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {

    CalculateOnBarClose = true;
    Add("ES 03-12", PeriodType.Minute, 10);
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(SMA(BarsArray[0], 14), SMA(10), 1))
    {
    if (BarsInProgress == 0)
    EnterLong(DefaultQuantity, "");
    if (BarsInProgress == 1)
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (CrossBelow(SMA(BarsArray[0], 14), SMA(10), 1))
    {
    if (BarsInProgress == 0) ExitLong("", "");
    if (BarsInProgress == 1) ExitLong("", "");
    }
    }
    Please help

    #2
    another question: Is it possible to automatically execute simultaneous trade on another instrument when trading discretionary.

    e.g.: I manually put stop order on one instrument and that order, when triggered, automatically puts market order on second instrument

    Comment


      #3
      Hello zoki.rb,

      For this you would need to work with EntriesPerDirection and EntryHandling properties. They can be set in code or through the GUI.

      Since there are no signal names with the entries, you could set EntriesPerDirection = 2 to allow each order to be accepted.

      If you want to enforce that only each distinct entry should be entered (and not two of the same), you can provide a unique signal name for each entry, set EntryHandling = UniqueEntries, and EntriesPerDirection = 1.

      More information about what the strategy is doing and any messages about ignoring orders and reason is possible with TraceOrders output.
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        I don't get it. What is the syntax for telling Ninja to buy specific instrument?

        I don't have problems with orders being accepted, but I dont know what to type into EnterLong syntax...

        if (CrossAbove(SMA(BarsArray[0], 14), SMA(BarsArray[0], 10), 1))
        {
        if (BarsInProgress == 0)
        EnterLong(DefaultQuantity, "");
        if (BarsInProgress == 1)
        EnterLong(DefaultQuantity, "");
        Last edited by zoki.rb; 12-22-2011, 02:17 PM.

        Comment


          #5
          You can use the advanced overload of EnterLong, that allows you to specify the BarsInProgress value for the order.

          EnterLong(int barsInProgressIndex, int quantity, string signalName)
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            solved. thanks.. I had wrong order of "if" statements

            is there a way to make that work with Volume charts? it work now with 5min on both primary and secondary instrument

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            573 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            575 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X