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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      82 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      43 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      68 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      56 views
      0 likes
      Last Post CarlTrading  
      Working...
      X