Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

for loop prices from currentbar

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

    for loop prices from currentbar

    Hello,

    From Close.GetValueAt(CurrentBar) i can get the actual trading price.

    I would like to get all the prices below that currentbar in a range of 10 points.

    If
    Close.GetValueAt(CurrentBar) = 3016, i need all the prices between 3016 and 3006 ;

    3016, 3015.75, 3015.5, 3015.25, 3015, 3014.75, etc.

    Is there a loop that allow to do that?

    Cant do that:






    Code:
     double closes = Close.GetValueAt(CurrentBar);
       for (double d = closes; d <= closes + 10; d+= 0.25D)
                    {
    
    
                      Print(d);
    
    
                    }
    Thanks
    Last edited by frankduc; 09-19-2019, 11:41 AM.

    #2
    Hello frankduc,

    What you have shown could be used to loop over a range of prices at a fixed interval. Was something not working with this or what is your specific question here?

    In the code you provided you are adding to the value, did you mean to subtract from the value similar to the prices you presented? If so, you can use a minus symbol to subtract instead of using the plus symbol: -=

    I see you are also using specific values, did you intend to offset the price with an amount of Ticks? You would need to use the TickSize if so: Close[0] +/- 10 * TickSize;

    If you are having difficulty understanding the loop portion of this, you may additionally look at external C# "for loop" tutorials or guides, this type of loop would not be something that would be documented or pre made in NinjaScript.


    Please let me know if I may be of additional assistance.

    Comment


      #3
      I did an edit of the for loop i dont know if you saw the right one. Here it is again. Looks like its working. It gives me 10 tick under 3016 by interval of .25.

      Code:
      [LEFT][COLOR=#252C2F][FONT=Courier][SIZE=12px]double closes = Close.GetValueAt(CurrentBar);
         for (double d = closes; d <= closes + 10; d+= 0.25D)
                      {
      
      
                        Print(d);
      
      
                      }[/SIZE][/FONT][/COLOR][/LEFT]

      I am not sure what you mean by ticksize, is
      TickSize a NT code?

      Close[0] +/- 10 * TickSize;

      Thanks for the info Jesse

      Comment


        #4
        Hello frankduc,

        I would suggest to only post new replies if you have new information to provide. We try to answer posts quickly so if you are making edits while we are replying we likely wont get that edit. A new post preserves the order of the information so we can at least see that we missed something that you added. An edit also does not notify our support that the ticket was updated, only new replies.

        TickSize is a NinjaScript property: https://ninjatrader.com/support/help...htsub=TickSize



        Please let me know if I may be of further assistance.

        Comment

        Latest Posts

        Collapse

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