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

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.
    Brandon H.NinjaTrader Customer Service

    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
        Brandon H.NinjaTrader Customer Service

        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 fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          7 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X