Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plots won't update or will only consider the bars on screen

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

    Plots won't update or will only consider the bars on screen

    Hello,

    I have two working indicators that are modified versions of a single NT8 out-of-the box indicator. The problem is that they only work under certain conditions. They both do quite literally the exact same thing on screen when working properly, just go about it different ways. The gist of the mods are just some calculations that end up changing the color of the plot given certain criteria.

    The first time I tried it, I did everything inside OnRender(), but that failed spectacularly. The help guide recommended doing all the math outside of OnRender(), so this is what I came up with the second time around:

    (Please forgive me. Since all my programming experience comes from required introductory programming classes from several years ago, I have forgotten the technical names of some of what's below)

    In OnRender(), a previously created list (copyList) is used to duplicate a portion of the information stored in a dictionary that is populated in OnMarketData()
    - copylist is a private list that is created with the other private variables that are not part of a specific method

    copyList is then sorted and passed into custom internal class (Calc()) using a foreach loop

    Calc() has 2 methods, calc1 and calc 2.
    -In calc1, another temporary list (tempList) is populated using the args passed into Calc(). tempList and some other simple arithmetic is needed for calc2.
    -In calc2, tempList is simply looped through with some calculations performed
    -These two methods update public variables within Calc() for use elsewhere

    So to recap, OnRender()

    1. copies/sorts a dict. into copyList
    2. creates a new Calc() object which copyList is passed into
    3. Calc() does math
    4. public Calc() variables then used later in OnRender to determine whether certain parts of the plot change color.

    The problem with this version is that while it does everything correctly on first render, it refuses to automatically update the plot as new data is made available. I suspect the problem lies with calling Calc() inside OnRender(), but I'm not sure.

    After not knowing where to go with the last version, I wrote another that actually does all the math and everything else inside OnRender(), but prior to being drawn which was the problem on my first attempt. This final version also works exactly as expected and even auto updates, unlike the previous. However, if I zoom in on the price axis, it starts ignoring data as if the bars above and below what's currently visible on the chart do not exist at all. This is even more perplexing, but I imagine it has something to do with the way OnRender() behaves that I'm not aware of. Any suggestions here would be greatly appreciated.

    Thanks again for your help,

    #2
    Hello Convert,

    Thank you for the post.

    I reviewed the details provided however this specifically does not tell me what may be happening in your tests only that the problem likely revolves around either the calculation being done or OnRender.

    What I could suggest to move forward from this point would be to make a reduced test that we can work together on here on the forum. I won't necessarily be able to help with what you explained for the calculations but I can try to advise best practice surrounding your rendering of the calculated data.

    Can you provide a simple example of how you are currently rendering the data in the situation that is working best? It looks like the one where you are calculating inside of OnRender works but then fails when scaling. That is likely the most complete/working sample so I would suggest to try and make an example out of how you are trying to render from that file so we can further explore that. From the given details it sounds like potentially the bar indexes you are referencing are mixed up causing the scaling to further confuse the rendering.



    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Walter2011, Today, 08:27 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by arangocj, Today, 06:28 AM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by BIllblast, Today, 08:03 AM
    2 responses
    11 views
    0 likes
    Last Post BIllblast  
    Started by jerryblack, Yesterday, 05:04 PM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by mattage86, Today, 06:43 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_RyanS  
    Working...
    X