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 DJ888, Yesterday, 10:57 PM
      0 responses
      6 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      158 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      7 views
      0 likes
      Last Post Belfortbucks  
      Started by zstheorist, Yesterday, 07:52 PM
      0 responses
      7 views
      0 likes
      Last Post zstheorist  
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      151 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Working...
      X