• 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

    #16
    Hello miroslav,

    You have set plotval as type DataSeries in your Variables region.

    You need to set it as type CCIMA.

    Code:
    private CCIMA plotval;
    
    protected override void OnStartUp()
    {
         plotval = CCIMA(period, smoothperiod);
    }
    Zachary G.NinjaTrader Customer Service

    Comment


      #17
      Originally posted by NinjaTrader_ZacharyG View Post
      Hello miroslav,

      You have set plotval as type DataSeries in your Variables region.

      You need to set it as type CCIMA.

      Code:
      private CCIMA plotval;
      
      protected override void OnStartUp()
      {
           plotval = CCIMA(period, smoothperiod);
      }
      Hello Zachary,

      thank you now I understood and I have modified variables and on start update. It compiles correctly but still indicator is not plotting anything. At least there is something in log tab:" Error on calling 'OnBarUpdate' method for indicator 'ccipokus2' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

      When I looked in the mentioned section but there is no referrence to[0]

      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()>= CCIdelta )||(delta()>= CCIthreshold))

      BackColorAll = Color.FromArgb(opacity,BgColorUp);

      else if ((delta()<= -CCIdelta)||(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[0]); // Blue for NOT over-sold or over-bought.
      CCIoverbought.Set(plotval[0]); // DarkGreen for over-bought.
      CCIoversold.Set(plotval[0]); // DarkRed for over-sold.
      CCIbarHi.Set(plotval[0]); // Green histogram for over-bought.
      CCIbarLo.Set(plotval[0]); // Red histogram for over-sold.

      }

      Comment


        #18
        Hello Zachary,

        it seems I forced Ninja with your huge help to cooperate and fixed issue with OnBarUpdate.

        I have included code into On Bar Update and now it starts to plot indicator:

        if (Close[0] > Close[Math.Min(CurrentBar, 1)])

        But indicator is behaiving in very different way. There is condition:

        if (colorbackground)
        {
        if ((delta()>= CCIdelta))

        BackColorAll = Color.FromArgb(opacity,BgColorUp);

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

        else BackColorAll= Color.Empty;
        }

        CCI delta is set to 15 but when I plot indicator I have delta of "plotval" e.g -80 and it is not taking it as condition and change color to red since -80 is less than CCIdelta set.

        If I understood correctly plotval is data which will be plotted based on script as histogram indicator or it will be CCIMA?

        thank you

        Miroslav
        Attached Files

        Comment


          #19
          Could this be moved to an appropriate NT7 thread..

          Thanks


          -=Edge=-
          NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

          Comment


            #20
            Originally posted by -=Edge=- View Post
            Could this be moved to an appropriate NT7 thread..

            Thanks


            sure no problem. Will be than some replay to it from Zachary?

            Thank you
            Miroslav

            Comment


              #21
              Originally posted by miroslav View Post
              sure no problem. Will be than some replay to it from Zachary?
              Sorry.. that was meant for NT admins.. as they will be the one to have to do it.. but sure.. nothing will go away or change, will just be in the appropriate NT7 thread and not one specifically for NT8 Beta General Discussions..


              -=Edge=-
              NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

              Comment


                #22
                Hello Miroslav,

                I am not clear of your question.

                if (delta() >= CCIdelta) would not be true if CCIdelta is 15 and the return value of delta() is -80.

                Your delta() method is returning the value of plotval[0] (the current value of plotval) minus plotval[1] (the previous value of plotval).

                You will need to debug your code and check to see why you are not getting the results you are expecting.

                The variable plotval is set to the CCIMA indicator with the parameters of period and smoothperiod passed to it.

                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
                Zachary G.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Longhornmark, Today, 07:06 AM
                4 responses
                21 views
                0 likes
                Last Post bltdavid  
                Started by bomberone3, Today, 02:59 PM
                0 responses
                3 views
                0 likes
                Last Post bomberone3  
                Started by Krossaren96, Today, 02:36 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_JoshG  
                Started by Rafmed, 01-28-2019, 11:01 PM
                8 responses
                88 views
                0 likes
                Last Post aligator  
                Started by priceisking, Today, 01:15 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X