Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Declaration of AddLine/AddPlot for array datas

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

    Declaration of AddLine/AddPlot for array datas

    I would like to plot datas that I am storing in an array (variable length)

    In (State == State.SetDefaults), I did not find any other way to declare AddLine/AddPlot for every possible position in the array :
    Code:
    AddPlot(new Gui.Stroke (myBrush, Gui.DashStyleHelper.Dot, 1), PlotStyle.Line, "L0");
    AddPlot(new Gui.Stroke (myBrush, Gui.DashStyleHelper.Dot, 1), PlotStyle.Line, "L1");
    etc.
    For example, if I would have an array of 50 lines, then there would be 50 manual AddLine/AddPlot declarations.

    The issue is when the array size is increased beyond the maxi number of Line/Plot declarations;
    if there is not enough manual declarations, the script does not add them for plotting the additional Values[position][0]

    Does anyone have any suggestion?
    I am using NT8 RC1

    #2
    Hello alizes,

    What is the limit that you are running into as the Max number of lines?

    I've added 50+ lines but I did not hit a limit of the number of lines that can be added to an indicator using the Strategy Builder.

    Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Thank you for your answer.

      A) Actually, there may be a misunderstanding about "limit".
      I do not hit any limit when I declare the AddPlot/line, and it works very good.
      In your screencast, you are using the Strategy Builder;
      I do the same by copying directly the script in the Editor.
      So basically, one could create 100 or 1000 declarations ... I guess there is no limit for this.

      When I wrote about the "maxi number", I was trying to say that you have to stop creating manually the number of AddPlot/Line declarations (it's manual) by planning what would be the maxi extent you think the array could reach.
      In other words, you create more AddPlot/Line than necessary, and you have to limit the array size to not go beyond tha number of plots declared.

      My first post was to ask if there was any other way to "adapt" the number of AddPlot/Line declarations according to the array Length.

      Also, to answer your question in the screencast, I am creating my own array.
      The array has a variable length (could be 10, or 100, or more) initialized in State.Configure

      B) In the meantime, I may have found a solution to my first post.
      I tried the following script:

      Code:
      if (State == State.SetDefaults)
      {
      ArrayLength = 60;
      for (idx = 0; idx < ArrayLength; idx++)
      AddPlot(new Gui.Stroke (myBrush, Gui.DashStyleHelper.Dot, 1), PlotStyle.Line, "Plot"+idx.ToString());
      }
      else if (State == State.Configure)
      {
      myArray = new double[ArrayLength];
      }
      I don't know if State.Default was designed to accept this, but it seems to work.

      Comment


        #4
        Hello alizes,

        Yes, as I didn't have your code, I wanted to be sure that if you were using the Strategy Builder to generate the code that adding code by hand wasn't confusing.

        And absolutely, use a loop.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by RichardHK, 08-22-2024, 09:02 AM
        4 responses
        60 views
        0 likes
        Last Post RichardHK  
        Started by HGTrader, Today, 09:31 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Gibranes, 10-12-2024, 04:02 AM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by dbennett3, Today, 09:18 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by cupir2, Yesterday, 05:27 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X