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 the maximum of a plot

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

    Plot the maximum of a plot

    Let's see if there is any way to do the following and anybody give me a hint or post an example or another indicator:

    Imagine an indicator with one plot, Plot0, (plotstyle.Bar) that in realtime is going up or down depending on the code, for example the volume or another thing that vary its value as the bar progress. So my question is: is there any way of adding another Plot1 that plots the maximum of Plot0?.

    Take a look to the attached picture to see what I need to get.

    Thanks in advance
    Attached Files

    #2
    Hello Sangui,
    Yes, you can do it by adding another plot (say Plot1) and then setting the Maximum value for it. A sample code will be like.

    Code:
    Plot0.Set(your value for Plot0)
    Plot1.Set(Math.Max(Plot1[0], Plot0[0]));


    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Hello Joydeep,

      I have done what you say but with bad results. My intention is to plot some kind of Tape Speed and its maximum value, by combining OnMarketData(MarketDataEventArgs e) and OnBarUpdate().

      Plot0 that is the speed is well displayed but the problem is with the maximum (Plot1) that seems to take the value of the price (very rare...).

      Look at the attached chat to see what I mean please.

      The code is something like this: (with COBC=false

      #region Variables:

      public int tradescounter=1;

      protected override void OnBarUpdate()
      {
      if (Historical) return;
      if (CurrentBar<1) return;

      if (FirstTickOfBar) tradescounter=1;

      Plot0.Set(tradescounter/Bars.PercentComplete);
      Plot1.Set(Math.Max(Plot0[0],Plot1[0])); // This is the one that seems to take the value of the price instead of the maximum value of Plot0...

      }

      protected override void OnMarketData(MarketDataEventArgs e)
      {
      if (e.MarketDataType == MarketDataType.Last) tradescounter=tradescounter+1;
      }

      Please, help me to understand what I am doing wrong.

      Thanks again and regards,
      Sangui
      Attached Files

      Comment


        #4
        Hello Sangui,
        Before assigning the value to the Plot1 please make sure it contains a valid value or not.
        Code:
        if (Plot1.ContainsValue(0))
        	Plot1.Set(Math.Max(Plot0[0], Plot1[0]));
        else Plot1.Set(Plot0[0]);
        If you Print out the value of Plot0[0] then what values you are getting.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          It seems it is OK now. Thanks a lot.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by andrewtrades, Today, 04:57 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          6 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          436 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          8 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X