Announcement

Collapse
No announcement yet.

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;

      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.


          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          80 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          40 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          64 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          66 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          54 views
          0 likes
          Last Post CarlTrading  
          Working...
          X