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 timko, Today, 06:45 AM
    2 responses
    12 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by habeebft, Today, 07:27 AM
    0 responses
    4 views
    0 likes
    Last Post habeebft  
    Started by Tim-c, Today, 03:54 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by rocketman7, Today, 01:00 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by wzgy0920, 04-23-2024, 09:53 PM
    3 responses
    76 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X