Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Displaying on NinjaTrader Output the Count of a Condition

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

    Displaying on NinjaTrader Output the Count of a Condition

    Hello,

    I hope my message find you well.
    I am trying to have displayed on the NinjaTrader Output window how many times a condition occurs, but the result is always 0, which cannot be true.
    Would you be able to help?
    Thank you

    Code:
    private void PriceGoingImbalance()
    {
    
    // Condition for Price Crossing 1STD.
    _CrossUp1STD = Close[0] > amaCurrentWeekVWAP1.UpperBand1[0];
    _CrossUp1STD &= Low[0] < amaCurrentWeekVWAP1.UpperBand1[0];
    
    
    CountIf(() => _CrossUp1STD, CurrentBar);
    Print("-------------------------------------");
    Print(Time[0]);
    Print("Number of Signals Imbalance Up : " + CountIf(() => _CrossUp1STD, CurrentBar));
    Print("Total Number of Bars: " + CurrentBar);
    Print("-----------------------------------");
    
    
    }
    Click image for larger version

Name:	NinJA2.png
Views:	55
Size:	12.7 KB
ID:	1323440​​

    #2
    Hello NorwegianCat92

    Please try the following format instead:

    int count = CountIf(() => Close[0] > amaCurrentWeekVWAP1.UpperBand1[0] && Low[0] < amaCurrentWeekVWAP1.UpperBand1[0] , CurrentBar);

    Print(count);

    You may also want to print the prices you are using to see if that every is true with both prices being greater/lesser than the indicator.

    Comment


      #3
      Hello Jesse,

      Ah I see, I had to use an Int variable. It works now.
      Thank you very much as always for your help.

      Best Regards

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      50 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      126 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      69 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      42 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X