Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

question of understanding (draw objects)

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

    question of understanding (draw objects)

    I have a question of understanding, following example: small timeframe 100tick or smaller. general calculations of the strategy run on OnEachTick basis. A line (draw.Line) is drawn every time a new one is made, in the tickchart and OnEachTick there can be a lot of arithmetic operations which can lead to freezing the charts. What would be the best solution if OnEachTick is needed for the other calculations in the strategy? Would this be solved with OnRender or with a new data series (AddDataSeries)? Is there an example where many lines or other draw objects have to be drawn in a small timeframe? Which method requires the least computing power and resources?

    Code:
    RemoveDrawObject(oldIntradayHighTag);
    intradayHighTag = "intradayHigh" + " @ " + intradayHigh.ToString();
    labeledRayIH = Draw.LabeledRay(this, intradayHighTag, false, startBar, intradayHigh, 0, intradayHigh, IntradayHigh.Brush,IntradayHigh.DashStyleHelper, Convert.ToInt32(IntradayHigh.Width), true);
    labeledRayIH.IgnoresSnapping = true;
    labeledRayIH.TextDisplayMode = TextDisplayMode; oldIntradayHighTag = intradayHighTag;
    Click image for larger version  Name:	Screenshot_1.jpg Views:	0 Size:	99.2 KB ID:	1125395
    Last edited by sidlercom80; 10-29-2020, 11:59 AM.
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    Thank you for your post.

    A script that is constantly adding and removing drawing objects on every tick would have a big performance impact, yes. Adding an additional data series would only increase the performance impact.

    You could try creating a single Draw.LabeledRay() and simply updating it rather than creating and destroying new ones with each tick that comes in. You can update a drawing object by calling it again using the same tag name and adjusting the price it's drawn at - that automatically will update the line without the need for removal. This would have less impact on performance.

    You could also consider separating out some of this logic and only updating the value of the line once per bar. Here's an example from our help guide that shows how to separate some logic to calculate once per bar and some to calculate on every tick:



    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Working...
    X