• 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

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.

    http://www.ninjatrader.com/support/f...ear#post310521

    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 maggie3, Today, 02:05 AM
      0 responses
      3 views
      0 likes
      Last Post maggie3
      by maggie3
       
      Started by qewcool, Today, 01:14 AM
      0 responses
      3 views
      0 likes
      Last Post qewcool
      by qewcool
       
      Started by fredrikn, 05-08-2019, 04:01 AM
      17 responses
      669 views
      1 like
      Last Post emtrader  
      Started by zacharydw00, Yesterday, 10:19 PM
      0 responses
      3 views
      0 likes
      Last Post zacharydw00  
      Started by chafan11, Yesterday, 09:28 PM
      0 responses
      7 views
      0 likes
      Last Post chafan11  
      Working...
      X