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

How to draw indicator of two instruments in one chart?

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

    How to draw indicator of two instruments in one chart?

    I am working on a multi-instrument code and need to draw the indicator of two different instruments in one chart in backtesting.
    For example, how can I draw RSI(EURUSD,14,3) and RSI(AUDUSD,14,3) in the same backtesting chart. They can be in different panels.
    I could only add the indicator of the primary instrument in the chart, but couldn't add the indicator for the secondary instrument.

    Below is my code:

    protected override void Initialize()
    {
    Add("$AUDUSD", PeriodType.Minute, 10);
    Add(RSI(Close,14,3)); // add RSI of the primary instrument EURUSD
    Add(RSI(BarsArray[1],14,3)); // try to add RSI of 2nd instrument but is wrong
    }

    Could someone point out the error in the 3rd line of the above code in blue color?
    Also thanks a lot if anyone can provide sample code....
    Last edited by algoapi; 04-25-2013, 04:25 PM.

    #2
    Originally posted by algoapi View Post
    I am working on a multi-instrument code and need to draw the indicator of two different instruments in one chart in backtesting.
    For example, how can I draw RSI(EURUSD,14,3) and RSI(AUDUSD,14,3) in the same backtesting chart. They can be in different panels.
    I could only add the indicator of the primary instrument in the chart, but couldn't add the indicator for the secondary instrument.

    Below is my code:

    protected override void Initialize()
    {
    Add("$AUDUSD", PeriodType.Minute, 10);
    Add(RSI(Close,14,3)); // add RSI of the primary instrument EURUSD
    Add(RSI(BarsArray[1],14,3)); // try to add RSI of 2nd instrument but is wrong
    }

    Could someone point out the error in the 3rd line of the above code in blue color?
    Also thanks a lot if anyone can provide sample code....
    My post, #10, in this thread, will show you what to do.



    To really understand the issue, you may want to read the thread in threaded or hybrid display mode.

    Comment


      #3
      Thank you Koganam for the help!

      I tested your code but it seems the chart still only displays the primary instrument, not the secondary instrument ("AAPL"), did I miss anything here?

      Below is the code (edited based on your sample) I tested. Basically I want the chart to display both RSI(CSCO) in one pane, and RSI(AAPL) in another pane. But the result chart only displays RSI(CSCO). Any idea?

      protected override void Initialize()
      {
      CalculateOnBarClose = true;

      Add("AAPL", PeriodType.Minute, 5);

      this.myRSI = RSI(Close, 14, 3);

      Add(this.myRSI);

      Add(RSI(Close,14,3));
      }

      protected override void OnStartUp()
      {
      this.myRSI = RSI(Closes[1], 14, 3);
      // this.myRSI = RSI(BarsArray[1], 14, 3);
      }


      Thanks again!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Rapine Heihei, Yesterday, 07:51 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by kaywai, Today, 06:26 AM
      1 response
      6 views
      0 likes
      Last Post kaywai
      by kaywai
       
      Started by ct, 05-07-2023, 12:31 PM
      6 responses
      205 views
      0 likes
      Last Post wisconsinpat  
      Started by kevinenergy, 02-17-2023, 12:42 PM
      118 responses
      2,780 views
      1 like
      Last Post kevinenergy  
      Started by briansaul, Today, 05:31 AM
      0 responses
      10 views
      0 likes
      Last Post briansaul  
      Working...
      X