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:	71
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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      474 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      315 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      253 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      340 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      305 views
      0 likes
      Last Post CarlTrading  
      Working...
      X