• 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

Lines and Rays panel incorrect from indicator when loaded onto chart by Strategy

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

    Lines and Rays panel incorrect from indicator when loaded onto chart by Strategy

    Hi,
    I have an indicator I've written that draws on both the chart panel and its own separate panel. It works fine when used as an indicator.

    It is used from a strategy, and added to the chart via AddChartIndicator(...) in State.DataLoaded.
    In this scenario, lines and rays draw on the main panel even when using the Draw.Ray or Draw.Line signature that includes the "drawOnPricePanel" property and set to false.

    Here is the signature being used in the indicator. (tl is a class containing various useful data)

    Draw.Line(this, tl.tag, false, tl.anchor.barTime, tl.anchor.cciValue,tl.touches[0].barTime, tl.touches[0].cciValue, brush,
    tl.state == 1 ? DashStyleHelper.Dot : DashStyleHelper.Solid, tl.state == 1 ? 1 : 2, false);



    In State.SetDefaults the indicator sets DrawOnPricePanel true, because at various points it places Draw.Text objects on the price panel. All other Draw methods use the signature including "drawOnPricePanel". At no time is DrawOnPricePanel at the base level set true or false on the fly.

    Your assistance would be appreciated.
    Cheers,
    saltminer

    #2
    Hello saltminer,

    Thanks for your post.

    This is the expected behavior when adding an indicator that dynamically changes DrawOnPricePanel to a strategy.

    In the help guide for DrawOnPricePanel is this specific warning: "This property should ONLY be set from the OnStateChange() method during State.SetDefaults. Dynamically using DrawOnPricePanel in an indicator outside of State.SetDefaults may show issues when working with that indicator through a hosting strategy via AddChartIndicator()."
    Reference: https://ninjatrader.com/support/help...pricepanel.htm

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,
      you must have missed the penultimate sentence of my post, which says "At no time is DrawOnPricePanel at the base level set true or false on the fly."

      It is only the signatures of the Draw methods which include DrawOnPricePanel property that are used to draw to both chart and indicator panel.

      Over to you;
      saltminer

      Comment


        #4
        Hello saltminer,

        Thanks for your reply and penultimate clarification!

        I've tested with a sample strategy and sample indicator. The indicator will draw a line in the indicator panel and will then draw a line in the price panel. When I add the indicator to the strategy with addChartIndicator() it also will draw on both panels. I've attached a results screenshot and the indicator strategy zip if you would like to test. (Will draw when the first real-time bar closes).

        Click image for larger version

Name:	saltminer-1.PNG
Views:	50
Size:	35.6 KB
ID:	1061236

        Drawpanelstratind.zip
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks for doing a test.
          Nevertheless, here is a screenshot of lines being drawn incorrectly on the price panel. Those vertical-looking lines are actually trendlines across the oscillator in the lower panel. They draw correctly on the lower panel when the indicator is placed manually onto a chart.
          Therefore, I assume, that there is something that can trip Ninja up that doesn't exist in your test strategy.
          For mytest I turned off everything in the strategy that I can, to just have
          1) basic plotting of the oscillator,
          2) Draw. used for one thing only - those trendlines.

          Can I email you this strategy for you to experience this yourself? You can quickly scan the code to verify that DrawOnPricePanel is nowhere set on the fly.

          Cheers,
          saltminer
          Click image for larger version

Name:	Annotation 2019-06-20 052541.jpg
Views:	58
Size:	121.6 KB
ID:	1061291

          Comment


            #6
            Hello saltminer,

            Thanks for your post.

            You are always welcome to write into PlatformSupport[at]NinjaTrader[dot]com, in this case, please mark Atten: Paul and include a link to this thread for reference.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by darkgreen, Today, 03:35 PM
            0 responses
            5 views
            0 likes
            Last Post darkgreen  
            Started by GTBrooks, Today, 02:44 PM
            2 responses
            12 views
            0 likes
            Last Post GTBrooks  
            Started by GLFX005, Today, 12:22 PM
            4 responses
            41 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by AspenHiker, Today, 08:37 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by MartinT, Yesterday, 01:12 PM
            3 responses
            17 views
            0 likes
            Last Post MartinT
            by MartinT
             
            Working...
            X