• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Relative Performance Charts Comparing Two Instruments

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

    Relative Performance Charts Comparing Two Instruments

    Hey,

    I was wondering how I can view the relative performance of two instruments. For example, this is achieved on other platforms by entering [Instrument 1]/[Instrument 2], essentially dividing one by the other.

    Thanks

    #2
    Hello Splex,

    You would need to add this calculation to an indicator.

    Open a NinjaScript Editor from the New menu
    Right-click the Indicators folder and select New Indicator
    In the Indicator Wizard on the Additional Data page add a secondary instrument
    On the Plots and Lines page add a plot
    Generate the script

    Within the OnBarUpdate() methods action block add the code
    Code:
    if (CurrentBars[0] < 1 || CurrentBars[1] < 1)
    {
    Values[0] = Closes[0] / Closes[1];
    }
    Then right-click the code and select Compile.
    Next add the indicator to a chart.

    Below is a public link to a post with helpful information about getting started with NinjaScript.
    http://ninjatrader.com/support/forum...609#post503609

    A link to a Spread indicator which shows the difference between two instruments.
    https://ninjatrader.com/support/foru...php?linkid=936

    As well as a few links that discuss dynamically using variables to load a secondary series.
    https://ninjatrader.com/support/foru...349#post424349
    https://ninjatrader.com/support/foru...489#post451489

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3

      Hi When I use the script with NT8 it gives and error during compilation
      myditorIndicator.cs Operator '/' cannot be applied to operands of type 'NinjaTrader.NinjaScript.PriceSeries' and 'NinjaTrader.NinjaScript.PriceSeries' CS0019 59 13
      Values[0] = Closes[0] / Closes[1]; any help with syntax is appreaciated thanks

      Comment


        #4
        Hello 2sureshk,

        Thanks for your post.

        Sorry for the error in the example, please try Values[0] = Closes[0][0] / Closes[1][0]; // divide the current bar value of the chart bars by the added data series.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by n8dogg59, Today, 03:07 PM
        0 responses
        1 view
        0 likes
        Last Post n8dogg59  
        Started by Newtrader101, Today, 10:31 AM
        1 response
        15 views
        0 likes
        Last Post koganam
        by koganam
         
        Started by nepenthean, Today, 12:36 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by sun0781, Yesterday, 05:02 PM
        1 response
        23 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by Emma1, Today, 12:14 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Working...
        X