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

General Trend Indicator (Don't Working)

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

    #16
    Hello fisagol,

    A histogram would not require that every plot be set. A line plot can only draw a line between two consecutive plots. If there aren't values set on every bar, the line will not appear because it does not have two or more points to connect.


    Are you certain this plot is being set on every bar?

    It seems it plots when there is a downtrend or an uptrend. What if there is neither?


    If you print the value that you have set on every bar, does every bar have a -1 or 1?

    if (Close[1][0] > SuperTrend(BarsArray[1],longuitud, multiplicador, true).UpTrend[0])
    {
    CalculatedValues.Set(1);
    }
    if (Close[1][0] < SuperTrend(BarsArray[1],longuitud, multiplicador, true).DownTrend[0])
    {
    CalculatedValues.Set(-1);
    }

    Print(CalculatedValues[0]);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      There can't be a case in which one of the two is not fulfilled . The trend is up or down because the price always will be above the trend line or below never in between.

      If this is true as you would with a histogram such conditions ?

      Thankyou very much
      Last edited by fisagol; 07-21-2015, 11:41 AM.

      Comment


        #18
        Hello fisagol,

        Are you certain this plot is being set on every bar?

        It seems it plots when there is a downtrend or an uptrend. What if there is neither?


        If you print the value that you have set on every bar, does every bar have a -1 or 1?

        if (Close[1][0] > SuperTrend(BarsArray[1],longuitud, multiplicador, true).UpTrend[0])
        {
        CalculatedValues.Set(1);
        }
        if (Close[1][0] < SuperTrend(BarsArray[1],longuitud, multiplicador, true).DownTrend[0])
        {
        CalculatedValues.Set(-1);
        }

        Print(CalculatedValues[0]);


        What are you getting when you print this?


        If your indicator is setting a value on every bar then you should see the plot on the chart, even if this is a line plot.

        I would suggest using a histogram because the value is -1 or 1 and not a price that needs to be connected by a line.

        Is there some reason that these values need to be connected by a line?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Nothing, the result is the same that before. When I add indicator in graphic draw the line 1 or -1 if time frame is the same that graphic, but if I say Graphic 3 min and the indicator 1, 2 or 4, 5... don't appear any thing

          Comment


            #20
            Hello fisagol,

            Just to confirm, you have added that print and nothing is printing in the Output Window under Tools -> Output Window..., is this correct?

            If so, then no values are being set at all.

            If that is the case then neither of your conditions are evaluating as true.


            You need to print the values used in your condition to find out why they are not evalutating as true.

            Try the following print and post what this prints in the output window in your next post.

            Print(Time[0]+" - Close[0]: "+Close[0]+" - SuperTrend[0]: "+SuperTrend(BarsArray[1],longuitud, multiplicador, true).UpTrend[0]);
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Sorry I don't make this, tools > windows. Now YES I make this and when I put graphic 5 min and indicator at 5 min the sequence is:
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              -1
              And it's all correct because the indicator draws all lines right .BUT when I put the graphic at 5 min but the indicator at 15 min, the output windows says this:

              Error on calling 'OnBarUpdate' method for indicator 'SuperTrendFractal' 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.
              Error on calling 'OnBarUpdate' method for indicator 'SuperTrendFractal' 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.
              AND DON'T DRAW NOTHING

              Comment


                #22
                Hello fisagol,

                Earlier you mentioned that there are no error messages.

                If there are error messages then the indicator is not going to plot.

                The error messages you are getting are an indexing error.

                Likely its the Close[1][0] instead of Closes[1][0].

                I recommend you comment out code until you figure out which line is causing the error message.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #23
                  Hi, NinjaTrader_ChelseaB

                  Now I'm very confused, you say that this indicator you could create as a histogram indicator. Could help me to create this how you would do?

                  Thank You very much!

                  Comment


                    #24
                    Hello fisagol,

                    Making this a histogram will not fix the errors if you are getting errors.

                    If you are getting errors then your indicator will not work!


                    To make your indicator a histogram set the Add() call to:

                    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Bar, "CalculatedValues"));
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      The error persist, this code isn't good.

                      Then, as you think you would have to do to make this work in MultiTimeFrame? :/ :/

                      if (Close[1][0] > SuperTrend(BarsArray[1],longuitud, multiplicador, true).UpTrend[0])
                      {
                      CalculatedValues.Set(1);
                      }
                      if (Close[1][0] < SuperTrend(BarsArray[1],longuitud, multiplicador, true).DownTrend[0])
                      {
                      CalculatedValues.Set(-1);
                      }

                      Comment


                        #26
                        Hi fisagol,

                        I would think that using Close[0][1] instead of Closes[0][1] would cause an index error. (I mentioned this in post #22)

                        I have provided a multi-time frame example for you in post #11.

                        As long as the script is not generating errors I would expect your script to work for multiple time frames.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          But close[0][1] IS ILLEGAL!! This isn't a solution for this indicator.

                          Comment


                            #28
                            Hello fisagol,

                            Yes, Close[0][1] cannot be used, but I see this in your code. I would expect this to cause an error.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Rapine Heihei, Today, 08:19 PM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by Rapine Heihei, Today, 08:25 PM
                            0 responses
                            6 views
                            0 likes
                            Last Post Rapine Heihei  
                            Started by f.saeidi, Today, 08:01 PM
                            1 response
                            9 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by Rapine Heihei, Today, 07:51 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post Rapine Heihei  
                            Started by frslvr, 04-11-2024, 07:26 AM
                            5 responses
                            98 views
                            1 like
                            Last Post caryc123  
                            Working...
                            X