Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Unable to enter position at same direction across different contract

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

    Unable to enter position at same direction across different contract

    Hi, I added a list of contracts in Initialize(), like this:

    Code:
    Add("CL 01-15", BarsPeriod.Id, BarsPeriod.Value);
    Add("CL 03-15", BarsPeriod.Id, BarsPeriod.Value);
    Add("CL 05-15", BarsPeriod.Id, BarsPeriod.Value);

    And in my OnBarUpdate():

    Code:
            protected override void OnBarUpdate()
            {
    			if (BarsInProgress == 0){
    				EnterLong(1, DefaultQuantity, "long1");
    				EnterLong(2, DefaultQuantity, "long2");
    				EnterLong(3, DefaultQuantity, "long3");
    			}
            }
    However, when I backtest it, only the first Bars will be entering Long, while 2nd & 3rd are ignored. Means, it will Long CL 01-15 only.

    Is this by design?

    #2
    Hello vhanded,

    Thank you for your post.

    On what dates is it taking the positions? Likely there is no data for the other contracts at these times.

    Comment


      #3
      Hi Patrick,

      I am backtesting it from 1/1/2013 till 15/3/2015. CL 01-15 taking Long position on 2/2/3013.

      If I remove
      Code:
      EnterLong(1, DefaultQuantity, "long1");
      , then it will enter Long position for CL 03-15.

      It seems like there is only 1 Long position across all instruments, and also 1 Short position across instruments. Means, I can't Long CL 01-15 and CL 03-15 at the same time, even they are different contract.

      However, there can be both Long and Short position for different instrument. Means, I can Long 01-15 and Short CL 03-15 at the same time.

      Comment


        #4
        Hi Patrick,

        I had found a solution. Changing Entry Handling to UniqueHandling solve the problem.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,605 views
        0 likes
        Last Post aligator  
        Started by jaybedreamin, Today, 05:56 PM
        0 responses
        8 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        4 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        13 views
        0 likes
        Last Post Javierw.ok  
        Working...
        X