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

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.





    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 CortexZenUSA, Today, 12:53 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by CortexZenUSA, Today, 12:46 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by usazencortex, Today, 12:43 AM
    0 responses
    5 views
    0 likes
    Last Post usazencortex  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    168 responses
    2,265 views
    0 likes
    Last Post sidlercom80  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    11 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X