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

Log not being updated on daily roll over with OBC strategy

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

    Log not being updated on daily roll over with OBC strategy

    So I have a strategy that is supposed to update a JSON log file on rollover.

    Inside my OnBarUpdate() I have this:

    Code:
    if (CurrentBar == Bars.Count -2 || CurrentBar == Bars.Count -1) { // -2 as it's zero based plus we operate on a closed bar basis
    
    Print(String.Format("Writing JSON to file at Bars.Count: {0} and CurrentBar: {1}... ", CurrentBar, Bars.Count), PrintLevel.INFO);
    
    WriteToJSON(Instrument.FullName + "-" + BarsPeriod.Value + "-" + BarsPeriod.BarsPeriodType, netlinerLog);
    
    }
    So pretty straightforward. The reason why I have the if condition is that I don't want the JSON log to be overwhelmed when loading the strategy.

    This works but intermittently. I had this running for a few days and on some days the JSON log gets updated and on the next day it didn't.

    With the strategy set to OBC the OnBarUpdate method should only be called once per day (it's a daily series) and the condition should pass.

    When I reload the strategy then the JSON log gets updated properly.

    Any idea as to what may be going on?

    Thanks!

    #2
    Hello molecool,

    JSON would be outside of what our Engineering Support is able to assist with.

    This thread will remain open for any community members that would like to provide insight.

    You could write to a text file with streamwriter instead.

    Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hey Chelsea - I'm a NinjaTrader tech partner so YES I do understand that you are not supporting JSON ;-)

      My issue does not relate to JSON it's the fact that not even the print statement is being executed intermittently.

      Does that make more sense?

      Thanks in advance.

      Comment


        #4
        Hello molecool,

        Can you print outside of the condition?

        If so, print the values in the conditions and provide the output saved in a text file.

        If not, check for errors on the Log tab of the Control Center, ensure data is on the chart, and ensure the strategy is enabled.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Yes print works just fine outside of the condition. I don't see any errors in the log section (or in the print output windows) and the strategy is live (with candles rolling over).

          If you forget about the print and the JSON statement for a moment. Do you see any reason why the if condition would not be true in live tape at the roll-over?

          Thanks in advance.

          Michael

          Comment


            #6
            Hello Michael,

            If the condition is not evaluating as true, the print would not appear. This is why we debug by printing the values in the condition.

            Also, your call to Print() has two parameters which is not documented. The PrintLevel.INFO is not supported by NinjaTrader.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            10 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            14 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            14 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,983 views
            3 likes
            Last Post jhudas88  
            Working...
            X