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 andrewtrades, Today, 04:57 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    5 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    7 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X