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

Logic Question bars with same low

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

    Logic Question bars with same low

    I am trying to write some code that will help me identify certain patterns on a chart. I am hoping someone can help me.

    I would like to identify a series of bars that have the same lows, but obviously they all cant be equal. So I am trying to find a series of bars (all in a row) where lets say 8 out of 10 all have the same low.

    I am thinking there is a way to create an object that i can iterate thru to check values and set flags. Can someone point me in the correct direction?

    Thanks in advance

    #2
    You could create a HashTable or any other .NET collectiont hat can store a key and value pair, then you can iterate through the last 10 bars, store the key (price) and the value, the number of times you have seen this price. Then you can iterate through the HashTable to see if any of the objects contain values greater than X?
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray, this is what i actually wound up doing:
      Code:
      [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] x = 0; 
      [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] trueOccur = 0;
      
      [/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// Condition set 1
      [/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]do[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] 
      { 
      [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (Low[x+1] == Low[0])
      {
      trueOccur = trueOccur + 1;
      }
      [/SIZE][SIZE=2]
      x = x + 1; 
      } 
      [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]while[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (x < barsTested);
      
      
      [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (trueOccur >= barsLowEqual)
      {
      Do something here[/SIZE][SIZE=2]
      }
      [/SIZE]

      Comment


        #4
        Got it. My approach is if the last lows did NOT have to equal the current low, which is what it looks like you are doing.
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ScottWalsh, Today, 06:52 PM
        3 responses
        19 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        19 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        1 view
        0 likes
        Last Post cre8able  
        Started by Haiasi, Today, 06:53 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottW, Today, 06:09 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X