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:	61
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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      41 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X