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 Aviram Y, Today, 05:29 AM
        0 responses
        1 view
        0 likes
        Last Post Aviram Y  
        Started by quantismo, 04-17-2024, 05:13 PM
        3 responses
        25 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by ScottWalsh, 04-16-2024, 04:29 PM
        7 responses
        34 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cls71, Today, 04:45 AM
        0 responses
        5 views
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        216 views
        1 like
        Last Post PaulMohn  
        Working...
        X