• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

draw.region

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

    draw.region

    Hi,

    I read in another post, by support, in this forum, that you could use the draw. methods, almost anywhere, but specifically, in OnRender, if you wanted. Unless I misunderstood this, I expected Draw.Region(this, "pjsVPva", VALow.Count-1, 0, VALow, VAHigh, Brushes.DimGray, Brushes.Black, 20); to work in onrender. In my case, it does not. If I put the exact same command in OnBarUpdate, it works fine.

    Is this expected?

    Thanks.

    #2
    Originally posted by pjsmith View Post
    I read in another post, by support, in this forum, that you could use the draw. methods, almost anywhere, but specifically, in OnRender, if you wanted. Unless I misunderstood this?.
    Misunderstood! Do Not use default Draw.Anything methods in OnRender… You must render your own objects with SharpDX!

    Control Center / Help / Help Guide

    Click Search... and then type

    brush

    then search and take a look at 1st result..


    Using SharpDX for Custom Rendering...



    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    Comment


      #3
      Well, that explains it Thanks for the pointer...


      For info, this is the quote I found from NT support when looking for the answer

      "You should find no problem working with both NinjaScript drawing methods and SharpDX drawing methods within OnRender, and you can access any of the NinjaScript drawing objects' properties from within OnRender, as well.

      The big distinction here is that SharpDX drawing requires a RenderTarget, and OnRender provides a ready-made RenderTarget for you. Thus, you will want to do your SharpDX work within that event. NinjaScript drawing methods (Draw.X) have no such requirement, and are already connected to logic related to slot indexes and the x- and y-axis, so you can call them in a greater scope."

      Comment


        #4
        Hi pjsmith, thanks for your post.

        Could you link me to the thread where that quote is from? I would like to read the full context. Any Draw.<X> method is designed to be used in OnBarUpdate, and since OnRender is not tied to the bar update logic in any way then custom sharpDX drawing methods should be used.
        Last edited by NinjaTrader_ChrisL; Yesterday, 09:45 AM.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris,

          It's here https://ninjatrader.com/support/foru...-clarification

          Comment


            #6
            Hello pjsmith,

            To clarify, the major issue with using Draw methods in OnRender is that OnRender will not be synchronized with the proper indexing to make appropriate BarsAgo indexes. You could get away with calling some Draw methods like Draw.TextFixed in OnRender, but we would not recommend this since the Draw methods have higher overhead and the intention of using OnRender would be to use your own drawing routines.

            You could notice that if you use TriggerCustomEvent in OnRender for your draw method, the BarsAgo indexing will work, but this adds even more overhead when you should be using SharpDX and literal index referencing with Series.GetValueAt(barIndex) and using bar indexes when looping between ChartBars.FromIndex and ChartBars.ToIndex.

            Please let me know if we can be of further assistance.
            JimNinjaTrader Customer Service

            Comment


              #7
              Hi - Yes, I'm aware of that one re the indexes. I was just being lazy at the time, as draw.region was a little simpler to test something than using native methods. A quick search looked like it should work, hence my query. Thanks.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rontronimous, Today, 05:55 PM
              0 responses
              8 views
              0 likes
              Last Post rontronimous  
              Started by bcgeek, Today, 03:43 PM
              2 responses
              6 views
              0 likes
              Last Post bcgeek
              by bcgeek
               
              Started by Mberg, Today, 04:05 PM
              0 responses
              9 views
              0 likes
              Last Post Mberg
              by Mberg
               
              Started by dkbyond, Today, 03:52 PM
              0 responses
              5 views
              0 likes
              Last Post dkbyond
              by dkbyond
               
              Started by Newtrader101, Today, 03:09 PM
              2 responses
              7 views
              0 likes
              Last Post Newtrader101  
              Working...
              X