Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi time series

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

    Multi time series

    Hi there,
    I have following problem. This is my code(edited part):


    protected override void Initialize()
    {
    Add(PeriodType.Minute, 1); // Adds another TimeSeries 1min Array[1]
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.

    // Posouzeni Stoch 2min


    if (CCI(14)[0] <= 20
    && Rising(CCI(BarsArray[1],14)) == true)
    {
    DrawTextFixed("CCI status","CCI OK ", TextPosition.BottomLeft, Color.Black, new Font("Arial", 10), Color.Black, Color.Lime, 10);
    }
    else
    if (CCI(14)[0] >= 80
    && Falling(CCI(BarsArray[1],14)) == true)
    {
    DrawTextFixed("CCI status","CCI OK ", TextPosition.BottomLeft, Color.Black, new Font("Arial", 10), Color.Black, Color.Lime, 10);
    }
    else
    {
    DrawTextFixed("CCI status","CCI NOK ", TextPosition.BottomLeft, Color.Black, new Font("Arial", 10), Color.Black, Color.Red, 10);
    }

    }



    What I want it to do is:
    I have the primary Time series 2min.
    I want to build an indicator based on CCI.
    If CCI on 2min is below 20 and CCI on 1min is rising, print green box saying "CCI OK" . If CCI on 2min is above 80 and CCI on 1min is falling, print green box saying "CCI OK". If anything else print red box saying "CCI NOK"

    I used Add(PeriodType.Minute, 1) to add 1min time series and BarsArray[1] to execute it in a code
    But I cannot get it working

    Can you help please?
    Radek

    #2
    Radek, you want to include a check to BarsInProgress for your conditions / OnBarUpdate code as well - http://www.ninjatrader.com/support/h...BarsInProgress

    Right now both bars objects updates would be used, while you want to work off the primary (BarsInProgress 0 only, as this is your 2 min),

    Comment


      #3
      I changed the script like this, but still not working. When I activate the indicator on the chart, the bars stop moving, BarTimer stops working(like if I was not connected)


      {

      if (BarsInProgress == 0)
      {

      if (CCI(14)[0] < 80 && CCI(14)[0] > 20)
      {
      DrawTextFixed("status","CCI NOK ", TextPosition.BottomLeft, Color.Black, new Font("Arial", 10), Color.Black, Color.Red, 10);
      }


      else if (CCI(14)[0] <= 20)
      {
      if (BarsInProgress == 1)

      {
      if (Rising(CCI(14)[0] == true)
      {
      DrawTextFixed("status","CCI OK ", TextPosition.BottomLeft, Color.Black, new Font("Arial", 10), Color.Black, Color.Lime, 10);
      }
      else
      {
      DrawTextFixed("status","CCI NOK ", TextPosition.BottomLeft, Color.Black, new Font("Arial", 10), Color.Black, Color.Red, 10);
      }

      }
      }
      else if (BarsInProgress == 1)
      {
      if (Falling(CCI(14)[0] == true)
      {
      DrawTextFixed("status","CCI OK ", TextPosition.BottomLeft, Color.Black, new Font("Arial", 10), Color.Black, Color.Lime, 10);
      }
      else
      {
      DrawTextFixed("status","CCI NOK ", TextPosition.BottomLeft, Color.Black, new Font("Arial", 10), Color.Black, Color.Red, 10);
      }
      }

      }
      }

      Comment


        #4
        Now, chart data is updating, but indicator is not working
        if I use BarsInProgress do I have to use BarsArray[1] too?
        the problem is that I need to compare CCI on both time periods in one time and then do something
        Last edited by godiamond; 03-20-2014, 11:41 AM.

        Comment


          #5
          Radek, what do you mean exactly by the script is not working? It's not showing any return or not the one you would expect from your conditions?

          Here's a simple test you could run for example for the long side of your condition from a 2 min primary chart - that would identify bars where the 2 min CCI is <= 20 and the 1 min one rising at the same time (primary bar update / timestamp) :

          if (BarsInProgress != 0) return;

          if (CCI(14)[0] <= 20 && Rising(CCI(BarsArray[1],14)) == true)
          {
          BarColor = Color.Blue;
          DrawArrowUp(CurrentBar.ToString(), 0, Low[0] - TickSize, Color.DarkBlue);
          }

          Comment


            #6
            To NinjaTrader_Bertrand , your sample script works, but I want the action(That box saying OK or NOK) just for the actual tick, every new tick to be recalculated. I do not want it from the past

            Comment


              #7
              I did some changes and it seems to be working. But without your help I would not make it, thanks a lot

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              576 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              334 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X