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

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 kevinenergy, 02-17-2023, 12:42 PM
                116 responses
                2,757 views
                1 like
                Last Post kevinenergy  
                Started by franatas, 12-04-2023, 03:43 AM
                7 responses
                106 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by jpapa, Today, 07:22 AM
                0 responses
                3 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by Jltarrau, Today, 05:57 AM
                3 responses
                8 views
                0 likes
                Last Post Jltarrau  
                Started by f.saeidi, Today, 05:56 AM
                2 responses
                8 views
                0 likes
                Last Post NinjaTrader_Erick  
                Working...
                X