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 Tin34, Today, 03:30 AM
        2 responses
        16 views
        0 likes
        Last Post Tin34
        by Tin34
         
        Started by sastrades, Yesterday, 09:59 AM
        2 responses
        31 views
        0 likes
        Last Post brucerobinson  
        Started by ETFVoyageur, Today, 12:52 AM
        1 response
        16 views
        0 likes
        Last Post Leeroy_Jenkins  
        Started by lollers, Today, 03:26 AM
        0 responses
        12 views
        0 likes
        Last Post lollers
        by lollers
         
        Started by aliyahany, Today, 03:16 AM
        0 responses
        4 views
        0 likes
        Last Post aliyahany  
        Working...
        X