Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to create multiple bars range

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

    How to create multiple bars range

    I am using this below. I have a Length input which in this case is 6 but I would like to code that the Close minus the open of the Length input is calculated and then can be changed using the Length input ANY help appreciated. I know that on a RED bar that the Close - Open will create a negative for that part of the calculation (which is what I want - NOT looking for ATR calculations

    AverageBody[0] = ( ( (Close[0] - Open[0]) + (Close[1] - Open[1]) + (Close[2] - Open[2]) + (Close[3] - Open[3]) + (Close[4] - Open[4]) + (Close[5] - Open[5]) ) / Range_[Length] );

    #2
    Hello DTSSTS,

    Thanks for your notes.

    There are no supported NinjaScript methods or properties to accomplish this goal.

    You would have to come up with your own custom logic to go about accomplishing this specific goal in a script.

    This forum thread will be open for other community members to share their insights on custom logic you could consider using to accomplish this.
    <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
      I knew by your reply that it could be done. The way you worded made me instantly think of the solution.

      SMACloseLength = SMA(Close, Length);
      SMAOpenLength = SMA(Open, Length);


      (SMACloseLength[0] - SMAOpenLength[0])

      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      43 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      25 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      163 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      98 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      158 views
      2 likes
      Last Post CaptainJack  
      Working...
      X