Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 instruments strategy

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

    2 instruments strategy

    Hello there

    Can this be done using C#?

    I want a strategy based on 2 instruments i.e. YM/ES, chart type range chart, and I want to buy/sell based on a simple MACD crossover.

    Thanking you in advance

    #2
    Hello Ninjamouse,

    NinjaTrader offers support for automated strategies with multiple instruments. The following two links should help get you started on implementing this:

    Trading Crossovers

    Multi Time Frame and Instruments.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hello Ninjamouse,

      NinjaTrader offers support for automated strategies with multiple instruments. The following two links should help get you started on implementing this:

      Trading Crossovers

      Multi Time Frame and Instruments.
      I just wrote this:

      protectedoverridevoid Initialize()
      {
      Add(PeriodType.Range,
      3);
      Add(
      "ES 03-10", PeriodType.Range, 3); // I can change this 04-10

      CalculateOnBarClose =
      true;
      }
      ///<summary>
      /// Called on each bar update event (incoming tick)
      ///</summary>
      protectedoverridevoid OnBarUpdate()
      {
      if (BarsInProgress == 0)
      {
      if (ADX(14)[0] > 30 && ADX(BarsArray[2], 14)[0] > 30)
      {
      EnterLong(
      1, "Long");
      }

      and Im not getting any buy or sell signals, am I doing something wrong?
      else

      {
      EnterShort(
      1, "Short");
      }
      }

      Comment


        #4
        Hello NinjaMouse,

        You'll have to work with TraceOrders and debug the values you expect to be true.

        Within the Initialize() method add:
        TraceOrders = true;


        Look at the tips below for help with this.

        Debugging your NinjaScript Code

        TraceOrders
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Is this correct?

          if (CrossAbove(RVI(14), 0, 1) && CrossBelow(RVI(BarsArray[1], 14), 0, 1))
          {
          // do something
          }

          So is this saying, if the current charts RVI is above and the RVI for ES is down do someting

          Comment


            #6
            A crossing event requires that the values cross, and is not necessarily the same as "less than" or "greater than".


            CrossAbove(RVI(14), 0, 1)

            This says if the primary series RVI crosses above 0 within the last bar.

            CrossBelow(RVI(BarsArray[1], 14), 0, 1)

            This says if the secondary series RVI crosses below 0 within the last bar.
            Last edited by NinjaTrader_RyanM1; 03-10-2010, 04:51 PM.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            637 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            572 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X