Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding values to a move(leg)

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

    Adding values to a move(leg)

    Hi I am trying to show volume above the bars in a move. what is the recomended way to single out move that is between the reversal bars?
    would it be using loop?
    MOve is series of same bars, long bars or short bars.

    string volumeDisplay = (VOL()[1]).ToString();
    if(Close[1] < Open[1] && Close[2] > Open[2] ){
    Draw.Text(this, "Tag33" + CurrentBar, true, volumeDisplay, 0, High[0] + (5 * TickSize), 0, Brushes.White, theFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
    }​

    Click image for larger version

Name:	image.png
Views:	118
Size:	43.7 KB
ID:	1264995

    #2
    Hello tkaboris,

    If I'm understanding correctly, if the current bar is down (close less than open) and the previous bar is up (close was greater than open), then this is reversing.
    if the current bar is up (close greater than open) and the previous bar is down (close was less than open), then this is reversing.

    After a 'reversal' you want each new bar where the close is less than the open to have the volume of that bar printed above the bar.

    Is this correct?

    Use a bool to know the trending direction.
    (Adjust barsAgo by 1 if you are using Calculate.OnEachTick/IsFirstTickOfBar)

    Code:
    private bool trendingUp;
    
    if (Close[0] > Open[0] && Close[1] < Open[1])
    trendingUp = true;
    
    if (Close[0] < Open[0] && Close[1] > Open[1])
    trendingUp = false;
    
    if (trendingUp == false && Close[0] < Open[0])
    Draw.Text(this, "Tag33" + CurrentBar, true, volumeDisplay, 0, High[0] + (5 * TickSize), 0, Brushes.White, theFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi, I would like to record volume in each leg, Leg can have 1 or 10 bars in it. I am stuck with these for loops. I was going to use for loops to keep consecutive bars together in a leg and then print total volume at the end of each leg
      I attached a sample code too.

      Code:
      string volumeDisplay = (VOL()[1]).ToString();
                  if(Close[1] < Open[1] && Close[2] > Open[2] ){
                  Draw.Text(this, "Tag33" + CurrentBar, true, volumeDisplay, 0, High[0] + (5 * TickSize), 0, Brushes.White, theFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                  }
                  consecutiveBullBars = 0;
                  consecutiveBearBars = 0;
      
      
                  for (int i = 1; i < CurrentBar; i++)
                  {
                      if (Close[i] > Open[i])
                      {
                          consecutiveBullBars++;
      
                          consecutiveBearBars = 0;
                      }
                      else if (Close[i] < Open[i])
                      {
                          consecutiveBearBars++;
                          trendingDown = true;
                          consecutiveBullBars = 0;
                      }
                      else
                      {
                          consecutiveBullBars = 0;
                          consecutiveBearBars = 0;
                          trendingDown = false;
                          trendingUp = false;;
                      }
                      Print("consecutiveBullBars"+consecutiveBullBars);
                  }​
      Attached Files
      Last edited by tkaboris; 08-18-2023, 02:09 PM.

      Comment


        #4
        Hello tkaboris,

        private int legVolume;

        if (Close[0] > Open[0] && Close[1] < Open[1])
        {
        trendingUp = true;​
        legVolume = 0;
        }

        if (trendingUp)
        legVolume += Volume[0];

        Print(legVolume);
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        53 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
        70 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