Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Entering Trades on MultiDataSeries

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

    Help with Entering Trades on MultiDataSeries

    Hello,

    I hope my message finds you well. I am currently trying to test an execution method where if the close of the 1 Minute Candle is below the Low of the 5 Minute Candle the strategy enters short.
    I have not quite understood how to accomplish this.

    This is the code I wrote, and it does not execute anything:

    Code:
    else if (State == State.Configure)
    {
    // Additional Data Series
    AddDataSeries(Data.BarsPeriodType.Minute, 1);
    }​
    
    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;
    
    if (CurrentBars[0] < 50)
    return;
    
    SimpleEntryLogic();
    
    }
    
    private bool _BreakofLow;
    private void SimpleEntryLogic()
    {
    
    _BreakofLow = Closes[0][0] < Opens[0][0]; // 5 Minute Bar is Red
    _BreakofLow &= Closes[1][0] < Closes[0][0]; // Close of 1 Minute Bar is Below 5 Minute Bar Low
    _BreakofLow &= Closes[1][0] < Opens[1][0]; // 1 Minute Bar is Red
    
    if(_BreakofLow)
    {
    Draw.ArrowDown(this, @"Entry Dot_1 " + Convert.ToString(CurrentBars[0]), true, 0, (High[0] + (5 * TickSize)), Brushes.Red);
    }
    
    }
    ​Thank you very much, I just need to understand how to structure it properly.

    #2
    Hello NorwegianCat92

    I would suggest making a standard if condition rather than using the &= operator, your code would look like this:

    if(Closes[0][0] < Opens[0][0] && Closes[1][0] < Closes[0][0] && Closes[1][0] < Opens[1][0])
    {

    }

    If you still do not see any trades I would suggest using a Print to see what the values are for each of these series to get a better idea of why its false. ​

    Comment


      #3
      Hello Jesse,

      Thank you for your reply.
      I tried to print the bar values, but it does not print the data for the 1 Minute Data series, it only prints the 5 Minute. Can you pinpoint what is wrong?

      Thank you Jesse

      Code:
      protected override void OnBarUpdate()
      {
      if (BarsInProgress != 0)
      return;
      
      if (CurrentBars[0] < 50)
      return;
      
      SimpleEntryLogic();
      
      }
      
      private void SimpleEntryLogic()
      {
      
      Print(Times[0][0] + "PrimaryDataSeries 5M: " + Closes[0][0]);
      Print(Times[0][1] + "SecondaryDataSeries 1M: " + Closes[1][0]);
      
      
      }
      Click image for larger version

Name:	Forum.png
Views:	60
Size:	43.5 KB
ID:	1325892

      Comment


        #4
        Hello NorwegianCat92,

        Your Print is using the 1 bars ago time and not the secondary series, you need to use Times[0][0] and Times[1][0] to access the times for both series.

        Comment


          #5
          Hello Jesse,

          I changed it, but still the Print shows only 5M Bars like before....

          protected override void OnBarUpdate()
          {
          if (BarsInProgress != 0)
          return;

          if (CurrentBars[0] < 50)
          return;

          SimpleEntryLogic();

          }

          private void SimpleEntryLogic()
          {

          Print(Times[0][0] + "PrimaryDataSeries 5M: " + Closes[0][0]);
          Print(Times[1][0] + "SecondaryDataSeries 1M: " + Closes[1][0]);


          }​

          Comment


            #6
            Hello NorwegianCat92,

            In the image you previously provided I see prints for both series, you only had the incorrect time so you would only see the 5 minute timestamps. You have 2 prints happening for each bar which show the 1 and 5 minute prices.

            Comment


              #7
              No I think it does not work... It only shows the print every 5 minutes in conjuction only with the primary data series which is the 5 minute chart.
              What I want is also the print of the closes for each individual 1 Minute chart, otherwise it is like having only one data series.

              It would need to show:
              7:30 PM PrimaryDataSeries 5M
              7:30 PM PrimaryDataSeries 1M
              7:31 PM PrimaryDataSeries 1M
              7:32 PM PrimaryDataSeries 1M and so on..

              my objective is to take trade decisions on the 5 minute chart and execute on the 1 minute chart, but here it seems it does not read the 1 minute chart.
              Click image for larger version  Name:	Forum 2.png Views:	0 Size:	12.0 KB ID:	1325917

              Comment


                #8
                Hello NorwegianCat92,

                That is because you are executing the code only for the primary series so that would be expected based on what you coded. You have the following line which means only execute code past that point for the primary series.

                if (BarsInProgress != 0)
                return;​

                Comment


                  #9
                  Ah I see, Thank you Jesse.
                  What should I put so that it executes the code also for the secondary data series?

                  Thanks Jesse

                  Comment


                    #10
                    Hello NorwegianCat92,

                    You would need to remove that condition and the return statement if you want it to execute for both series.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Yesterday, 05:17 AM
                    0 responses
                    54 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    130 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    72 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    44 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    49 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X