Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

price of candle going through sma for four candles. is there code for this?

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

    price of candle going through sma for four candles. is there code for this?

    i'm trying to code an automated strategy that involves price of a candle running through an sma line. is there logic for this? i'm trying to have price of candle go through sma of low 3 four times. then on fifth candle the whole candle is below the sma. is there code for that? from bars ago it reads the 1st candle is completely below the sma. 2,3,4,5 bars ago price of candle intersects sma.

    #2
    Hello SteveReiza,

    Thanks for your post.

    I am not certain I understand exactly what you want to accomplish based on the information provided.

    When you mention "sma of low 3 four times" are you referring to the Low price being less than the SMA indicator plot?

    Could you please provide a screenshot demonstrating exactly what you are trying to accomplish so we may accurately assist?
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      thanks for reply. i attached what i was referring to. there is three candles that have a bollinger line go through them. that's what i'd like to code. there is an instance of four candles like this on a keltner channel line that i want to make into a strategy - i scratched the sma idea.
      Attached Files

      Comment


        #4
        Hello SteveReiza,

        Thanks for your notes.

        You could check if the Bollinger().Middle[0] plot is less than the High[0] price of the bar and create a condition checking if the Bollinger().Middle[0] plot is greater than the Low[0] price of the bar. This would need to be checked for barsAgo 0, barsAgo 1, and barsAgo 2 to check for 3 bars in a row.

        The CountIf() method could be used to accomplish this by surrounding the single condition with (condition1 && condition2).

        See this help guide documentation for more information about the CountIf() method and sample code: https://ninjatrader.com/support/help...t8/countif.htm
        Bollinger: https://ninjatrader.com/support/help...nger_bands.htm
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          oh that's awesome. yes! that's what i was looking for. many thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          566 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          330 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          548 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X