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

Draw rectangle around 3-7 candles with conditions.

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

    Draw rectangle around 3-7 candles with conditions.

    Hello everyone.

    I'm looking to make a simple indicator. Here are the functionality i would like to program in:

    1. Check candles from right to left, find a mimimum of 3, maximum of 7, basing candles (like the yellow highlighted region, shown in the image below).
    2. Once found, draw a rectangle around the bodies of these candles, including the wicks. (if there are more than 7 basing candles, don't draw anything)
    3. Repeat step one.
    4. Repeat step two
    5. if the second rectangle clashes with the first one, delete the first rectangle
    6. Continue the check, until all candles viewable by the user on whichever timeframe has been complete.

    I'm having two problems right now.
    1. I don't know how to loop that candle check across the entire chart for a minimum of 3 candles.
    2. how would i create it in a way that it is able to spot a set of basing candles or a consolidation zone?

    Are there any indicators similar to this already out there?


    #2
    Hello amueller,

    You can use a loop and loop from the CurrentBar to bar 0 decrementing by 1 on each pass.

    Below is a public link to a 3rd party educational site on for loops and break.
    Iterate over numbers with for. Increment or decrement an index int from a start to an end value.

    Stop loops with the break keyword. Use break to end a block in a switch statement.


    You can use an int counter that is incremented when a condition is true, or set back to 0 if not true. When the counter reaches 3 (or the value you would like) you can break the loop and save the bar number to a variable.

    Below is a link to an example of a counter.


    And a link to the help guide on CurrentBar.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      thank you!!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by geotrades1, Today, 10:02 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by ender_wiggum, Today, 09:50 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by rajendrasubedi2023, Today, 09:50 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by bmartz, Today, 09:30 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by geddyisodin, Today, 05:20 AM
      3 responses
      26 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X