• 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

Question about array

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

    Question about array

    Hello, please help to program the following task. I need to create two arrays on the price axis and the time axis. No problem with the price axis.

    var x = new double[N];
    for (var i = 0; i < N; i++) x[i] = Close[i];

    But what about the timeline I don't know. I need to Express it as a sequence of numbers relative to each bar.
    For example x[5]=Close[5] x[4]=Close[4] x[3]=Close[3] x[2]=Close[2]
    y[5]= 1 y[4]=2 y[3]=3 y[2]=4 etc


    #2
    Hello Kovalev,

    Are you wanting the time of each bar?

    This is provided with the Time series.

    Below is a link to the help guide.
    https://ninjatrader.com/support/help...eries_time.htm

    If the series are already provided to you, it would be redundant to copy these to an array. Is there something specific you are trying to achieve?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Kovalev,

      Are you wanting the time of each bar?

      This is provided with the Time series.

      Below is a link to the help guide.
      https://ninjatrader.com/support/help...eries_time.htm

      If the series are already provided to you, it would be redundant to copy these to an array. Is there something specific you are trying to achieve?
      ChelseaB, thank you very much for the tip, but there was another question. I'm programming these actions in OnBarUpdate, doesn't that mean the action won't execute until a new bar appears?

      I did it this way. It turns out that this is wrong?
      var x = new double[N];
      for (var i = 0; i < N; i++)
      {
      x[i] = Close[i];
      Print("x ");
      Print(x[i]);
      }
      var y = new double[N];
      for (var j = N-1; j > -1; j--)
      {
      y[j] = j;
      Print("y ");
      Print(y[j]);
      }
      Last edited by Kovalev; 01-28-2019, 09:12 AM.

      Comment


        #4
        Hello Kovalev,

        OnBarUpdate() runs depending on the Calculate setting and whether the script is processing historical or real-time data and whether TickReplay is enabled or not.

        In real-time when Calculate is .OnEachTick OnBarUpdate() will run each time a tick is received, when Calculate is .OnPriceChange OnBarUpdate() will run any time the price changes, when Calculate is .OnBarClose OnBarUpdate() will run any time the bar closes.

        Below is a link to the help guide on Calculate.
        https://ninjatrader.com/support/help.../calculate.htm

        In historical data, Calculate is always .OnBarClose unless TickReplay is enabled.
        https://ninjatrader.com/support/help...ick_replay.htm
        https://ninjatrader.com/support/foru...377#post773377


        However, I'm unsure if your custom logic is wrong. Is this printing what you are wanting to print? Were not you not attempting to get the time of the bar?
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by uiwislth, Yesterday, 11:25 PM
        0 responses
        4 views
        0 likes
        Last Post uiwislth  
        Started by Steve L, Yesterday, 10:04 PM
        0 responses
        3 views
        0 likes
        Last Post Steve L
        by Steve L
         
        Started by marianfed, Yesterday, 09:47 PM
        0 responses
        5 views
        0 likes
        Last Post marianfed  
        Started by hir04068, Yesterday, 09:29 PM
        0 responses
        4 views
        0 likes
        Last Post hir04068  
        Started by iq200, 03-11-2018, 07:49 PM
        24 responses
        1,022 views
        0 likes
        Last Post mrlucky1x  
        Working...
        X