• 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

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.
    https://www.dotnetperls.com/for
    https://www.dotnetperls.com/break

    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.
    https://ninjatrader.com/support/foru...builder-syntax

    And a link to the help guide on CurrentBar.
    https://ninjatrader.com/support/help...currentbar.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      thank you!!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Atilla, Today, 04:05 PM
      0 responses
      10 views
      0 likes
      Last Post Atilla
      by Atilla
       
      Started by Displacer, Today, 02:57 PM
      2 responses
      13 views
      0 likes
      Last Post Displacer  
      Started by SAILIKITY, 05-22-2019, 05:41 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by rmillar, 01-09-2019, 06:02 PM
      6 responses
      71 views
      1 like
      Last Post eDanny
      by eDanny
       
      Started by mlarocco, Today, 11:39 AM
      4 responses
      23 views
      0 likes
      Last Post mlarocco  
      Working...
      X