Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

In a Strategy, how can I plot one indicator over another existing indicator?

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

    In a Strategy, how can I plot one indicator over another existing indicator?

    Hello,

    I have a plot enabled for an indicator I'm using in my strategy. This is for the ROC(SMA()) of the data I'm running the strategy on.

    I'd like to also plot my "signal line" - a 3 day SMA of the ROC(SMA()). This needs to be plotted on the same indicator, so I can visually compare the two lines.

    I couldn't find a way of achieving this using the Strategy Builder. When I unlock and edit the code, I tried this:

    Code:
    SMA2.Plots[0].RenderTarget = ROC1.Plots[1].RenderTarget;
    But that seems to have either no effect or to make Ninjatrader unstable.

    How can I get the SMA(ROC(SMA())) to appear on the same indicator as the ROC(SMA())?

    Thank you,

    Ryan

    #2
    Hello gripload, and thank you for your question.

    If I understand what your goal is here, I would like to recommend

    • Editing the SMA indicator's source
    • Right-clicking in the editor, selecting "save as", then giving it a new name
    • Adding another plot to your new indicator
    • Setting the value of your new indicator to the output of ROC1

    If you had a different goal in mind or there is another way we can help please let us know.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hello Jessica,

      I'm working inside a custom Strategy. Please see the image below for a visualization of what I'm trying to accomplish.

      I believe I'm on the right track with this code, but it doesn't seem to be having the desired effect yet:

      Code:
      		protected override void OnRender(ChartControl ChartControl, ChartScale ChartScale)
      		{
      				SMA2.Panel = ROC1.Panel;
      		}
      Thank you!
      Attached Files

      Comment


        #4
        Ok, I just figured out that if I set the indicator's Panel # in the OnStateChange() function, I get the desired effect. However, I have to set it explicitly, i.e.:

        ROC1.Panel = 1;
        SMA2.Panel = 1;

        I can't do the following because in this function, the default value for Panel is 0 on both accounts:

        SMA2.Panel = ROC1.Panel;

        And when I place that code in the OnRender() function, nothing changes, or worse, the program crashes.

        Any ideas?

        Thanks,

        Ryan

        Comment


          #5
          Thank you for this additional information.

          I had misunderstood your goal. I believe I understand more clearly.

          With respect to OnRender, your goal in the image you sent can be accomplished completely during State.Configure , and chart panels for an indicator can not be modified beyond this stage, as you found out. Trying to directly change these properties during OnRender will definitely break your code. If there is a compelling reason to use OnRender, or to attempt to make runtime changes, we may have other options, such as creating hidden indicators and revealing them during OnRender. Please let us know what our goals are with respect to this if we need to go above and beyond what you showed us in the picture.

          That said, it seems you would like to have multiple indicators know to plot to the same panel. This is possible through the use of globals. I am including a publicly available link from the MSDN C# documentation which will guide you toward putting together a global scope file in NT8.

          The C# namespace alias qualifier `::` is used to access a member of an aliased namespace. The `::` operator is often used with the `global` alias, an alias for the global namespace


          With a global scope file, you could then call something like this during your State.Configure phase :

          Code:
          ROC1.Panel = Globals.PanelToUse;
          SMA2.Panel = Globals.PanelToUse;
          Jessica P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          60 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          9 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Started by algospoke, 04-17-2024, 06:40 PM
          5 responses
          48 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X