Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator not plotting

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

    indicator not plotting

    Hi

    new to NJ programming, finding it a bit tricky. One example, this following text inside an inidicator compiles OK but the indicator will not plotanything.
    Any hints about a possible solution ?
    Thanks in advance
    Chris

    BarsRequired=50;

    calculclose[
    0]=facteurclose*(Close[0]-Close[1]);
    data=SMA(calculclose,period)[
    0];
    Plot0.Set(data);


    #2
    Hi bluejay,

    Thanks for posting.

    Please check out this link - http://www.ninjatrader-support2.com/...ead.php?t=3170

    Then add this check to the start of your OnBarUpdate() code section -

    Code:
    if (CurrentBar < Period)
    return;
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Try:
      BarsRequired=50;
      if (CurrentBar<BarsRequired) return;
      calculclose[
      0]=facteurclose*(Close[0]-Close[1]);
      data=SMA(calculclose,period)[
      0];
      Plot0.Set(data);

      Originally posted by bluejay View Post
      Hi

      new to NJ programming, finding it a bit tricky. One example, this following text inside an inidicator compiles OK but the indicator will not plotanything.
      Any hints about a possible solution ?
      Thanks in advance
      Chris

      BarsRequired=50;

      calculclose[
      0]=facteurclose*(Close[0]-Close[1]);
      data=SMA(calculclose,period)[
      0];
      Plot0.Set(data);

      Last edited by roonius; 01-08-2009, 08:55 PM.

      Comment


        #4
        Thanks for the input, still doesnt plot anything ! |(

        Chris

        Comment


          #5
          Hi bluejay,

          Then please post the code here, so we can take a look and advise...

          Thanks!
          BertrandNinjaTrader Customer Service

          Comment


            #6
            here is the code in total
            the problem occurs as soon as I start using Close[1], ie anything different from Close[0]

            thx in advance
            Chriss


            ///</summary>
            protectedoverridevoid Initialize()
            {
            Add(
            new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
            CalculateOnBarClose =
            true;
            Overlay =
            false;
            PriceTypeSupported =
            false;

            }
            ///<summary>
            /// Called on each bar update event (incoming tick)
            ///</summary>
            protectedoverridevoid OnBarUpdate()
            {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.

            BarsRequired=50;
            if (CurrentBar < Period)
            return;

            calculclose[
            0]=facteurclose*(Close[0]-Close[1]);
            data=SMA(calculclose,period)[
            0];
            Plot0.Set(data);

            }
            #region Properties

            Comment


              #7
              Period is not the same as period (Case sensitive)

              And it is not complete code, show your variables too...
              Last edited by roonius; 01-08-2009, 08:55 PM.

              Comment


                #8
                if "calculclose" is supposed to be a data series then the dataSeries has not been defined. Do a Help search on DataSeries and I believe all the info is there to get you going.

                Comment


                  #9
                  here are the variables . I cannot post all the lines at once, the NT forum tells me it exceeds 10000 characters !

                  Thx

                  [Description(
                  "Enter the description of your new custom indicator here")]
                  publicclass Bullbearclose : Indicator
                  {
                  #region Variables
                  // Wizard generated variables
                  privateint period = 20; // Default setting for Period
                  privatedouble facteurclose = 1; // Default setting for Facteurclose
                  privatedouble diff ;
                  private DataSeries calculclose;
                  privatedouble data;
                  // User defined variables (add any user defined variables below)
                  #endregion

                  Comment


                    #10
                    you are missing the following line in Initialize section:

                    calculclose = new DataSeries(this);
                    Last edited by roonius; 01-08-2009, 08:54 PM.

                    Comment


                      #11
                      Hi bluejay,

                      Please add this to the Variables section of your code -

                      Code:
                      new DataSeries calculclose;
                      then this to the Initialize section:

                      Code:
                      calculclose = new DataSeries(this);
                      Finally change your code in the OnBarUpdate -
                      Code:
                      BarsRequired=[SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]50[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2];[/SIZE]
                      [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2] (CurrentBar < Period)[/SIZE]
                      [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2];[/SIZE]
                       
                      [SIZE=2]calculclose.Set([/SIZE][/SIZE][SIZE=2][SIZE=2]facteurclose * (Close[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]] - Close[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]]));[/SIZE]
                      [SIZE=2]data = SMA(calculclose, Period)[[/SIZE][/SIZE][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][SIZE=2]];[/SIZE]
                      [SIZE=2]Plot0.Set(data);[/SIZE]
                      [/SIZE]
                      Also please review this link - http://www.ninjatrader-support2.com/vb/showthread.php?t=7299
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        You must finish defining the data Series with a line of code in the

                        protectedoverridevoid Initialize()
                        {
                        Add(
                        new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                        CalculateOnBarClose =
                        true;
                        Overlay =
                        false;
                        PriceTypeSupported =
                        false;

                        ANOTHER LINE OF CODE FOR THE DATA SERIES GOES HERE;
                        }


                        I do not recall the exact syntax but it is in the Help Files

                        Comment


                          #13
                          YES !! Working !

                          thanks to all for the input, seems simple when you have the answer, but this is learning I guess !!

                          Chris

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Barry Milan, Yesterday, 10:35 PM
                          5 responses
                          16 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by DanielSanMartin, Yesterday, 02:37 PM
                          2 responses
                          13 views
                          0 likes
                          Last Post DanielSanMartin  
                          Started by DJ888, 04-16-2024, 06:09 PM
                          4 responses
                          12 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by terofs, Today, 04:18 PM
                          0 responses
                          11 views
                          0 likes
                          Last Post terofs
                          by terofs
                           
                          Started by nandhumca, Today, 03:41 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post nandhumca  
                          Working...
                          X