Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        601 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        347 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        559 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        558 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X