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

Plot not showing in Strategy

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

    Plot not showing in Strategy

    Hi all,

    just wondering:

    I've added a plot to a strategy and don't see why this plot isn't showing up in the chart.

    Even it got values in OnBarUpdate() via:
    AverageEntry[0] = 30000;


    and i have in
    (State == State.SetDefaults):
    AddPlot(Brushes.Aqua, "AverageEntry");


    and at the bottom of the strategy I have

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> AverageEntry
    {
    get { return Values[0]; }
    }


    In the databox I can seen, that the plot is set


    Click image for larger version

Name:	2021-07-29 19_22_45-Data Box.png
Views:	149
Size:	1.2 KB
ID:	1165718

    What am I doing wrong?

    Thanks in advance.


    #2
    Hello Airwave,

    Thank you for the post.

    Just to confirm, did you remove and re apply the strategy after adding the plot?

    The other item which could make a plot not show up would be if you used OnRender, do you use OnRender in the strategy?

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

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Just to confirm, did you remove and re apply the strategy after adding the plot?
      Yes I did.

      Originally posted by NinjaTrader_Jesse View Post
      The other item which could make a plot not show up would be if you used OnRender, do you use OnRender in the strategy?
      Yes exactly. I'm using this for screenshots like in your
      TakeScreenshotAfterOrderAccepted.zip
      example.

      Tested to comment out OnRender Event. Yes, then the plot is showing up.
      How can I get it shown with the OnRender event?

      Thanks in advance.

      Comment


        #4
        Hello Airwave,

        Thanks for confirming that.

        If you used OnRender you very likely just need to add a call to the base class:

        Code:
        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
        {
        // call the base.OnRender() to ensure standard Plots work as designed
        [B]base.OnRender(chartControl, chartScale);[/B]
        
        // custom render logic
        }
        Can you confirm you have that as the first line in your OnRender?

        That line can be commented out for scripts which should hide plots but still render.

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

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Can you confirm you have that as the first line in your OnRender?
          Great, that did the trick.

          Now I can see the plot.

          ---

          On additional question.

          When a plot is 0, can I don't show the plot when it is 0?
          So that I don't have this "jumps" in the chart?

          Click image for larger version

Name:	2021-07-29 19_58_57-Chart - BBA_BTCUSD.png
Views:	151
Size:	41.3 KB
ID:	1165730

          Comment


            #6
            Hello Airwave,

            Thank you for the reply.

            If the value you are setting to the plot is 0 and you don't need the 0 values for any purpose (strategy reading for signals) then you could use a condition before setting the plot:
            Code:
            if(myValue > 0)
            Values[0][0] = myValue;
            An alternative would be setting that plot to transparent


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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by algospoke, 04-17-2024, 06:40 PM
            5 responses
            46 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by arvidvanstaey, Today, 02:19 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Started by mmckinnm, Today, 01:34 PM
            3 responses
            5 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by f.saeidi, Today, 01:32 PM
            2 responses
            8 views
            0 likes
            Last Post f.saeidi  
            Started by alifarahani, 04-19-2024, 09:40 AM
            9 responses
            55 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X