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 Christopher_R, Today, 12:29 AM
        0 responses
        9 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,235 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        3 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        8 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,415 views
        0 likes
        Last Post Traderontheroad  
        Working...
        X