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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    117 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    166 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    85 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    130 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    88 views
    0 likes
    Last Post PaulMohn  
    Working...
    X