Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 TraderBCL, Today, 04:38 AM
              0 responses
              1 view
              0 likes
              Last Post TraderBCL  
              Started by Radano, 06-10-2021, 01:40 AM
              19 responses
              606 views
              0 likes
              Last Post Radano
              by Radano
               
              Started by KenneGaray, Today, 03:48 AM
              0 responses
              4 views
              0 likes
              Last Post KenneGaray  
              Started by thanajo, 05-04-2021, 02:11 AM
              4 responses
              470 views
              0 likes
              Last Post tradingnasdaqprueba  
              Started by aa731, Today, 02:54 AM
              0 responses
              5 views
              0 likes
              Last Post aa731
              by aa731
               
              Working...
              X