• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Syntax Translation

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

    Syntax Translation

    Hello,

    can anyone please "translate" me from the line in a code

    "while ( swingHighRays.Count != 0 && (Input is Indicator ? Input[0] : High[0]) > tmpRay.StartAnchor.Price)"

    the snippet "... && (Input is Indicator ? Input[0] : High[0]) > ..."


    Thank you
    Tony

    #2
    Hello tonynt,

    The Input is Indicator part is checking to see if you have supplied another indicator as the input series to this indicator.

    If the input series is an indicator, then it uses the Input[0] which is the plot series for that indicator.

    If the input series is not an indicator and is instead a data series, then it uses the High[0] from the bar.

    Also, below is a public link to the Microsoft documentation on ternary operators.
    https://docs.microsoft.com/en-us/dot...ional-operator
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      thank you for your reply. Today I successfully modified an indicator from the ninjatraderecosystem/app-share page to plot the rays with different conditions. But I still have a problem with removing the rays correctly when price touches the ray. In the code is
      Ray tmpRay = null;
      if ( swingHighRays.Count != 0 )
      {tmpRay = (Ray)swingHighRays.Peek();}
      while ( swingHighRays.Count != 0 && (Input is Indicator ? Input[0] : Highs[1][0]) > tmpRay.StartAnchor.Price)
      {RemoveDrawObject(tmpRay.Tag);
      .....

      As the rays are not remvoved with touch of price I tried different ways eg
      while ( swingHighRays.Count != 0 && Lows[1][0]< tmpRay.StartAnchor.Price && Highs[1][0] >= tmpRay.StartAnchor.Price)
      but then there are no rays plotted in the chart.


      Thank you!
      Tony
      Attached Files

      Comment


        #4
        Hello tonynt,

        As far as removing a drawing object using the handles .Tag, this is fine to do.

        I've made a very quick example that just deletes a horizontal ray (so I don't have to calculate slope) using the .Tag of the ray if the price has a cross above or cross below on the price of the last anchor.
        The drawing object is successfully being removed.

        An example with some custom logic for using slope to project the line on each new bar can be found here.
        https://ninjatrader.com/support/foru...663#post828663
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          thank you for your reply. But with this it does not remove the Ray from a list when price crosses.
          I thought I could show this with the lines above.

          Thank you!
          Tony

          Comment


            #6
            Hello Tony,

            The example removes a ray when the price crosses the end anchor price of the ray.

            This is only meant to demonstrate that a ray can be removed by supplying the .Tag.

            Are you testing this example and finding the ray is not being removed in real-time when the price crosses the ray?

            I'm not seeing any previous mentions of using a List<Ray> object. What list are you referring to?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello Chelsea,

              thank you for your reply. I reduced a sample with a list to the very minimum.

              With the code to remove the ray when price is equal or higher there are no rays plotted (we need this also for days loaded to identify certain pivots and remove the ray when its touched)

              Thank you!
              Tony
              Attached Files

              Comment


                #8
                Hello Tony,

                In the script you have provided, the myList elements are never used after they are added. This might as well not be in the code as it does nothing.

                If you are interested in when the condition is evaluating as true, add prints to the script to understand the behavior.

                Below is a link to a forum post that demonstrates how to use prints to understand behavior.
                https://ninjatrader.com/support/foru...121#post791121

                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Chelsea,

                  the Highs are added as doubles "top" to the list and a ray is drawn with each of them.

                  I dont know what you mean with never used. They are used for the rays. (screenshot)

                  Once price is above an element of the list the corresponding ray should be removed. I´m trying to resolve this from NT7 to NT8 now and never found a sample. If I work with many doubles instead of a list each with a proper name then it can be removed easily. But in helpguide and samples I did not find how to access them from a list to remove.

                  Thank you!
                  Tony
                  Attached Files
                  Last edited by tonynt; 06-20-2019, 01:15 PM. Reason: correction of translation

                  Comment


                    #10
                    Hello Tony,

                    Here is how the data from the list would be called:

                    Print( myList[0].Tag );

                    The list has items added to it, but the data in the list is never used.

                    Here is the code for the indicator call:
                    Draw.Ray(this,"top" + CurrentBar, false,-1,High[0], -300,High[0],Brushes.Blue,DashStyleHelper.Dash,2);

                    Notice that myList isn't called here.

                    Below is a public link to an educational site on List<> objects.
                    https://www.dotnetperls.com/list
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Chelsea,

                      thank you for your reply. I know how to print it in output window.
                      And I will write with streamwriter to a file as well. But thats not the question, so its not in this reduced sample.

                      I do not understand why you post me the line from the indicator "Draw.Ray...."

                      This sample the indicator is plotting the ray every time the condition is true and that is working ok. And the values "top" are added to the list. Yes?

                      This is the purpose of the indicator. I worked with that landingpage "dotnetperls" already. And I can print in output window what I want.

                      But what is not on "dotnetperls" (and not in NT helpguide) is how the drawing object with a double from the list can be removed (with the simple condition when price crosses the double/ray)

                      With dotnetperls samples I can modify the list, remove items....but there is no help how to remove a drawobject built with an item of the list.

                      Thank you!
                      Tony
                      Last edited by tonynt; 06-20-2019, 03:38 PM. Reason: add info

                      Comment


                        #12
                        Originally posted by tonynt View Post
                        Hello Chelsea,

                        the Highs are added as doubles "top" to the list and a ray is drawn with each of them.

                        I dont know what you mean with never used. They are used for the rays. (screenshot)

                        Once price is above an element of the list the corresponding ray should be removed. I´m trying to resolve this from NT7 to NT8 now and never found a sample. If I work with many doubles instead of a list each with a proper name then it can be removed easily. But in helpguide and samples I did not find how to access them from a list to remove.

                        Thank you!
                        Tony
                        Pretty much the same question is answered by this code. You want to read the thread in order to follow the context.

                        ref: https://ninjatrader.com/support/foru...429#post594429

                        Comment


                          #13
                          Hello tonynt,

                          If you were to completely remove the myList declaration and any mentions of it from the script you have shared, the script would function exactly the same.

                          myList has elements added to it, but these items are then abandon and never used again.

                          I posted the Draw.Ray() call as this in the script and has absolutely no mentions of myList in the method call. myList is not being used.


                          What are you wanting to achieve?

                          Are you wanting to remove items by looping through a list?

                          For example:
                          RemoveDrawObject(myList[0].Tag);
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello Chelsea,

                            yes, this is the only thing I want "remove items by looping through a list". When CurrentAsk() is equal or higher the price of the ray then remove the ray (and the value in the list). Thats all. I know it could be done with RemoveDrawObject(myList[0].Tag); but because of many rays and plotted also historically when conditions were true in loaded days we dont know ".Tag". So we can not remove "rayX" + CurrentBar. If there would be only few rays then there would not be the thread about because this could be handled directly. Trying for days (weeks with NT7) find out how to do by helpguide, forum, sample, c# sites, I can not remove the ray touched when there are many rays in the chart.

                            Thank you!
                            Tony
                            Last edited by tonynt; 06-23-2019, 09:12 AM. Reason: translation error

                            Comment


                              #15
                              Hello Tony,

                              I'm not clearly understanding. Can we simplify what you are wanting to achieve?

                              Are you trying to find a specific drawing object by recording the CurrentBar and finding it with the tag name?

                              Are you trying to increment a variable to draw multiple drawing objects with different tag names?
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by learningnt, Today, 10:52 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post learningnt  
                              Started by CandySNK, Today, 10:24 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post CandySNK  
                              Started by user1986, Today, 07:28 PM
                              2 responses
                              11 views
                              0 likes
                              Last Post NinjaTrader_EricB  
                              Started by ericson, Today, 08:14 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post ericson
                              by ericson
                               
                              Started by jertrade, Today, 06:57 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post jertrade  
                              Working...
                              X