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

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:	201
Size:	35.6 KB
ID:	1061236

        [ATTACH]n1061237[/ATTACH]
        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:	222
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 pechtri, 06-22-2023, 02:31 AM
            9 responses
            122 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by frankthearm, 04-18-2024, 09:08 AM
            16 responses
            66 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by habeebft, Today, 01:18 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by benmarkal, Today, 12:52 PM
            2 responses
            15 views
            0 likes
            Last Post benmarkal  
            Started by f.saeidi, Today, 01:38 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X