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:	66
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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X