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

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 warreng86, 11-10-2020, 02:04 PM
                7 responses
                1,360 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by Perr0Grande, Today, 08:16 PM
                0 responses
                5 views
                0 likes
                Last Post Perr0Grande  
                Started by elderan, Today, 08:03 PM
                0 responses
                9 views
                0 likes
                Last Post elderan
                by elderan
                 
                Started by algospoke, Today, 06:40 PM
                0 responses
                10 views
                0 likes
                Last Post algospoke  
                Started by maybeimnotrader, Today, 05:46 PM
                0 responses
                14 views
                0 likes
                Last Post maybeimnotrader  
                Working...
                X