Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

to refer this DataSeries

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

    to refer this DataSeries

    hi, call a indicator but i want to refer to period of this script refer

    ex:
    Code:
    protected override void OnBarUpdate()
            {
                
    var xx=Stochastics(int period, int periodK, int smooth) ;
    
       }
    i want setting this period in Stochasticx egual to period of data in the chart

    I want to use the period of the symbol of this chart

    (period = this period of chart)

    Ex. I use this indicator on 5 Min. fut s&p...

    i want setting period=5 min in automatic....it take frame from the chart

    How i do it? thanks
    Last edited by turbofib; 01-27-2016, 12:06 PM.

    #2
    Hello turbofib,

    Thank you for writing in.

    You would be able to obtain the period value of your chart with BarsPeriod.Value. This will return an integer value representing the period parameter.

    For more information about BarsPeriod, please take a look at this link in the NinjaTrader 8 help guide: http://ninjatrader.com/support/helpG...barsperiod.htm

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

    Comment


      #3
      i try this :


      apply a stocastic Indicator in chart(see pics on gyazo)...and i create indicator (see code down)

      https://gyazo.com/ae9001084bf489d93f718335c0190a39

      Code:
       
        
      double value = Stochastics(7, 14, 3).K[0];
       Print("The current Stochastics %K value is " + value.ToString());
      I see all value different (indicator and the print of screen of my code)..The parameter of setting is the same.

      where is a bug?
      Last edited by turbofib; 01-27-2016, 06:59 PM.

      Comment


        #4
        Originally posted by turbofib View Post
        i try this :


        apply a stocastic Indicator in chart(see pics on gyazo)...and i create indicator (see code down)

        https://gyazo.com/ae9001084bf489d93f718335c0190a39

        Code:
         
          
        double value = Stochastics(7, 14, 3).K[0];
         Print("The current Stochastics %K value is " + value.ToString());
        I see all value different (indicator and the print of screen of my code)..The parameter of setting is the same.

        where is a bug?
        There is no bug. You asked the code to print out the value of the Stochastics on the current bar. That value will change, depending on what is the CurrentBar.

        Comment


          #5
          Originally posted by koganam View Post
          There is no bug. You asked the code to print out the value of the Stochastics on the current bar. That value will change, depending on what is the CurrentBar.
          Ok, but in the CurrentBar ...Open or Close bar? ...i don't understand
          I'm in OnBarUpdate()

          Comment


            #6
            Hello turbofib,

            The print is printing out every historical Stochastics K value on your chart.

            Your script will be evaluating on every historical bar on your chart unless you have specified that you do not want it to evaluate on historical data. This is why you would see multiple prints. Each value corresponds to each Stochastics K value on the past bars.

            If you do not wish for your script to run logic on historical bars, you can return if the script's state is Historical.

            As an example:
            Code:
            protected override void OnBarUpdate()
            {
                 if (State == State.Historical) return;
            
                 // code logic below that will run if not historical
                 ........
            }
            Depending on what your Calculate property in State.SetDefaults is set to, OnBarUpdate() will be called on every close of a bar, every new tick that comes in, or on price change.

            For more information about Calculate, please take a look at this link: http://ninjatrader.com/support/helpG...?calculate.htm
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Ok. but if i write :
              Calculate = Calculate.OnBarClose;
              ....

              double valueStocaz = Stochastics(7, 14, 3).K[1];
              Print("The current Stochastics %K value is " + value.ToString());
              This print the Value of stocast in the previous candle..

              But if i use

              double valueStocaz = Stochastics(7, 14, 3).K[0]; (i use [0])

              Is not a value of CurrentBar because the bar is not close....
              Then what value is it?
              Is Open of current Bar?

              Comment


                #8
                Hello turbofib,

                With Calculate.OnBarClose, if the current bar hasn't closed yet, OnBarUpdate() has not been called for the current bar. Therefore, [0] is the value of the Stochastics K on the most recently closed bar, which would be the previous bar.
                Last edited by NinjaTrader_ZacharyG; 01-28-2016, 10:02 AM.
                Zachary G.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jeronymite, 04-12-2024, 04:26 PM
                3 responses
                44 views
                0 likes
                Last Post jeronymite  
                Started by Barry Milan, Yesterday, 10:35 PM
                7 responses
                20 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by AttiM, 02-14-2024, 05:20 PM
                10 responses
                179 views
                0 likes
                Last Post jeronymite  
                Started by ghoul, Today, 06:02 PM
                0 responses
                10 views
                0 likes
                Last Post ghoul
                by ghoul
                 
                Started by DanielSanMartin, Yesterday, 02:37 PM
                2 responses
                13 views
                0 likes
                Last Post DanielSanMartin  
                Working...
                X