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

How to use Draw.HorizontalLine in the indicator panel from a strategy

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

    How to use Draw.HorizontalLine in the indicator panel from a strategy

    I'm trying to draw a horizontal line in the indicator panel from my strategy but it always get put in the 1st chart area where the prices are. I dont see any way in the documentation to change it to another panel.

    protected override void OnBarUpdate()
    {
    Draw.HorizontalLine(this,"line"+CurrentBar.ToStrin g(),4000,Brushes.DeepPink);
    }

    #2
    The trick is on IsOverlay (Bool)
    You can change in the State == State.SetDefaults.

    Code:
    if (State == State.SetDefaults)
    {
    IsOverlay = true;
    
    }
    When it is true, it will appear on your 1st chart which is with the bar chart.

    Comment


      #3
      Hello kazisl,

      Thanks for your post.

      In order to draw in an indicator panel, as forum member cincai advised, you would need to have the strategy create its own indicator panel. IsOverlay tells the strategy to create an indicator panel and any "Plots" created by the strategy would be sent to that panel. Please note that to use Draw methods to draw objects in that indicator panel, you would also have to use DrawOnPricePanel = false as this would direct draw objects to the strategy-created indicator panel.

      You would not be able to draw in a panel that was not created by the strategy.

      References;

      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Got it, I see, It draws on the indicator panel now. Is there a way to draw on both price panel and indicator panel in the same strategy since that boolean can only be changed at the beginning?

        Comment


          #5
          Hello kazisl,

          Thanks for your reply.

          Even though the bool is set in OnStateChange(), you can set it in OnBarUpdate() as well.

          Just before you want to draw on the price panel set DrawOnPricePanel = true, then your draw code for the price panel, then back to DrawOnPricePanel = false for your indicator panel drawing.


          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by MarianApalaghiei, Today, 10:49 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by love2code2trade, Yesterday, 01:45 PM
          4 responses
          28 views
          0 likes
          Last Post love2code2trade  
          Started by funk10101, Today, 09:43 PM
          0 responses
          8 views
          0 likes
          Last Post funk10101  
          Started by pkefal, 04-11-2024, 07:39 AM
          11 responses
          37 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Yesterday, 08:51 AM
          8 responses
          46 views
          0 likes
          Last Post bill2023  
          Working...
          X