Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

using multiple entry and exits

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

    using multiple entry and exits

    Hi,

    NT has a reference example here (http://ninjatrader.com/support/forum...ead.php?t=3225) about a strategy that uses multiple entry and exits. I am coding a strategy that also has multiple entry and exits and I am using

    EntryHandling = EntryHandling.UniqueEntries;

    as I want each entry/exit to generate its own orders.

    I have a question for which I will use the example that NT gave (in that link above) :

    This is a part of the NT reference code:

    protected override void OnBarUpdate()
    {
    // Entry Signal 1: If RSI value crosses above 20
    if (CrossAbove(RSI(RSI_Period, RSI_Smooth), 20, 1))
    {
    // Placing a string between the parenthesis allows you to give unique identifiers to your entries.
    EnterLong("RSI Entry");
    }
    // Exit Signal 1: If RSI value crosses below 80
    if (CrossBelow(RSI(RSI_Period, RSI_Smooth), 80, 1))
    ExitLong("RSI Entry");
    // Entry Signal 2: If SMA crosses above the current close
    if (CrossAbove(SMA(SMA_Period), Close, 1))
    EnterLong("SMA Entry");
    // Exit Signal 2: If SMA crosses below the current close
    if (CrossBelow(SMA(SMA_Period), Close, 1))
    ExitLong("SMA Entry");
    }
    Now in my own indicator, the EnterLong() / ExitLong() and EnterShort() / ExitShort() signals can take a while to occur initially when the strategy starts from CurrentBar = 0. So, instead of using CrossAbove() / CrossBelow() in my signals, I want to use a ">" or "<" operator, i.e.

    I want to use something along the lines of this (using NT's code as an example):

    if (Position.MarketPosition != MarketPosition.Long && RSI(RSI_Period, RSI_Smooth)[0] > 20)
    EnterLong("RSI Entry");
    if (Position.MarketPosition != MarketPosition.Long && SMA(SMA_Period)[0] > Close[0])
    EnterLong("SMA Entry");
    ....
    My question is:

    Since I am using multiple entry / exit signals (along with EntryHandling = EntryHandling.UniqueEntries;), it is not clear if Position.MarketPosition refers to the the RSI Entry or the SMA Entry .

    Would the correct approach be Positions[0] and Positions[1] like this?

    if (Positions[0].MarketPosition != MarketPosition.Long && RSI(RSI_Period, RSI_Smooth)[0] > 20)
    EnterLong("RSI Entry");
    if (Positions[1].MarketPosition != MarketPosition.Long && SMA(SMA_Period)[0] > Close[0])
    EnterLong("SMA Entry");
    ....
    But, the NT7 documentation https://ninjatrader.com/support/help...?positions.htm mentions that Positions should ONLY be used for executing orders against multiple instruments.

    How can I implement multiple entry/exit signals where each entry/exit need to check whether its Position is long / short / flat?
    Last edited by uday12; 02-18-2016, 03:16 PM.

    #2
    Hello uday12,

    Thank you for writing in.

    Position.MarketPosition would refer to the entire strategy position.

    If you wish to track multiple positions, you would need to add an additional data series and submit your other orders to that data series.

    You would then be able to utilize the Positions collection to keep track of each position.

    For more information about working with multiple timeframes or instruments, please take a look at this help guide link: https://ninjatrader.com/support/help...nstruments.htm
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X