• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use indicator in another Indicator....How i declare it?

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

    Use indicator in another Indicator....How i declare it?

    i want to use Indicator BuySellPressure in my Pippo Indicator

    i don't know how i declare it ::

    1)
    BuySellPressure bsP;

    protected override void OnStateChange()



    bsP=BuySellPressure;

    protected override void OnBarUpdate()

    Print("tempo " + time[0] + "delta " + delta[1]);

    2)


    Series<BuySellPressure> bsP;

    protected override void OnStateChange()

    bsp=new Series<BuySellPressure>(this,MasimumBarsLookBack.I nfinite);



    What is the method corret? thanks


    (i need of 2 properties of BuySellPressure : BuyPressure and SellPressure)






    #2
    Hello turbofib,

    Thank you for writing in.

    BuySellPressure() is an indicator method, so you would need to place parenthesis after BuySellPressure.

    Example:
    Code:
    bsP = BuySellPressure();
    For more information about the BuySellPressure() indicator method, please take a look at this help guide link: http://ninjatrader.com/support/helpG...llpressure.htm
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      ok...

      But if my indicator have

      Calculate =
      Calculate.OnBarClose;

      And i write in my code

      protected override void OnBarUpdate()
      {
      Print BuySellPressure()[1];
      }
      i see 0 value..because my indicator is
      Calculate =
      Calculate.OnBarClose;

      and buySellPressure is
      Calculate
      .OnEachTick;

      How i do to print correcty the last pressure in historic bar(for all historic bar)?


      See pics

      https://gyazo.com/f5a52f94e65ca3216e06e33ad56547f3


      Last edited by turbofib; 02-07-2016, 05:56 AM.

      Comment


        #4
        Hello turbofib,

        If you wish to print the BuyPressure and SellPressure of the previously closed bar, you would need to utilize this syntax:
        Code:
        Print(BuySellPressure().BuyPressure[1]);
        Print(BuySellPressure().SellPressure[1]);
        For more information about the BuySellPressure() indicator method, please take a look at this help guide link: http://ninjatrader.com/support/helpG...llpressure.htm

        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          how to declare delta

          Hello,

          I have following script and I would like to use delta of "plotval" for next calculation to use it in section if..... I am running in the circle and menu help is not helping me. I am not an programer......

          double plotval=CCIMA(period,Smooth)[0];

          private double delta()
          {
          return (plotval)[0]-(plotval)[1];
          }

          if (colorbackground)
          {
          if (delta >= CCIthreshold)
          BackColorAll = Color.FromArgb(opacity,BgColorUp);

          else if (delta <= -CCIthreshold)
          BackColorAll = Color.FromArgb(opacity,BgColorDown);

          else BackColorAll= Color.Empty;

          Thank you

          Miroslav

          Comment


            #6
            Hello Miroslav,

            It does not look like you are properly calling the delta() method.

            You need to ensure to place parenthesis after delta if you are wishing to call the delta() method.

            I would suggest taking a look at this link for more information about utilizing methods in C#: http://www.tutorialspoint.com/csharp/csharp_methods.htm

            Additionally, you are attempting to access an index on a double variable. A double variable is only going to hold one value.

            I would suggest creating a variable of type CCIMA.

            Example:
            Code:
            CCIMA plotval;
            
            protected override void Initialize()
            {
                 plotval = CCIMA(period, Smooth);
            }
            
            private double delta()
            {
                 return plotval[0] - plotval[1];
            }
            Before accessing the barsAgo value of 1, ensure that you have enough bars in the data series you are accessing. Please take a look at this link for additional information: http://ninjatrader.com/support/forum...ead.php?t=3170

            If you are still running into issues, please describe the issue you are running into.

            Please, let us know if we may be of further assistance.
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ZacharyG View Post
              Hello Miroslav,

              It does not look like you are properly calling the delta() method.

              You need to ensure to place parenthesis after delta if you are wishing to call the delta() method.

              I would suggest taking a look at this link for more information about utilizing methods in C#: http://www.tutorialspoint.com/csharp/csharp_methods.htm

              Additionally, you are attempting to access an index on a double variable. A double variable is only going to hold one value.

              I would suggest creating a variable of type CCIMA.

              Example:
              Code:
              CCIMA plotval;
              
              protected override void Initialize()
              {
                   plotval = CCIMA(period, Smooth);
              }
              
              private double delta()
              {
                   return plotval[0] - plotval[1];
              }
              Before accessing the barsAgo value of 1, ensure that you have enough bars in the data series you are accessing. Please take a look at this link for additional information: http://ninjatrader.com/support/forum...ead.php?t=3170

              If you are still running into issues, please describe the issue you are running into.

              Please, let us know if we may be of further assistance.
              Hello Zachary,

              thank you for your answer. I tried to modify my script. I have looked to linked you provided but it does not helped me too much. I tried to modify my script. Still I have some issue to complile it. It seems there is already used name "delta" but not sure if it is refering to variables or to section if.

              public class ccipokus2 : Indicator
              {
              #region Variables
              private int cCIthreshold = 45;
              private int period = 14; // Default setting for
              private double line1Value = 100; // Default setting for Line1Value
              private double line2Value = -100; // Default setting for Line2Value
              private double line3Value = 200; // Default setting for Line3Value
              private double line4Value = -200; // Default setting for Line4Value
              private bool colorbackground = true;
              private int opacity = 50;
              private Color bgColorUp = Color.RoyalBlue;
              private Color bgColorDown = Color.DeepPink;
              private int smoothperiod = 14;
              private int plotval;
              private int delta;


              //Color Price Bars

              private bool colorpricebars = true;
              private Color barColorUp = Color.Gray;
              private Color barColorDown = Color.Gray;
              private Color barColorFt = Color.Gray;
              private Color barColorUpFill = Color.Green;
              private Color barColorDownFill = Color.Maroon;
              private Color barColorFtFill = Color.Yellow;
              private DataSeries MADelta;


              #endregion

              /// <summary>
              /// This method is used to configure the indicator and is called once before any bar data is loaded.
              /// </summary>

              protected override void Initialize()
              {
              Add(new Plot(new Pen(Color.White, 2), PlotStyle.Line, "CCImiddle")); // Between margins.
              Add(new Plot(new Pen(Color.DarkOrange, 2), PlotStyle.Line, "CCIoverbought"));// Upper = Overbought (>+100)
              Add(new Plot(new Pen(Color.DarkOrange, 2), PlotStyle.Line, "CCIoversold")); // Lower = Oversold (<-100)
              Add(new Plot(new Pen(Color.Lime, 1), PlotStyle.Bar, "CCIbarHi")); // Histogram above zero.
              Add(new Plot(new Pen(Color.Red, 1), PlotStyle.Bar, "CCIbarLo")); // Histogram below zero.
              Add(new Plot(Color.Yellow, PlotStyle.Line, "Line1"));
              Add(new Plot(Color.Yellow, PlotStyle.Line, "Line2"));
              Add(new Plot(Color.Yellow, PlotStyle.Line, "Line3"));
              Add(new Plot(Color.Yellow, PlotStyle.Line, "Line4"));

              CalculateOnBarClose = false;
              Overlay = false;
              PriceTypeSupported = false;
              PaintPriceMarkers = false;
              DisplayInDataBox = true;

              }
              protected override void OnStartUp()

              {
              plotval = CCIMA(period, smoothperiod);
              }
              private double delta()
              {
              return plotval[0] - plotval[1];
              }

              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              { Plots[0].Min = Line2Value; // Not oversold or overbought.
              Plots[0].Max = Line1Value;
              Plots[1].Min = Line1Value; // Overbought is above this.
              Plots[2].Max = Line2Value; // Oversold is below this.
              Plots[3].Min = 0; // Overbought is above this.
              Plots[4].Max = 0;



              if (colorbackground)
              {
              if (delta() >= CCIthreshold)
              BackColorAll = Color.FromArgb(opacity,BgColorUp);

              else if (delta() <= -CCIthreshold)
              BackColorAll = Color.FromArgb(opacity,BgColorDown);

              else BackColorAll= Color.Empty;
              }

              if (Line1Value != 0) Line1.Set(Line1Value);
              if (Line2Value != 0) Line2.Set(Line2Value);
              if (Line3Value != 0) Line3.Set(Line3Value);
              if (Line4Value != 0) Line4.Set(Line4Value);




              // Note, some of the following settings will be ignored based on the Min & Max values defined in Initialize() above:
              CCImiddle.Set( plotval ); // Blue for NOT over-sold or over-bought.
              CCIoverbought.Set( plotval ); // DarkGreen for over-bought.
              CCIoversold.Set( plotval ); // DarkRed for over-sold.
              CCIbarHi.Set( plotval ); // Green histogram for over-bought.
              CCIbarLo.Set( plotval ); // Red histogram for over-sold.

              }

              Thank you
              Attached Files

              Comment


                #8
                Hello miroslav,

                I do want to note the reason why you are receiving an "already contains a definition for delta" error is because you have created an int variable called delta. You will need to either remove or rename this variable as it is conflicting with the delta() method.

                Additionally, you have declared plotval as int. This will need to be of type CCIMA.

                I see that you are also trying to set your DataSeries (CCImiddle, CCIoverbought, CCIoversold, CCIbarHi, and CCIbarLow) to plotval. plotval is a DataSeries; you cannot pass a DataSeries in a Set() method.

                If you wish to pass the current value of plotval, you will need to specify the index of 0:

                Code:
                plotval[0]
                Please, let us know if we may be of further assistance.
                Zachary G.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ZacharyG View Post
                  Hello miroslav,

                  I do want to note the reason why you are receiving an "already contains a definition for delta" error is because you have created an int variable called delta. You will need to either remove or rename this variable as it is conflicting with the delta() method.

                  Additionally, you have declared plotval as int. This will need to be of type CCIMA.

                  I see that you are also trying to set your DataSeries (CCImiddle, CCIoverbought, CCIoversold, CCIbarHi, and CCIbarLow) to plotval. plotval is a DataSeries; you cannot pass a DataSeries in a Set() method.

                  If you wish to pass the current value of plotval, you will need to specify the index of 0:

                  Code:
                  plotval[0]
                  Please, let us know if we may be of further assistance.
                  Hello Zachary,

                  is it possible to do it in this way or it will make some overloading of ninjatrader.

                  Thank you
                  Attached Files

                  Comment


                    #10
                    Hello miroslav,

                    I am not entirely clear of your question.

                    Please note that we do not provide debugging services; I have only resolved the compile errors for you.

                    If you are running into unexpected behavior ,I would first suggest to consult the information found at this link for information about debugging your code: http://ninjatrader.com/support/forum...ead.php?t=3418

                    If you are running into any specific issues and are unsure of why the behavior is occurring, please provide the results you see, the results you expect, and what debugging steps you have already done to try to resolve the unexpected results.
                    Zachary G.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_ZacharyG View Post
                      Hello miroslav,

                      I am not entirely clear of your question.

                      Please note that we do not provide debugging services; I have only resolved the compile errors for you.

                      If you are running into unexpected behavior ,I would first suggest to consult the information found at this link for information about debugging your code: http://ninjatrader.com/support/forum...ead.php?t=3418

                      If you are running into any specific issues and are unsure of why the behavior is occurring, please provide the results you see, the results you expect, and what debugging steps you have already done to try to resolve the unexpected results.
                      Hello Zachary,

                      no I am not asking for debugging services but I run compile correctly and there is no output of indicator also log is empty so I do not know what is issue now.

                      Miroslav

                      Comment


                        #12
                        Hello miroslav,

                        What debugging steps have you already done?

                        What values are you seeing when debugging? What values are you expecting? Are any errors appearing in the Log tab?
                        Zachary G.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_ZacharyG View Post
                          Hello miroslav,

                          What debugging steps have you already done?

                          What values are you seeing when debugging? What values are you expecting? Are any errors appearing in the Log tab?
                          Hello,

                          there is nothing in the log tab. And I see in indicator following things, see picture.

                          Miroslav
                          Attached Files

                          Comment


                            #14
                            Hello miroslav,

                            I have noticed that you have placed...
                            Code:
                            double delta =(Math.Abs((plotval[0]))-Math.Abs((plotval[1])));
                            ...in OnStartUp(). This will result in a run-time error as the data you are trying to retrieve is not available yet.

                            You will want to do this calculate in OnBarUpdate(), before all of your other logic. Also, ensure that you are checking that you have enough bars before attempting to access plotval[1]: http://ninjatrader.com/support/forum...ead.php?t=3170

                            Additionally, you have set plotval as a DataSeries rather than of type CCIMA. You will want to make plotval of type CCIMA if you wish to set the indicator to this variable.

                            Lastly, ensure to initialize plotval within OnStartUp() rather than Initialize(). I apologize for stating to initialize plotval from Initialize() in my previous post; this will cause the indicator to always return 0.

                            Code:
                            protected override void OnStartUp()
                            {
                                 plotval = (CCIMA(period, smoothperiod));
                            }
                            Please, let us know if we may be of further assistance.
                            Zachary G.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ZacharyG View Post
                              Hello miroslav,

                              I have noticed that you have placed...
                              Code:
                              double delta =(Math.Abs((plotval[0]))-Math.Abs((plotval[1])));
                              ...in OnStartUp(). This will result in a run-time error as the data you are trying to retrieve is not available yet.

                              You will want to do this calculate in OnBarUpdate(), before all of your other logic. Also, ensure that you are checking that you have enough bars before attempting to access plotval[1]: http://ninjatrader.com/support/forum...ead.php?t=3170

                              Additionally, you have set plotval as a DataSeries rather than of type CCIMA. You will want to make plotval of type CCIMA if you wish to set the indicator to this variable.

                              Lastly, ensure to initialize plotval within OnStartUp() rather than Initialize(). I apologize for stating to initialize plotval from Initialize() in my previous post; this will cause the indicator to always return 0.

                              Code:
                              protected override void OnStartUp()
                              {
                                   plotval = (CCIMA(period, smoothperiod));
                              }
                              Please, let us know if we may be of further assistance.

                              Hello Zachary,

                              thank you for your reply

                              what do you mean by "You will want to make plotval of type CCIMA if you wish to set the indicator to this variable."

                              I made suggested modifications but I am running in the circle with error message: "Cannot implicitly convert NinjaTrader. Indicator CCIMA to NinjaTrade.DataSeries and it is addressing the following code

                              protected override void OnStartUp()
                              {
                              plotval = CCIMA(period, smoothperiod);
                              }
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by fredfred, Today, 03:41 AM
                              2 responses
                              8 views
                              0 likes
                              Last Post fredfred  
                              Started by TraderYoda, Today, 03:33 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post TraderYoda  
                              Started by pjsmith, Today, 02:56 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post pjsmith
                              by pjsmith
                               
                              Started by ntbone, Yesterday, 08:10 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post ntbone
                              by ntbone
                               
                              Started by chrislou, 08-28-2015, 03:27 AM
                              14 responses
                              2,884 views
                              0 likes
                              Last Post nkhoi
                              by nkhoi
                               
                              Working...
                              X