Announcement

Collapse
No announcement yet.

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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      157 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      91 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      143 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      131 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X