• 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

Strategy can't draw HorizontalLine in the panel of an indicator it put on the chart

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

    Strategy can't draw HorizontalLine in the panel of an indicator it put on the chart

    I'm trying to get some horizontal lines to draw in the same panel as an oscillating indicator that my strategy draws. The strategy is applied to a chart.

    The code I'm using is:
    Code:
    Draw.HorizontalLine( StratMACD, "ThreshLine", threshold1, Brushes.Yellow, DashStyleHelper.Dash, 2, false );
    This same code works fine running the strategy in the strategy analyzer.

    What am I missing?

    Thanks!
    daqu40
    NinjaTrader Ecosystem Vendor - QTradez

    #2
    Hello daqu40,

    Is this being drawn from the strategy or the indicator?

    For this to appear in a secondary panel it would depend on which script draws it along with the DrawOnPricePanel property. https://ninjatrader.com/support/help...awOnPricePanel

    If the indicator is drawing it, you need DrawOnPricePanel = false for the object to follow the indicator.
    If the strategy is drawing it, I would likely suggest using a dummy indicator to draw the object and have the strategy add the indicator. This allows the indicator to use DrawOnPricePanel = false and the object can then follow the indicators panel.



    I look forward of being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      It's being drawn from the strategy. The strategy is attached to a chart. The strategy has several indicators that it adds to the chart with AddChartIndicator. These StrategyIndicators are added in State.DataLoaded.

      Per your suggestion I implemented DrawOnPricePanel. Setting it false to draw my lines and then back to true so my other objects will draw on the price panel.

      Doing this in State.DataLoaded results in no lines and no errors or output indicating there was an attempt to draw the lines but it failed.

      I also moved the code to OnBarUpdate and a section that only executes on the first tick of BarsArray[0]. This results in lines being drawn, but no matter what I do they end up in the price panel. Interestingly the Attach to property when I look these lines up in Drawing Objects (from the context menu on the chart) show that the lines are attached to StratMACD as they should be, but they are still being drawn in the price.

      Something else to note. I have 4 indicators that are on the price panel and three that have their own panels. Could something in this mix be causing my lines to be diverted to the price panel?

      Thanks.
      daqu40
      NinjaTrader Ecosystem Vendor - QTradez

      Comment


        #4
        Hello daqu40,

        Thank you for the additional details.

        From what I can gather you tried changing DrawOnPricePanel in the strategy is that correct? the DrawOnPricePanel would need to be set to false in the Indicator which is drawing the line from State.SetDefaults. That indicator also needs ot be in its own panel. Additionally toggling DrawOnPricePanel later past Defaults may not work as expected, There is actually a note in the help guide which may apply toward the use case you described.

        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().

        The general way to do what you are asking would be to create the following structure:

        Indciator: Draws line, uses DrawOnPricePanel = false, also has to use IsOverlay = false
        Straetgy: Adds indicator using AddChartIndicator, nothing else needed.

        We actually have a sample you could use to test some uses with strategy added indicators: https://ninjatrader.com/support/help..._a_ninjasc.htm
        This has a dummy indicator and shows a way to read values from your strategy which is a nice benefit. The configuration in this sample would essentially be what is needed to draw drawing objects in the secondary panel from the indicator. The indicator that uses IsOverlay false would be the indicator to look at from this zip.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks Jesse,

          So I need to create my own version of the indicators I'm using and have them draw the lines?

          If that's the case. Let's enter a feature enhancement to avoid this. It's more work than should be required. Especially since what I'm doing works just fine if I run this with the Strategy Analyzer.
          Last edited by daqu40; 12-02-2019, 06:32 PM.
          daqu40
          NinjaTrader Ecosystem Vendor - QTradez

          Comment


            #6
            Hello daqu40,

            Thank you for the reply.

            Correct to have it draw in the indicators panel would require an indicator and that it is programmed to use the secondary panel. A dummy indicator could be used with your strategy simply for drawing purposes, you wouldn't need to recreate your existing indicators but would need to read the data from your strategy using the dummy indicator so it can draw. The general take away from the sample I had linked was the strategy does the heavy lifting and the indicators simply read what the strategy is doing to plot in some custom way. The indicators can be configured independently from the strategy is why that is the suggestion.

            I will also put in a feature request for allowing a strategy to draw in any panel.

            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by faisamtrader, Today, 10:31 AM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_Tyler  
            Started by ChazJ, Today, 09:48 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by maxie, Today, 10:01 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Melissa  
            Started by Bionian, Today, 09:36 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by tomd, Today, 09:48 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Ariana  
            Working...
            X