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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    72 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    63 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X