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

UniRenko memory leak

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

    UniRenko memory leak

    I'm trying to diagnose why some hybrid Renko bars (e.g. UniRenko, etc.) cause a serious memory leak when you try to use Market Replay.

    I'm suspicious that has to do with the way MR deals with market data differently from live data, and some statement may be caught into a loop with the AddBar(...) statement within it.

    When I try to add Print(" ....") statements within the code of the bar, I get a compilation error "The name Print does not exist in the current context". I thought was a namespace reference issue, but that seems not to be the problem. I also have problems with the Log( ...) statement.

    I guess I have 2 questions:
    1- Any clues as why MR would cause the memory leak while it works fine with live data?
    2- How could I diagnose the problem using Print statements?

    I tried to comment out parts of the code, but if I could use Print statements with some info around the code would be much easier to diagnose the issue with these bars.

    Thanks!

    #2
    Ok...

    I think I found the cause of the leak and how to solve it. I looked at the original Renko bars code, and I used the following piece of code in the beginning of the procedure for the synthetic Renkos:

    // ******************* ADDED FROM RENKO
    offset = bars.Period.Value * bars.Instrument.MasterInstrument.TickSize;
    if (bars.Count < tmpCount && bars.Count > 0) // reset cache when bars are trimmed
    {
    renkoHigh = bars.GetClose(bars.Count -
    1) + offset;
    renkoLow = bars.GetClose(bars.Count -
    1) - offset;
    }
    // *********************
    and before the end:
    tmpCount = bars.Count; // ADDED FROM RENKO

    I'm still testing it, but it seems ok, and now I can use Market Replay with these bars without memory leaks. I'm still trying to understand better why this piece of code is needed. If someone can shine some light about how this is resetting the 'cache' I would love to hear the explanation.

    I also still would love to be able to print to output to have a better understanding of what is going on with the different variables of the code.

    Thanks!

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by gentlebenthebear, Today, 01:30 AM
    0 responses
    1 view
    0 likes
    Last Post gentlebenthebear  
    Started by samish18, Yesterday, 08:31 AM
    2 responses
    8 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by Mestor, 03-10-2023, 01:50 AM
    16 responses
    389 views
    0 likes
    Last Post z.franck  
    Started by rtwave, 04-12-2024, 09:30 AM
    4 responses
    31 views
    0 likes
    Last Post rtwave
    by rtwave
     
    Started by yertle, Yesterday, 08:38 AM
    7 responses
    29 views
    0 likes
    Last Post yertle
    by yertle
     
    Working...
    X