Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot0.Set not executed when overriding Plot()

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

    Plot0.Set not executed when overriding Plot()

    Hello,

    Here is the most basic code to display an indicator:

    PHP Code:
    protected override void OnBarUpdate()
    {
       
    // Use this method for calculating your indicator values. Assign a value to each
       // plot below by replacing 'Close[0]' with your own formula.
       
    Plot0.Set(Close[0]);
    }
    /*        
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
    {
    }
    */ 
    Plot0 is correctly displayed. Can someone explain why, as soon as overriding Plot() is uncommented, then nothing is displayed anymore :
    PHP Code:
    protected override void OnBarUpdate()
    {
       
    // Use this method for calculating your indicator values. Assign a value to each
       // plot below by replacing 'Close[0]' with your own formula.
       
    Plot0.Set(Close[0]);
    }
            
    public 
    override void Plot(Graphics graphicsRectangle boundsdouble mindouble max)
    {
       
    // Prevents Plot0.Set() in OnBarUpdate() to be executed ???

    So, when overriding Plot(), does it mean that Plot0.Set() cannot be used anymore ? This is strange, and I cannot understand if this is by design, or a mistake in my code.

    Thanks.

    #2
    Originally posted by fpa75 View Post
    Hello,

    Here is the most basic code to display an indicator:

    PHP Code:
    protected override void OnBarUpdate()
    {
       
    // Use this method for calculating your indicator values. Assign a value to each
       // plot below by replacing 'Close[0]' with your own formula.
       
    Plot0.Set(Close[0]);
    }
    /*        
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
    {
    }
    */ 
    Plot0 is correctly displayed. Can someone explain why, as soon as overriding Plot() is uncommented, then nothing is displayed anymore :
    PHP Code:
    protected override void OnBarUpdate()
    {
       
    // Use this method for calculating your indicator values. Assign a value to each
       // plot below by replacing 'Close[0]' with your own formula.
       
    Plot0.Set(Close[0]);
    }
            
    public 
    override void Plot(Graphics graphicsRectangle boundsdouble mindouble max)
    {
       
    // Prevents Plot0.Set() in OnBarUpdate() to be executed ???

    So, when overriding Plot(), does it mean that Plot0.Set() cannot be used anymore ? This is strange, and I cannot understand if this is by design, or a mistake in my code.

    Thanks.
    If you want the base Plot method to be called, then you must code it to be called.
    Code:
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) 
    {
       [B][COLOR=Blue]base.Plot(graphics, bounds, min, max); [/COLOR][/B]
       // the rest of your custom stuff. Or you can call base.Plot(...) last. Your choice.
    }

    Comment


      #3
      Hello fpa75,

      Thank you for your post and to Koganam for answering.

      Yes, you need to have base.Plot(graphics, bounds, min, max); in order to show any plots the indicator has

      Let me know if I can be of further assistance.
      Cal H.NinjaTrader Customer Service

      Comment


        #4
        Thanks. It works !

        Fabrice.

        PS: I have added another Plot (Plot1) and base.Plot(graphics, bound, min, max) displays both. As Cal H. says, this command tells the graphical rendering engine to display all the PlotXX in OnBarUpdate().

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X