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

Remove Indicator

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

    Remove Indicator

    What would be the equivalent command to remove a previously added indicator from a strategy?

    Thx
    Last edited by P-Sionic; 11-07-2016, 08:20 AM. Reason: Typo

    #2
    Hello,

    Thank you for the question.

    I am not quite sure I understand the question, are you asking how to reverse the Add() syntax to Remove an indicator the strategy added to the chart?

    Can you confirm if you are using Add syntax, if not could you provide a sample of the syntax you are currently using to add the indicator?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Indeed, I add an indicator via e.g. Add(EMA(14)) and want to remove it later depending on some conditions.

      Thanks.

      Comment


        #4
        Hello,

        Thank you for the reply.

        While you cant directly remove the indicator after adding it, you could set its plot to transparent, use the Strategy Plot example or edit the indicator its self.

        One example would be the following or to create a variable of the indicator which can be used in logic:

        Code:
        private SMA mySma;
        protected override void Initialize()
        {
        	mySma = SMA(12);
        	Add(mySma);
        }
        protected override void OnBarUpdate()
        {
        	if(Close[0] > Open[0])
        	{
        		mySma.PlotColors[0][0] = Color.Transparent;
        		//or for the whole plot
        		mySma.Plots[0].Pen = new Pen(Color.Transparent, 0);
        	} else {
        		mySma.PlotColors[0][0] = Color.Red;
        		//or for the whole plot
        		mySma.Plots[0].Pen = new Pen(Color.Red, 1);
        	}
        }
        Another approach is the strategy plot example, in essence the strategy passes a value to a dummy indicator that just plots that value. The strategy can control if the indicator gets a value, the colors of the plots etc.
        When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability


        Another approach is to make a version of the indicator that includes the logic already to hide its plots when a condition becomes true. Mainly to just make its plots transparent.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks. Thats a viable alternative. In fact I intend showing an Ichimoku indicator each time a respective condition becomes valid for verification and hide it if not. So that solution should work for me.

          Btw. would removing indicators they way I intended previously work in NT8?

          Thanks.

          Comment


            #6
            Hello,

            No this would still be the same type of options for NT8. The script you are applying to the chart tells the platform to then Add the indicator, this all happens when the script is first starting.

            The opposite action or removing actually does happen but only when the script is disabled. I don't believe actually removing the item would be the correct approach, in the case an item needs to be added after that, the script would need reloaded to Add that indicator. Instead the suggested approach would be to add the items you may need and toggle them depending on conditions.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by helpwanted, Today, 03:06 AM
            1 response
            11 views
            0 likes
            Last Post sarafuenonly123  
            Started by Brevo, Today, 01:45 AM
            0 responses
            9 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            5 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            242 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            387 views
            1 like
            Last Post Gavini
            by Gavini
             
            Working...
            X