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

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.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by nandhumca, Yesterday, 03:41 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by The_Sec, Yesterday, 03:37 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by vecnopus, Today, 06:15 AM
    0 responses
    1 view
    0 likes
    Last Post vecnopus  
    Started by Aviram Y, Today, 05:29 AM
    0 responses
    5 views
    0 likes
    Last Post Aviram Y  
    Started by quantismo, 04-17-2024, 05:13 PM
    3 responses
    27 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X