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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    50 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X