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

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 ageeholdings, 05-01-2024, 05:22 AM
    6 responses
    42 views
    0 likes
    Last Post ageeholdings  
    Started by tony_28217, Today, 07:04 PM
    0 responses
    11 views
    0 likes
    Last Post tony_28217  
    Started by flybuzz, Today, 10:33 AM
    1 response
    9 views
    0 likes
    Last Post flybuzz
    by flybuzz
     
    Started by spencerp92, 10-10-2023, 09:56 AM
    4 responses
    308 views
    0 likes
    Last Post flybuzz
    by flybuzz
     
    Started by samish18, Yesterday, 10:13 AM
    1 response
    26 views
    0 likes
    Last Post NinjaTrader_Eduardo  
    Working...
    X