Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

No overlapping trades

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

  • NinjaTrader_PatrickH
    replied
    Hello Q,

    Thank you for your response.

    The Basket test will run the strategy on each instrument in the instrument list separately. There is no work around for this as it works as expected.

    What you wish to do can be done by adding the instruments into your strategy or just viewing the performance results in the Strategy Analyzer: http://www.ninjatrader.com/support/h...ce_results.htm

    If you need the performance of multiple strategies for your calculations, then that must be done within the code by adding the instruments into the code: http://www.ninjatrader.com/support/h...nstruments.htm

    Please let me know if I may be of further assistance.

    Leave a comment:


  • qoheleth
    replied
    Hi,

    I checked with debug prints.
    In "Performance.AllTrades" list there are finished trades only of current contract month beining backtested.
    Also another properties of Performance.AllTrades list (such as Performance.AllTrades.TradesPerformance.GrossProfi t/GrossLoss etc.) are present only for actually backtested contract month.
    So when backtesting whole instrument list, I cannot adjust the strategy behaviour (such as position sizing) based on all finished trades. I tried to keep those values in separate variables, but also those are re-initialized/reset with new contract month.
    Are there any other trade statistics which are not being reset every time NT start to backtest new contract month?
    Or will Performance objects include really all trades statistics when backtesting whole instrument list in next release?

    Thanks.
    BR.
    Q.

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello Rick,

    Thank you for your response.

    I recommend enabling TraceOrders and using Print statements to pepper your code with checks for when conditions return true.

    Both TraceOrders and Print output information to the Output window (Tools > Output window).

    For information on Debugging your NinjaScript code please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3418

    Please let me know if I may be of further assistance.

    Leave a comment:


  • qoheleth
    replied
    Hi Rick,

    I'm running backtest on whole instrument list
    I'm not running backtest on each month separately
    For better debugging, I reduced instrument list of ZS to only 2 contract months, but issue is the same for other instruments (ZW etc...)
    Please see printscreen attached.

    BR.
    Q.
    Attached Files

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello qoheleth,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    Are you backtesting the contracts from within your Default instrument list in a basket test?
    Information on a basket test can be found at the following link: http://www.ninjatrader.com/support/h...asket_test.htm

    Or are you running the backtest on one contract for the ZS such as the 01-12?

    I look forward to your response.

    Leave a comment:


  • qoheleth
    started a topic No overlapping trades

    No overlapping trades

    Hi Ninjas,

    I have question regarding backtesting:
    My strategy generates entry/exit signals for the same trading day for more contract months. However, I'de like to avoid to trade the same time range in different contract months.
    Example:
    - let's say strategy generates entry on 20/7/2011 and exit on 12/8/2011 for ZS 01-12 and also for ZS 11-11
    - in ZS 11-11 there are also another trades (entry 24/1/2011 exit 1/2/2011)
    - NT backtests ZS 01-12 first, then backtests ZS 11-11

    I tried to check, if time of next trade (ZS 11-11 20/7/2011...12/8/2011) is not overlapping with trades already finished in another contract months (ZS 01-12 20/7/2011...12/8/2011).
    Code created based on NT 7 manual:

    private void CheckPrevTrades() // entry signal generated, check overlapping with trades already finished
    {

    if ( Performance.AllTrades.Count > 0 && Position.MarketPosition == MarketPosition.Flat ) // at least one trade finished, no position currently opened
    {
    foreach (Trade trade in Performance.AllTrades) // go through all finished trades
    {
    int checkFlatEntryDate = DateTime.Compare(Time[0].Date.Date, trade.Entry.Time.Date); // compare current trading day with previous trade entry date
    int checkFlatExitDate = DateTime.Compare(Time[0].Date, trade.Exit.Time.Date); // compare current trading day with previous trade exit date
    if (checkFlatEntryDate >= 0 && checkFlatExitDate <= 0) // check overlapping, if current date is bigger/equal to entry date and smaller/equal to exit date, we cannot continue to open the trade
    {
    // logic for overlapping here
    }
    .
    .
    }
    }
    }


    The problem: when NT backtests ZS 11-11 after ZS 01-12, in the list of finished trades (i.e. Performance.AllTrades), there is only contr. month ZS 11-11 with entry 24/1/2011 and exit 1/2/2011.
    In the list, there's no trade ZS 01-12 entry 20/7/2011 exit12/8/2011. So, the trade for ZS 11-11, entry 20/7/2011 exit12/8/2011 is opened despite I don't want the trade to open.
    Can you hint me, how to resolve it?
    Thanks in advance.
    BR.
    Q.

Latest Posts

Collapse

Topics Statistics Last Post
Started by crystalet, Yesterday, 12:19 PM
3 responses
34 views
0 likes
Last Post crystalet  
Started by Orogpd, Today, 03:26 AM
0 responses
1 view
0 likes
Last Post Orogpd
by Orogpd
 
Started by cbdgrenhouseusa, Today, 03:17 AM
0 responses
1 view
0 likes
Last Post cbdgrenhouseusa  
Started by cbdgrenhouseusa, Today, 03:16 AM
0 responses
1 view
0 likes
Last Post cbdgrenhouseusa  
Started by ラリー, 09-05-2022, 02:02 PM
62 responses
513 views
0 likes
Last Post ラリー  
Working...
X