Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic Plot Identifiers

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

    Dynamic Plot Identifiers

    Is it possible to dynamically change Plot identifiers?
    For example,

    Code:
    int number;
    switch (lookup)
    {
        case 1:
            number = 1;
            break
        case 2:
            number = 2;
            break;
    }
    Values[number][BarRef] = BarValue[lookup];

    #2
    Hello Zeos6,

    Yes, there would not be a problem doing that.

    I put together a sample indicator similar to yours in which you can apply to a chart and test by entering either a 1 or 2 in the UI when applying the indicator, and it'll switch which plot is set / the plot color.

    Please let us know if you need further assistance.

    To Import a NinjaScript into NinjaTrader 8 do the following:
    From the Control Center window select Tools -> Import-> NinjaScript...
    Find the file location.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi Alan_P,

      Thank you, your reply is useful. I however had a different intent for this. I wanted to simply use a single Plot statement in place of two. That is, instead of writing..

      int number; switch (lookup)
      {
      case 1:
      Values[1][BarRef] = BarValue[n];
      break;
      case 2:
      Values[2][BarRef] = BarValue[m];
      break;
      }

      I was looking to simplify writing Plot statements as I have a lot, about 50.

      Any suggestion on how I might be able to automate the indexers for Plot statements?

      Comment


        #4
        Hello Zeos6,

        So I can best answer your question, you want to have 1 plot and be able to change what value it is set to with a switch statement? If not, could you please provide more information?

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Hi AlanP,

          No. Essentially I want to set the values for multiple Plots using one Plot statement, by changing the Plot identifier via a switch statement. Therefore I want to use the switch statement to specify which Plot value is being set.

          Comment


            #6
            Hello Zeos6,

            This would not be possible.

            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by Zeos6 View Post
              Hi Alan_P,

              Thank you, your reply is useful. I however had a different intent for this. I wanted to simply use a single Plot statement in place of two. That is, instead of writing..

              int number; switch (lookup)
              {
              case 1:
              Values[1][BarRef] = BarValue[n];
              break;
              case 2:
              Values[2][BarRef] = BarValue[m];
              break;
              }

              I was looking to simplify writing Plot statements as I have a lot, about 50.

              Any suggestion on how I might be able to automate the indexers for Plot statements?
              So what is the problem then? The way that you detailed in your original post looks like the way to go about it. Does it not work correctly?

              Comment


                #8
                Hi koganam,

                It actually does work as indicated. Thanks for pointing it out. There were other issues that prevented the plots from functioning correctly. In fact you can also do the following:

                Code:
                int number;
                switch (lookup)
                {
                    case 1:
                        number = 1;
                        break;
                    case 2:
                        number = 4;
                        break;
                }
                Values[number+0][BarRef] = BarValue[lookup];
                Values[number+1][BarRef] = BarValue[lookup];
                Values[number+2][BarRef] = BarValue[lookup];
                It's pretty handy.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                650 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                370 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                577 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X