Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Recalling order's bar information

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

    Recalling order's bar information

    Hi there,
    I have a question about recalling the number of the bar where an order was placed in Ninjascript. Let's say I submit an order at bar number 100 based on a certain condition. After that, I need to know the number of the bar where the order was placed (i.e., 100) at every subsequent bar.
    Right now, I'm using a for loop to check this condition at all previous bars and find the bar where the condition was met. However, I'm wondering if there's a smarter way to do this. Is it possible to move the information about the order's bar to the next bars so that I can easily retrieve it without having to search through all previous bars?
    Thanks for your help!




    #2
    Hello, thanks for writing in.

    There could be a few ways of doing this. First, see BarsSinceEntryExecution:



    Alternatively, you can save bar data within your own class-level variables at the same time you submit the order, so save the bar data to variables right before or right after calling the EnterLong() method, for instance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    46 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    33 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X