• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Receiving and loading data

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

    Receiving and loading data

    Hello. I have 2 questions.
    1) How to limit screen refresh time? Function "Onrender" may start too often. I want to limit the start of a function "Onrender()", for example 1 time in 5 seconds.
    2) Is the "Download Level2-Data" command? With my new connection, DOM (Glass of prices) can fill up slowly, step-by-step. I want to update full-information immediately.
    Sorry for my bad english.

    #2
    Hello Udimuz,

    Thank you for your post.

    Just to first clarify, OnRender is supposed to be called very frequently, this is because that is the charts render pass which determines what is being displayed on that frame. You should not try to slow OnRender down and instead move any calculations in your code to a different location. The OnRender is best used to simply display data.

    Anything you need to render can be made into a variable or you can reference series by using the GetValueAt method.

    A good example of this concept is the Pivots indicator. It uses OnRender to custom render plot data which was calculated in OnBarUpdate. That would be the same concept you would want to try and target for efficiency. In that use case OnRender only does basic rendering calculations like where to draw something, the actual processing of data or heavy work would be done at a slower frequency from OnBarUpdate.

    A simple example would be storing a variable and then drawing something based on that:

    Code:
    private int myBip;
    
    protected override void OnBarUpdate()
    {
       myBip = BarsInProgress; 
    }
    
    
    //on render
    {
         if(myBip == 1) draw something
    }
    You can do this with any values this is just a simple example to show a variable. The efficiency is that you are only resetting or doing your calculation at the rate of OnBarUpdate, OnRender simply displays the calculated data which may stay the same over many frames.

    Another way to make OnRender more efficient is to only render the currently visible data. You can use GetValueAt and the FromIndex and ToIndex property to do that.

    https://ninjatrader.com/support/help...sub=getvalueat

    https://ninjatrader.com/support/help...ghtsub=toindex

    As far as your second question goes, could you give a little more detail or perhaps a screenshot to illustrate what you mean by "fills up slowly"?

    To send a screenshot with Windows 7 or newer I would recommend using the Windows Snipping Tool.

    Click here for instructions

    Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and add the file as an attachment to your reply.

    Click here for detailed instruction

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by odeifuor, Today, 09:05 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by jhontorres, Today, 12:16 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by KarstenKafl, 07-16-2020, 12:38 AM
    8 responses
    42 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by DieSlower, Yesterday, 11:02 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by TomTownsend, Today, 11:35 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X