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

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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        939 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        7 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        4 views
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        28 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        33 views
        0 likes
        Last Post wzgy0920  
        Working...
        X