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, 10:59 AM.

    #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:

    https://ninjatrader.com/support/help...either_cal.htm

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by aslane, Today, 02:50 AM
    0 responses
    3 views
    0 likes
    Last Post aslane
    by aslane
     
    Started by fx.practic, Today, 02:07 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by Ousher, Today, 01:29 AM
    0 responses
    8 views
    0 likes
    Last Post Ousher
    by Ousher
     
    Started by tonynt, Today, 01:23 AM
    0 responses
    4 views
    0 likes
    Last Post tonynt
    by tonynt
     
    Started by cmarkb, Today, 01:18 AM
    1 response
    11 views
    0 likes
    Last Post cmarkb
    by cmarkb
     
    Working...
    X