Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A very weird situation with Median[2]

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

    A very weird situation with Median[2]

    Ninjas, this should be very easy to solve for you, this situation is this

    If I add this condition below, it works perfectly:

    if (Close[0]-Median[1]> 0)
    {
    EnterLong();
    }

    But if I add this one, I have non result, zero event, why?

    if (Close[0]-Median[2]> 0)
    {
    EnterLong();
    }

    #2
    pstrusi,

    Could you possible post your code here?

    It could be you are trying to access Median[2] when it doesn't exist yet.

    if ( CurrentBar < 2) return;

    added to the beginning of your OnBarUpdate() may help.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      I'ts no necessary, a very fool error from me...as you well said Median[2] didn't exist cause in Barsrequired I had set 1.

      Thanks my friend

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      152 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      87 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      131 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      127 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      106 views
      0 likes
      Last Post CarlTrading  
      Working...
      X