Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry Bar return

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

    Entry Bar return

    Hello!

    How can I get Enter Position Bar in my strategy?
    Want to create next thing:
    When position is going +10 ticks in my side -> set stop loss on the high/low of the bar, where was an entry in position.

    Thanks!

    #2
    Hello YevhenShynkarenko,

    To find when the price has increased, save the trigger price to a variable. Then compare the current price to that variable.

    For example:
    private double triggerPrice = 0;
    if (/* conditions to enter trade */)
    {
    SetStopLoss( "entryOrder", CalculationMode.Ticks, 10, false );
    EnterLong( "entryOrder" );
    triggerPrice = Close[0] + 10 * TickSize;
    }

    if (Position.MarketPosition == MarketPosition.Long && Close[0] >= triggerPrice)
    {
    SetStopLoss( "entryOrder", CalculationMode.Price, Position.AvgPrice, false );
    }

    This code sets the triggerPrice variable to the current price plus 10 ticks (Close[0] + 10 * TickSize). Once the current price is equal or greater than the saved price the stop loss is set to the position entry price.

    I am also attaching a more complicated example script that demonstrates movements in OnBarUpdate and movements in OnMarketData() with a slightly different approach.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    47 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    15 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    21 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    23 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X