Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Resetting output prints on an new day

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

    Resetting output prints on an new day

    Hello

    I am trying to get my script output prints to reset at the start of a new trading days, but all that both of the codes below do, is to disable the script at the end of the day and re-enable it at the start of the next day, while all the prints carry on counting from the day before (such as the List indexes), where as I expected the data prints to start from 0 again, without clearing the Output window.
    Is there a way to achieve that?

    Thank you

    Code:
    else if (State == State.Configure)                
                {
                    AddDataSeries(Data.BarsPeriodType.Tick, 1);
                    AddDataSeries(null, new BarsPeriod() { BarsPeriodType = BarsPeriodType.Minute, Value = 5 }, "CME US Index Futures ETH", true);
    Code:
    protected override void OnBarUpdate()
            {                      
                // Make sure this strategy does not execute against historical data
                if (State == State.Historical)
                    return;
                int startTime = ToTime(23, 0, 0);
                if (ToTime(Time[0]) >= startTime)
                {            
                    // Script Logic
    ....

    #2
    Hello itrader46,

    Thanks for your post.

    I am not quite sure I follow what you are trying to accomplish with the information and code provided. If the information below does not resolve your inquiry, could you attach an export of a small example script that demonstrates the behavior you are seeing, and could you clarify on what exactly you are trying to accomplish?

    If you are seeing prints in the Output window, this would mean that the strategy logic is allowing the prints to be reached.

    If you would like to clear the output window, you can do so with ClearOutputWindow()

    ClearOutputWindow - https://ninjatrader.com/support/help...tputwindow.htm

    IsFirstBarOfSession can also be used to identify the first bar of a session (set from the Data Series Trading Hours template.)

    IsFirstBarOfSession - https://ninjatrader.com/support/help...rofsession.htm

    IsFirstBarOfSessionByIndex (Multi Time Frame) - https://ninjatrader.com/support/help...ionbyindex.htm

    I look forward to being of any further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi JIM
      What I am trying to achieve is to have the prints reset at the end of the trading day and start from 0 on the next trading day, without clearing all the output window.

      For instance I have Lists of indicator highs / lows and I would like the indexes of those lists to start from 0 on each new day.

      I am testing this in Playback and restarting the count at the start of each day would be helpful when I run the test over a number of days, as opposed to the indexes accumulating over 5 days for instance.

      Comment


        #4
        Hello itrader46,

        I am still not following.

        Prints will print out whatever is being applied in the print. If you would like to have your lists reset and start from 0, you should clear the list. Lists are general C# concepts and not specifically NinjaScript code. Publicly available information on clearing lists can be found below.



        Without seeing a small example script that demonstrates the output you are seeing, I would not be in a position to provide any further insight.

        If you need further help, please attach an export off a small example strategy that demonstrates this output. Other unrelated code can be removed for this demonstration script.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by f.saeidi, Today, 11:02 AM
        1 response
        1 view
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by geotrades1, Today, 10:02 AM
        4 responses
        11 views
        0 likes
        Last Post geotrades1  
        Started by rajendrasubedi2023, Today, 09:50 AM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by lorem, Today, 09:18 AM
        2 responses
        11 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by geddyisodin, Today, 05:20 AM
        4 responses
        30 views
        0 likes
        Last Post geddyisodin  
        Working...
        X