Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-Serie strategy

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

    Multi-Serie strategy

    Hi folks,

    I am currently struggling with strategy with two data series. I am sure that it must be an easy thing but I am not a programming expert.

    I have a simple strategy which enters long or short when the prise crosses above or below the 30minute opening range. This strategy works fine:

    Code:
     
    protectedoverridevoid Initialize()
    {
    Add(HiLoOfTimeRange(15, 30, 16, 0));
    Add(HiLoOfTimeRange(15, 30, 16, 0));
     
    SetTrailStop("", CalculationMode.Ticks, 6, false);
     
    CalculateOnBarClose = false;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    if (CrossAbove(Close, HiLoOfTimeRange(15, 30, 16, 0).TheHigh, 1) && Bars.BarsSinceSession > 30)
    {
    EnterLong();
    }
     
    if (CrossBelow(Close, HiLoOfTimeRange(15, 30, 16, 0).TheLow, 1) && Bars.BarsSinceSession > 30)
    {
    EnterShort();
    }
    }


    But if I want to extend the entering condition to depend on other data serie (e.g. ^TICK) the strategy does not work:

    Code:
     
    protectedoverridevoid Initialize()
    {
    Add("^TICK",PeriodType.Minute,1);
    Add(HiLoOfTimeRange(15, 30, 16, 0));
    Add(HiLoOfTimeRange(15, 30, 16, 0));
     
    SetTrailStop("", CalculationMode.Ticks, 6, false);
     
    CalculateOnBarClose = false;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    if (CrossAbove(Closes[0][0], HiLoOfTimeRange(15, 30, 16, 0).TheHigh, 1) && Closes[1][0]> 800 && Bars.BarsSinceSession > 30)
    {
    EnterLong();
    }
     
    if (CrossBelow(Closes[0][0], HiLoOfTimeRange(15, 30, 16, 0).TheLow, 1) && Closes[1][0]> 800 && Bars.BarsSinceSession > 30)
    {
    EnterShort();
    }
    }

    Could you please me help me to make it work?
    Thanks a lot!
    Stepan

    #2
    I found the answer already. No need to answer

    Comment


      #3
      Hello,

      Glad to hear you found the answer!

      Let me know if I can be of further assistance.
      BrettNinjaTrader Product Management

      Comment


        #4
        Multi-Series

        Stepan,

        Not sure why you have added a duplicate series? But with multi-series, you might consider using the BarsArray[] function in your Boolean logic to identify different time series.

        Comment


          #5
          Originally posted by borland View Post
          Stepan,

          Not sure why you have added a duplicate series? But with multi-series, you might consider using the BarsArray[] function in your Boolean logic to identify different time series.
          Actually the problem was that I forgot that the first serie should be refferenced with regular CLOSE command and the second one with Closes[1][0]

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          672 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          577 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X