Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with a simple code

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

    Need help with a simple code

    Hi!

    Need some help. The indicator plots nothing and I don't know why. This is the core code. Am I missing something?

    It only calculates a swing in ADX below certain level (bandadx), checking that another ADX is below bandadx1 and finally seeing that +DI and -DI go in different directions.

    Thanks in advance,

    Sergio

    Code:
    protected override void OnBarUpdate()
            {
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
                if (ADX(14)[2] > ADX(14)[1]
                    && ADX(14)[0] > ADX(14)[1]
                    && ADX(14)[1] < bandadx
                    && ADX(35)[1] < bandadx1
                    && ((DM(14).DiPlus[0] - DM(14).DiPlus[1])* (DM(14).DiMinus[0] - DM(14).DiMinus[1]) < 0.000)
                    )
                {barracuda = 1;}
                else
                {barracuda = 0;}
                Plot0.Set(barracuda);
            }
    Last edited by sercava; 12-05-2011, 08:49 AM.

    #2
    Hello

    Are you receiving any errors on the log tab of the control center?

    You're likely running into an issue explained in the following forum post from our Tips section:



    Please try adding the following snippet to the beginning of your code in OnBarUpdate()

    Code:
    if (CurrentBar < 2)
    return;
    Last edited by NinjaTrader_Matthew; 12-05-2011, 09:07 AM.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Works like a charm now, thanks. Need to put 'CurrentBar' and not 'Current Bar'

      Just beginning with programming with NT and need to make this mistakes. Seems I 'm not the only one. :-)

      Sergio

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by sjsj2732, 03-23-2026, 04:31 AM
      0 responses
      69 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      312 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      305 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      146 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      105 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X