Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Displaying ADX and Its SMA on the same plot?

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

    Displaying ADX and Its SMA on the same plot?

    Hello,

    In my strategy code, I am trying to display ADX(18) and It's own SMA on the same plot.... How can I achieve this?

    Adding the first line to the code below correctly displays the 18-Day ADX...as a separate plot under the Price plot.

    However, when I add the second line from below Add(SMA(ADX(18), 18)); the ADX SMA is displayed on the Price Section of the chart rather on the Indicator Plot itself...

    Add(ADX(18));
    Add(SMA(ADX(18), 18));

    I am obviously missing something....

    Do I need to make a copy of the ADX indicator code and add the SMA to the indicator code itself to achieve this?

    Thanks.

    #2
    CyberTrader123, yes please create a custom indicator for the 'SMA of the ADX' and then ADD() this from your strategy Initialize().

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      CyberTrader123, yes please create a custom indicator for the 'SMA of the ADX' and then ADD() this from your strategy Initialize().
      Thanks...If it helps anyone, I made a copy of the ADX indicator, called it ADXwSMA and added the following code....and it displayed the SMA of ADX.

      protected override void Initialize() {
      .....
      Add(new Plot(Color.Red, "ADXSMA"));
      .....
      }


      protected override void OnBarUpdate(){
      .....
      .....
      //Simple Moving Average
      ADXSMA.Set(SMA(Value, Smalength)[0]);
      .....
      .....
      }

      I parameterized the SMA Length using a variable...

      Thanks for the quick response... I really appreciate the timeliness.

      Comment


        #4
        You're welcome, thanks for sharing your solution here...

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, Yesterday, 01:02 PM
        0 responses
        29 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        21 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        160 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        95 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        148 views
        2 likes
        Last Post CaptainJack  
        Working...
        X