Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EasyLanguage to NinjaScript

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

    #61
    but the question still remains, how would I get the close value of a stock that closes at the NYSE close
    You could compare the current bar timestamp (using CalculatOnBarClose = false) against the Session End. You can use GetNextBeginEnd to do so: http://ninjatrader.com/support/helpG...xtbeginend.htm
    if i do closes [1][0] it gives me the close of the correct bar but closes[0][0] gives me the previous bar. these are historical charts.
    Can you provide the exact scenario? Chart, instrument, and the script used?
    if I wanted the bars ago count for channel [0] I could do:

    back = GetBar ( dt ) ;

    but how would I do it for channel [1]
    BarsArray[1].GetBar()
    is there an order to the BarsInProgress == , ie does 0 always get run first then 1 and so on ?
    No, there is no way to order BarsInProgress. If the timestamp of the bars is the same BarsInProgress 0 is generally called first but there is no guarantee of that.

    Comment


      #62
      I will try the sessionend first. Should it work with Historical Charts? If I just have a daily chart, how would I get the close if I have to wait for the next days open ?

      also

      If I wanted to get the close at a specific time of two charts with different periods, I could do:

      spx_cls = Close [GetBar ( dt )] ;
      es_cls = Closes[1][GetBar ( dt )]

      if I wanted the bars ago count for channel [0] I could do:

      back = GetBar ( dt ) ;

      but how would I do it for channel [1]

      Comment


        #63
        do you think you can help me with this? Hoping to work over weekend.

        Comment


          #64
          Should it work with Historical Charts? If I just have a daily chart, how would I get the close if I have to wait for the next days open ?
          Yes, the GetNextBeginEnd is based on the Session Template and will work on Historical data.
          You would check the time of the Session End against the DateTime.Now or Time[0].
          If I wanted to get the close at a specific time of two charts with different periods, I could do:

          spx_cls = Close [GetBar ( dt )] ;
          es_cls = Closes[1][GetBar ( dt )]

          if I wanted the bars ago count for channel [0] I could do:

          back = GetBar ( dt ) ;

          but how would I do it for channel [1]
          BarsArray[1].GetBar()

          Comment


            #65
            I am using
            value1 = BarsArray[1].GetBar (dt) ;
            I get a strange answer
            dt = 2/22/2016 9:00:00 PM

            Comment


              #66
              if I do
              value1 = GetBar (dt) ;
              I get value1 = 7 which is as expected.
              value1 = BarsArray[0].GetBar (dt) ;
              gives me 1169 which is strange
              value1 = BarsArray[1].GetBar (dt) ;
              gives me 1253 which is the right difference from 1169 but wrong.as it shd bearound 100.

              Comment


                #67
                could it be a timezone issue as I am 5 hrs ahead. Close is at 9pm local.

                Comment


                  #68
                  Good News, I was able to solve both problems.

                  The close problem was solved by making

                  CalculateOnBarClose = false;

                  as you suggested. However, the confusing thing was that the statement was sporadic in Initialize, but worked ok in OnStartUp.

                  The GetBar problem was solved by using:

                  if ( BarsInProgress == 0 ) { spx_cls = Close [GetBar ( dt )] ; }
                  if ( BarsInProgress == 1 ) { es_cls = Close [GetBar ( dt )] ; }

                  loading the variables at the start of session.

                  As always, thanks for your help.
                  Last edited by RobinT; 02-27-2016, 02:49 PM.

                  Comment


                    #69
                    New Question.

                    How do I position the display at a certain DateTime.

                    If I position it at CurrentDate then it will make sure the software runs to completion but then I want to display the user selected date.

                    Comment


                      #70
                      Originally posted by RobinT View Post
                      New Question.

                      How do I position the display at a certain DateTime.

                      If I position it at CurrentDate then it will make sure the software runs to completion but then I want to display the user selected date.
                      RobinT.

                      I am not sure I fully understand. Can you provide a screenshot or any examples?

                      Comment


                        #71
                        The scrollbar at the bottom of the chart display controls which dates are displayed on the screen. Fully right the screen displays the most recent data, fully left and the oldest data is displayed.

                        How do I control this by program, or how do I select where the chart is displaying?

                        Comment


                          #72
                          RobinT,

                          I may still not fully understand, but to control a drawing object for example on a specific area you could use the DateTime overload with Time.

                          DateTime: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

                          Time: http://ninjatrader.com/support/helpGuides/nt7/time.htm

                          Comment


                            #73
                            I have uploaded 2 files. All I want the program to do is display the chart at different dates. I have shown 2-4-16 then 2-1-16. I enter the date i want as an input.
                            Attached Files

                            Comment


                              #74
                              Hello RobinT,

                              Right click in your chart > select Data Series > select Custom Range under Load Data Based On > set the desired Start and End Date > OK.

                              Comment


                                #75
                                I can load data ok, I just want ninjascript to display a date on the screen

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                599 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                344 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                103 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                558 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                557 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X