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

Comparing bar lows/highs

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

    Comparing bar lows/highs

    I would like to compare the lows/highs of previous bars, but have no idea how to accomplish this. So say the Low[9] was 700 and Low[0] is 705. What code could be written to compare those numbers and recognize that the Low[0] was higher than Low[9]?
    Any help would be greatly appreciated.

    #2
    Hello,

    Thanks for the forum post.

    To check these two bars I would check this.

    if (Low[0] >= Low[9])
    {

    //Do something since the Low[0] is greater then or equal to the Low of 9 bars back.

    }


    If you dont know what bar you want to compare you can use this indicator to do this as well.



    if(Low[0] > MIN(9)[0])
    {
    // The current low is greater then all the lows of the last 9 bars if this check is successfull

    }

    Let me know if I can be of further assistance.

    Comment


      #3
      Thanks for the reply Brett. Great solution. Your second suggestion is along the lines of what I was looking for. I'm trying to find specific lows/highs that deal with the RValueCharts indicator. Specifically when (RValueCharts(Color.Blue, 3, 3).VClose[0] <= -4 ) or (RValueCharts(Color.Blue, 3, 3).VClose[0] >= 4 ) So when the RValueCharts VClose is +/- 4 I would like to know what the Low/High of that bar is and then be able to compare that to future bars. Your suggestion is wonderful. Could you give me an example of how to combine these two ideas? Thanks.

      Comment


        #4
        if(Low[0] > MIN(RValueCharts(Color.Blue, 3, 3).VClose[0], 9)[0])
        {
        // The current low is greater then all the lows of the last 9 bars if this check is successfull

        }

        The above should do the trick. Min will work with your custom indicators as well.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by llanqui, Yesterday, 09:59 AM
        4 responses
        22 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by smartromain, 03-13-2024, 01:42 AM
        5 responses
        93 views
        0 likes
        Last Post AndreiBig  
        Started by Noerclou, Today, 04:55 AM
        0 responses
        5 views
        0 likes
        Last Post Noerclou  
        Started by ThoriSten, Today, 03:56 AM
        0 responses
        6 views
        0 likes
        Last Post ThoriSten  
        Started by PhillT, 04-19-2024, 02:16 PM
        3 responses
        26 views
        0 likes
        Last Post mangel2000  
        Working...
        X