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 charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            65 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            149 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            162 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            99 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            286 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X