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

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; 11-19-2019, 10: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 SantoshXX, Today, 03:09 AM
              0 responses
              12 views
              0 likes
              Last Post SantoshXX  
              Started by DanielTynera, Today, 01:14 AM
              0 responses
              2 views
              0 likes
              Last Post DanielTynera  
              Started by yertle, 04-18-2024, 08:38 AM
              9 responses
              41 views
              0 likes
              Last Post yertle
              by yertle
               
              Started by techgetgame, Yesterday, 11:42 PM
              0 responses
              13 views
              0 likes
              Last Post techgetgame  
              Started by sephichapdson, Yesterday, 11:36 PM
              0 responses
              2 views
              0 likes
              Last Post sephichapdson  
              Working...
              X