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 burtoninlondon, Today, 12:38 AM
      0 responses
      5 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      14 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      13 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,982 views
      3 likes
      Last Post jhudas88  
      Working...
      X