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

how to control one indicator with another indicator

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

    how to control one indicator with another indicator

    Hi,

    i am using two indicator in my assembly file. i want to control my first indicator with second one.

    EX: if my MACD indicator gave me a buy call in that time i want to check my Trend showing indicator. if my Trend showing indicator is in down trend. i don't want draw any green arrow in my chart. vice versa for sell calls also.

    Thank You.
    Attached Files

    #2
    Hello paruchuriphani,

    You can expose an object like a Bool using a BoolSeries that you can have the other indicator check for to make sure that you are trending. The following thread has a reference sample that goes over how to expose indicator values that are not Plots that you may use to accomplish this.
    JCNinjaTrader Customer Service

    Comment


      #3
      hi,

      thanks for your reply.

      please give your ticket number . i will send my cs file. please tell me how to use BoolSeries in my case.

      thank you,

      Comment


        #4
        Hello paruchuriphani,

        You may send an email to Support [at] ninjatrader [dot] com with a reference link to this thread and put "ATTN: JC" in the subject and I can take a look at it.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC,

          Thank you for your reply,

          I changed my MACD indicator code like this.please tell me this is correct or not?

          This my old code:

          #region Variables

          private bool up = true;
          private bool down = true;

          #endregion

          protected override void Initialize()

          bbMacd = new DataSeries(this);
          dotSeries = new DataSeries(this);
          This is my new changed code:

          #region Variables

          private BoolSeries up = true;
          private BoolSeries down = true;

          #endregion

          protected override void Initialize()

          bbMacd = new BoolSeries(this);
          dotSeries = new BoolSeries(this);
          Next

          i want to stop this BUY call code. when Trend indicator in RED

          this is my MACD OnBarUpdate() code for buy call

          if(CrossAbove(dotSeries, BB_UpperBand,1)&&up)
          {
          {
          Say(" There is a Buy Call in" +Instrument.FullName+"" );
          over=true; // only say it once per bar
          }
          {
          DrawDiamond("MyDot"+ CurrentBar, true, 0, dotSeries[0] , Color.Blue);
          }
          up=false;
          down=true;
          }
          please tell me how to stop this code when my Trend Indicator(TSST) in RED.

          Thankyou,
          Last edited by paruchuriphani; 03-19-2013, 11:36 AM.

          Comment


            #6
            Originally posted by paruchuriphani View Post
            This is my new changed code:
            Code:
            #region Variables
            
            private BoolSeries up = true;
            private BoolSeries down = true;
            
            #endregion
            
            protected override void Initialize()
            
            bbMacd = new BoolSeries(this);
            dotSeries = new BoolSeries(this);
            
            if(CrossAbove(dotSeries, BB_UpperBand,1)&&up)
            {
            {
            Say(" There is a Buy Call in" +Instrument.FullName+"" );
            over=true; // only say it once per bar
            }
            {
            DrawDiamond("MyDot"+ CurrentBar, true, 0, dotSeries[0] , Color.Blue);
            }
            up=false;
            down=true;
            }
            How you set and call a BoolSeries is different than a bool so you would not be able to set it equal to true or false since, it will be like a Data Series in that it will have an series of values much like Bar data. Please read the following Help Guide for more information about the BoolSeries.


            Here is an example of how it may look:
            Code:
            #region Variables
            
            private BoolSeries up;
            private BoolSeries down;
            
            #endregion
            
            protected override void Initialize()
            
            up= new BoolSeries(this);
            down= new BoolSeries(this);
            
            protected override void OnBarUpdate()
            
            if(CrossAbove(dotSeries, BB_UpperBand,1)&&up[0])
            {
            {
            Say(" There is a Buy Call in" +Instrument.FullName+"" );
            over=true; // only say it once per bar
            }
            {
            DrawDiamond("MyDot"+ CurrentBar, true, 0, dotSeries[0] , Color.Blue);
            }
            up.Set(false);
            down.Set(true);
            }
            JCNinjaTrader Customer Service

            Comment


              #7
              Hi JC,

              thank you so much for your reply,

              I changed my code like this after your reference..my code compile fine but OnbarUpdate() functions DrawDiamond & SpeechSynthesizer not working.

              #region Variables
              private BoolSeries up;
              private BoolSeries down;
              #endregion
              protected override void Initialize()
              up=new BoolSeries(this);
              down=new BoolSeries(this);
              protected override void OnStartUp()

              if(CrossAbove(dotSeries, BB_UpperBand,1)&&up[0])
              {
              {
              Say(" There is a Buy Call in" +Instrument.FullName+"" );
              over=true; // only say it once per bar
              }
              {
              DrawDiamond("MyDot"+ CurrentBar, true, 0, dotSeries[0] , Color.Blue);
              }
              up.Set(false);
              down.Set(true);
              }

              if(CrossBelow(dotSeries, BB_LowerBand,1)&&down[0])
              {
              {
              Say(" There is a Sell Call in " +Instrument.FullName+ "");
              over=true; // only say it once per bar
              }
              {
              DrawDiamond("MyDot"+ CurrentBar, true, 0,dotSeries[0] , Color.White);
              }
              up.Set(true);
              down.Set(false);
              }
              }
              #region Properties
              /// <summary>
              /// </summary>
              [Browsable(false)]
              [XmlIgnore()]
              public BoolSeries Up
              {
              get { return up; } // Allows our public Up BoolSeries to access and expose our interal up BoolSeries
              }

              [Browsable(false)]
              [XmlIgnore()]
              public BoolSeries Down
              {
              get { return down; } // Allows our public Down BoolSeries to access and expose our interal down BoolSeries
              }
              please tell me Where do I get it wrong.I done exactly what you told in your last post.please help me.

              Thank You,
              Last edited by paruchuriphani; 03-22-2013, 11:56 AM.

              Comment


                #8
                From your last post, I do not see the OnBarUpdate() method referenced in your code -

                Are you sure you have added logic here? I only see this added to OnStartUp() which only works on the first bar on the chart.
                MatthewNinjaTrader Product Management

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Haiasi, 04-25-2024, 06:53 PM
                2 responses
                16 views
                0 likes
                Last Post Massinisa  
                Started by Creamers, Today, 05:32 AM
                0 responses
                5 views
                0 likes
                Last Post Creamers  
                Started by Segwin, 05-07-2018, 02:15 PM
                12 responses
                1,786 views
                0 likes
                Last Post Leafcutter  
                Started by poplagelu, Today, 05:00 AM
                0 responses
                3 views
                0 likes
                Last Post poplagelu  
                Started by fx.practic, 10-15-2013, 12:53 AM
                5 responses
                5,407 views
                0 likes
                Last Post Bidder
                by Bidder
                 
                Working...
                X