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

Can't display 2 indicators in one?

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

    Can't display 2 indicators in one?

    I made a strategy, and now I'm converting this to an indicator (no order submission of course).

    I see that AddChartIndicator(); is not supported on indicators :/

    So I added this code, which works fine and displays the FIRST indicator, but not the second. What am I missing?

    P.S. - This is for an indicator crossover situation.
    P.S.2 - See attached for the full code.


    Code:
    protected override void OnStateChange() {
      AddPlot(Brushes.Gray, "SHORT_ATR");
      AddPlot(Brushes.Blue, "LONG_ATR");
    }
    
    protected override void OnBarUpdate() {
      SHORT_ATR[0] = ATRTrailing(SHORT_ATRTimes,SHORT_Period,.005)[0];
      LONG_ATR[0] = ATRTrailing(LONG_ATRTimes,LONG_Period,.005)[0];
    }
    
    #region Properties {
    
      [Browsable(false)]
      [XmlIgnore]
      public Series<double> SHORT_ATR
      {
    	get { return Values[0]; }
      }
    
      [Browsable(false)]
      [XmlIgnore]
      public Series<double> LONG_ATR
      {
    	get { return Values[0]; }
      }
    		
    #endregion
    }
    Attached Files

    #2
    Originally posted by jikjol View Post
    I
    you have both as Values[0], change one of them to Values[1].

    in the code, I think this is what you want;;
    // SHORT_ATR[0] = ATRTrailing(SHORT_ATRTimes,SHORT_Period,.005)[0];
    SHORT_ATR[0] = ATRTrailing3[0];
    // LONG_ATR[0] = SMA(LONG_ATRTimes)[0];
    LONG_ATR[0] = ATRTrailing1[0];
    ------------------
    ---
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> LONG_ATR
    {
    get { return Values[1]; }
    }
    Last edited by nkhoi; 01-10-2018, 10:52 PM.

    Comment


      #3
      Hello jikjol,

      Thanks for your post and welcome to the NinjaTrader forums.

      Member nkhoi has provided correct advice for getting the second plot to show.
      Paul H.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by alifarahani, Today, 09:40 AM
      6 responses
      29 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      13 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X