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 Skifree, Today, 03:41 AM
      1 response
      3 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      603 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      23 views
      0 likes
      Last Post xiinteractive  
      Started by Pattontje, Yesterday, 02:10 PM
      2 responses
      23 views
      0 likes
      Last Post Pattontje  
      Working...
      X