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.

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.
    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 futurenow, 12-06-2021, 05:49 PM
        19 responses
        971 views
        0 likes
        Last Post Redders
        by Redders
         
        Started by Josephina55, 06-14-2025, 06:30 PM
        0 responses
        17 views
        0 likes
        Last Post Josephina55  
        Started by mathfrick2023, 05-08-2025, 12:51 PM
        8 responses
        77 views
        0 likes
        Last Post Yogaman
        by Yogaman
         
        Started by several, 04-22-2025, 05:21 AM
        2 responses
        250 views
        0 likes
        Last Post Lukasxgtx  
        Started by cherkoul, 06-12-2025, 11:21 PM
        0 responses
        18 views
        0 likes
        Last Post cherkoul  
        Working...
        X