Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with strategy and two instruments

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

    Problem with strategy and two instruments

    Hi

    I am having trouble with referring to two instruments in a strategy. Using a single instrument YM chart I have added a custom strategy. I have added a second data series using

    protectedoverridevoid Initialize()
    {
    CalculateOnBarClose =
    true;

    Add(
    "ES 12-09", PeriodType.Minute, 5);
    }

    In On bar update I have the following lines:

    string1 etc = CurrentDayOHL().CurrentLow[0].ToString();
    This is returning the value of the second data series not the first ie YM

    string2 etc = Closes[
    1][0].ToString();

    This line is working correctly

    The question is how do I get string1 to equal the value relating to the first data series ie YM in this case?




    #2
    MicroAl,

    Please be sure you are working within the correct BarsInProgress context.

    if (BarsInProgress == 0) <-- you are in YM
    if (BarsInProgress == 1) <-- you are in ES
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Problem with strategy

      Josh

      Thanks. Used a check as suggested - solved problem

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      605 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      351 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      560 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      561 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X