Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EasyLanguage to NinjaScript

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

  • RobinT
    replied
    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.

    Leave a comment:


  • RobinT
    replied
    could it be a timezone issue as I am 5 hrs ahead. Close is at 9pm local.

    Leave a comment:


  • RobinT
    replied
    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.

    Leave a comment:


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

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    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()

    Leave a comment:


  • RobinT
    replied
    do you think you can help me with this? Hoping to work over weekend.

    Leave a comment:


  • RobinT
    replied
    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]

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    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.

    Leave a comment:


  • RobinT
    replied
    is there an order to the BarsInProgress == , ie does 0 always get run first then 1 and so on ?

    Leave a comment:


  • RobinT
    replied
    I was wrong:

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

    does not work.

    with dt = 2/12/2016 9:00:00 PM

    I get the wrong data for [1] and the correct data for [0].

    Leave a comment:


  • RobinT
    replied
    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]

    Leave a comment:


  • RobinT
    replied
    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.
    Last edited by RobinT; 02-25-2016, 06:01 PM.

    Leave a comment:


  • RobinT
    replied
    I'm still trying to get the close value.

    I have got the time sorted as I use es futures on stream 2 so I can use

    time = day_close & BarsInProgress == 1

    as the futures trade for 15 minutes after the close.

    but the question still remains, how would I get the close value of a stock that closes at the NYSE close. Also, I use closes [0][0] to get the close price but this gives me the close price of the bar 5 minutes earlier.

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Originally posted by RobinT View Post
    My software only seems to run to the date on the screen. If I scroll to the lastbar then the software runs to completion.

    Have I got one of the control commands (like overlay = true) set wrongly ?
    This does occur in NinjaTrader 7. You can increment the bar by pressing the right arrow on your keyboard if you wanted to process bar by bar and analyze for example.

    Leave a comment:


  • RobinT
    replied
    My software only seems to run to the date on the screen. If I scroll to the lastbar then the software runs to completion.

    Have I got one of the control commands (like overlay = true) set wrongly ?

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by kinfxhk, 07-14-2026, 09:39 AM
0 responses
128 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 10:18 AM
0 responses
105 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 09:50 AM
0 responses
86 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-13-2026, 07:21 AM
0 responses
105 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Started by kinfxhk, 07-11-2026, 02:11 AM
0 responses
86 views
0 likes
Last Post kinfxhk
by kinfxhk
 
Working...
X