Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 instruments in one script

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

    2 instruments in one script

    This is for backtesting purposes. I made an attempt at having 2 instruments in one script below but when I compare it to running a single script against the same 2 instruments seperately I get different net profit results. I tried using "else if" as well. Is there anything else I'm doing incorrectly or is it not even possible to do what I'm attempting here?


    Code:
    protected override void Initialize()
    {
    
    //SPY is Primary series 0
    Add("DIA", PeriodType.Minute, 5);  //series 1 primary for DIA
    Add(PeriodType.Minute, 1); //series 2 secondary for SPY
    Add("DIA", PeriodType.Minute, 1);  //series 3 secondary for DIA
    
    }
    
    protected override void OnBarUpdate()
    {
       if ((BarsInProgress == 2) && //sma cross conditions here//)
            {
              EnterLong(200, "SPY");
            }
       if ((BarsInProgress == 3) && //sma cross conditions here//)
            {
              EnterLong(200, "DIA");
            }
    
    
       if ((BarsInProgress == 0) && (Position.MarketPosition == MarketPosition.Flat))
                {
    		SetStopLoss("SPY", CalculationMode.Percent, stoppercent, true);
    	     }
       if ((BarsInProgress == 1) && (Position.MarketPosition == MarketPosition.Flat))
                {
    	         SetStopLoss("DIA", CalculationMode.Percent, stoppercent, true);
    	     }
    }

    #2
    zachj, if I'm not mistaken you already have a thread opened on the same topic - we would appreciate if you can continue working with this thread. Thanks.

    Comment


      #3
      Alright, ill put it max down day post even though I feel it's a different method.
      Last edited by zachj; 07-25-2013, 07:09 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      574 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X