Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Open Positions in Backtest

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

    Open Positions in Backtest

    Hello,

    I would like to place a market order with a SL and a TP. If my understanding is right, it must be split into an EnterLong() and an ExitLongStopLimit() order. How can I make sure, that the ExitLongStopLimit() is only executet once for every order.

    Eg.
    if ( ..)
    {

    EnterLong();

    ExitLongStopLimit(tp, sl);
    }

    will cause an execution of the ExitLongStopLimit() even if the EnterLong is not executed due to the "Entries per direction" limit.

    It is possible to get the number of positions during backtests?

    if (Performance.LongTrades.Count == 0)
    {

    EnterLong();

    ExitLongStopLimit(tp, sl);
    }

    seems not to work during backtests.

    Best Regards

    Thomas

    #2
    Hi Thomas,

    Exit methods will not submit orders if there is not a position. Turn TraceOrders on and then could see messages to the effect An exit order was submitted but no position exists to exit.

    If you wanted to verify you are in a position before submitting, could use

    if (Position.MarketPosition == MarketPosition.Long) { }

    ExitLongStopLimit() will submit only one order and not both profit target and stop loss. It would be the stop loss portion, so if you wanted a profit target would need to be a separate
    ExitLongLimit()
    Last edited by NinjaTrader_RyanM1; 12-13-2011, 11:09 AM.
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    77 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    45 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    27 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    63 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X