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

Issue With ContainsValue(0) And Swing High

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

    Issue With ContainsValue(0) And Swing High

    I want the condition for when a Swing High is NOT plotted. However:

    myBoolSeries.Set(Swing(Strength).SwingHigh.Contain sValue(0));



    ALWAYS returns "true" even when Swing high shows "N/A" in the chart data box. Shouldn't it return "false" when Swing high is "N/A?"

    What am I misunderstanding?
    Last edited by ScorpioTravis; 03-04-2022, 01:49 PM.

    #2
    Hello ScorpioTravis,

    Thanks for your post.

    To see if a Swing().SwingHigh[] plot has been plotted, you would simply need to create a condition that checks for the last swing high to appear and then set your bool to true.

    You could see the Swing().SwingHigh[0] value by printing out the SwingHigh plot value and checking the Output window.

    For example, you could create a condition that checks if the Swing().SwingHigh[0] plot of the Swing indicator is greater than the current Close price and set your bool to true. Otherwise, the bool would be set to false.

    See the help guide documentation below for more information.
    Swing: https://ninjatrader.com/support/help.../nt7/swing.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Why doesn't ContainsValue() work? Why does it always return TRUE even when SwingHigh = N/A?

      Comment


        #4
        Hello ScorpioTravis,

        Thanks for your note.

        The SwingHigh plot of the Swing indicator will read N/A in the Daxa Box window when there is a bar without a swing high. This does not necessarily mean that the SwingHigh plot does not contain a value.

        Swing().SwingHigh.ContainsValue(0) will return true as long as there is a value assigned to SwingHigh. This would include a value of 0 since 0 is still a value.

        If you print out the value of the SwingHigh plot ( and print out Swing().SwingHigh.ContainsValue(0), you could see the value of the SwingHigh plot, and when there is a value you will see Swing().SwingHigh.ContainsValue(0) returns true.

        Code:
        Print(Swing(5).SwingHigh[0]);
        Print(Swing(5).SwingHigh.ContainsValue(0));
        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Are you saying N/A is a value? It seems it must be because Swing().SwingHigh.ContainsValue(0) ALWAYS returns true. Thanks.

          Comment


            #6
            Hello ScorpioTravis,

            Thanks for your note.

            If the SwingHigh plot reads N/A in the Data Box this means that there is no current SwingHigh. If you add the Swing indicator to a chart window, you could see that the SwingHigh plot is indicated by a green dot drawn on the chart above the bar.

            If there is a bar that does not have a green dot drawn above it, this indicates that there is no current swing high based on the 'Strength' parameter being passed to the indicator and the Data Box SwingHigh plot will read N/A. This does not mean that the SwingHigh plot does not contain a value. It simply means there is no current swing high based on the 'Strength' parameter set. This could be seen by printing the values mentioned in my previous post.

            Let us know if we may assist further.
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by TraderBCL, Today, 04:38 AM
            2 responses
            16 views
            0 likes
            Last Post TraderBCL  
            Started by martin70, 03-24-2023, 04:58 AM
            14 responses
            106 views
            0 likes
            Last Post martin70  
            Started by Radano, 06-10-2021, 01:40 AM
            19 responses
            609 views
            0 likes
            Last Post Radano
            by Radano
             
            Started by KenneGaray, Today, 03:48 AM
            0 responses
            5 views
            0 likes
            Last Post KenneGaray  
            Started by thanajo, 05-04-2021, 02:11 AM
            4 responses
            471 views
            0 likes
            Last Post tradingnasdaqprueba  
            Working...
            X