Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Crossover of 2 instruments?

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

    Crossover of 2 instruments?

    If you are charting 2 instruments, what Ninja Script would you use to test for the price of one crossing the price of the other?

    Brooks

    #2
    Hello Brooks,

    To access the price of a secondary series you could use:
    Closes
    BarsArray

    You can also use Highs, Opens, Lows as well.

    Below tests for close of primary series crossing above secondary.
    if (CrossAbove(Close, Closes[1][0], 1))
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan.

      Will this still work if one issue trades in the 100 range and the other trades in the 500 range?

      On the chart they may cross because one has Scale Justification set to Right and one to Left.

      Will this work in an indicator to plot an object (dot, cross, etc.) as well as in a strategy as a basis to enter a trade?

      If you did this in a backtest, where/how would you specify the 2nd instrument?

      Brooks

      Comment


        #4
        Actually, I think I see that you can have a 2nd instrument in the same way that you can have a 2nd time series on the same instrument - using the Add statement.

        Is it possible in Script to say that you want the 2nd instrument to have a Scale Justification = Left?

        Comment


          #5
          No, this will not work if your instruments do not trade in similar ranges.

          You can adjust the scaling and you may see visual crosses, but these are not actual crosses and will never be interpreted as such by NinjScript. For crossing to return true, the values must cross.

          For Version 7 only: You can set scale programatically through ScaleJustification property. This will apply to all plots within the indicator. It's not possible to have different scales on individual plots within the indicator.

          Yes, adding instruments works similar to adding multiple time frames. See the multi-instrument sample for help on adding series to a strategy. Click Tools > Edit NinjaScript > Strategy > SampleMultiInstrument.

          This help guide article can also help with this.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            I'm using NT7. Would your original plot be separate from the one you add in the indicator? IOW, the original plot has a right scale. If you Add a plot in script and set its scale to left, you'd then have different scales, right?

            If that's true, could you then compare a crossover?

            You addressed indicators, how does this work for strategies?

            "For Version 7 only: You can set scale programatically through ScaleJustification property. This will apply to all plots within the indicator. It's not possible to have different scales on individual plots within the indicator. "

            Comment


              #7
              Scale justifications are set per indicator, not a specific series. If you set the scale justification programatically then it will apply to all plots within the indicator.

              Cross conditions will always test for value crossings. You can't configure to test for visual crossing seen with different scales.

              When using strategies, cross conditions will still only test for values crossing. ScaleJustification property is only available with indicators.
              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
              599 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              344 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              103 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              558 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              557 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X