Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Syntax to reference entry order

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

    Syntax to reference entry order

    Hi there,

    I have an if statement that enters a long position when a Condition1 is met. How do I store the entry price of that long position in a variable?

    Here is my current code

    Code:
    if(Condition1){
    EnterLong(1, "Buy to open");
    var entryPrice = Execution.Price;
    I want to store the entry price of the position in the variable entryPrice. What is the correct syntax to do this?

    R/

    XYZ

    #2
    Hello AAAlmonte,

    Thanks for your post and welcome to the NinjaTrader forums!

    NinjaTrader uses event-driven processes so in your example the order would likely have not even left the platform by the time the next code line is executed where you are wanting to get the price.

    What you can do is check to see that you are in a long market position and then pull the entry price from Position.AveragePrice.
    References;



    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    79 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X