Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Put a value into a dataserie

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

    Put a value into a dataserie

    I'm not sure if I'm doing this the right way.
    My goal is create a simple swing indicator, ATR based.
    It works fine with colored bars. But now I want to put dots below the swingpoints and that doesn't work because sometimes a trend is so strong that it will multiple times cross above 'upwave'. So you get dots but it isn't actually a cross from down to up trend.

    Does anyone know a solution for this? I started playing with dataseries but I don't get the job done. (background yellow was for testing (=dots).

    PHP Code:
    
        if ( myDataSeries[1] == 0 && myDataSeries[0] == 1 
                    )
                    {BackColor = Color.Yellow; 
                    } 
                    
                    
                    double upwave = ATR(15)[0]*2.5 + MIN(Low, 14)[0] ;
                    double downwave = MAX(High, 14)[0] - ATR(15)[0]*2.5;
                 if ( CrossAbove(Close, upwave, 1)
                
                    )
                {  trend = 1;
                        myDataSeries.Set(1);
                }
                else if ( CrossBelow(Close, downwave, 1)
                    )
                {  trend = 0;
                     myDataSeries.Set(0);
                                  }
                if ( trend ==1)
                {BarColor = Color.Green;}
                 if (trend ==0)
                 {BarColor = Color.Red;} 
    

    #2
    no111, can you please clarify what you're trying to do here? Perhaps a picture would help. It sounds like you'll need to come up with a different set of conditions for drawing the dots; it seems like the ones you have now draw too many dots?
    AustinNinjaTrader Customer Service

    Comment


      #3
      Ok. I attached a screenshot.
      You see that if trend = 1 there are nice green bars (=upswing) and if trend = 0 there are nice red bars.

      But since trend is a double I can't do this:
      trend[1] == 0 && trend[0] ==1.
      That would be the switch from a downswing to a upswing. And I want to mark that points with arrows or give these points an id.
      Attached Files

      Comment


        #4
        Thanks for the clarification. Please take a look at this sample that shows how to use DataSeries to store calculations - http://www.ninjatrader.com/support/f...ead.php?t=7299. You can store your trend values in the data series and then you can do trend[1] and trend[0] and such. Let me know if you have any questions.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Great! I have it working now

          Comment


            #6
            I have another question , I want to add another dataserie. If there is a cross to an upswing I want to know the low of the last 5 bars. But this doesn't work because everytime onbarupdate it will save to dataserie: datalows.
            How can I code it that it only stores to datalows when there is a crossover?


            PHP Code:
                if ( trend ==1)
                        {BarColor = Color.Green;
                         }
                         if (trend ==0)
                         {BarColor = Color.Red;
                         }
            myDataSeries.Set(trend);
                        
                        if ( myDataSeries[1] == 0 && myDataSeries[0] == 1 
                            )
                            {//BackColor = Color.Yellow; 
                             DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Blue);
                            lastlow =     MIN(Low, 5)[0];
                            
                            }
                datalows.Set(lastlow);                    
                            
                            if ( datalows[0] < datalows[1] 
                            
                            ){
                                
                            BackColor = Color.Yellow; 
                            } 
            

            Comment


              #7
              So the lows in these attachment.
              Attached Files

              Comment


                #8
                Hi again, you just have to move the datalows.Set() statement into the trend check block of code so it only sets when there is a cross:
                Code:
                if (myDataSeries[1] == 0 && myDataSeries[0] == 1)
                {
                    //BackColor = Color.Yellow; 
                    DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Blue);
                    lastlow = IN(Low, 5)[0];
                    datalows.Set(lastlow);
                }
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Ok thanks, I have it now done this way:

                  PHP Code:
                      if ( myDataSeries[1] == 0 && myDataSeries[0] == 1 
                                  )
                                  {
                                   DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Blue);
                                  lastlow =     MIN(Low, 5)[0];
                                  datalows.Set(lastlow);        
                      
                                  } 
                                  
                                              
                                  if ( datalows[0] > datalows[1] 
                                  
                                  ){
                                      
                                  BackColor = Color.Yellow; 
                                  } 
                  
                  But doesn't work out, my goal is to compare the lows I stored into datalows[], so I can see if there is an lower or higher low.
                  Attached Files

                  Comment


                    #10
                    no111, we aren't able to provide debugging services. Have you seen the debugging tip page - http://www.ninjatrader.com/support/f...ad.php?t=3418? Please Print() out your values to ensure everything is triggering as expected.
                    AustinNinjaTrader Customer Service

                    Comment


                      #11
                      Ok thanks, The dataseries is printing every bar, so need to change that.

                      Comment


                        #12
                        That print function gave me new insight, thanks .

                        Comment

                        Latest Posts

                        Collapse

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