Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Summation

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

    Summation

    Hi,

    please, I need to a sum of values only if they are positive.
    For example : X = a+b+c were a, b,c are positive. If negaive no.

    Have someone idea about formula in NT7,

    Thanks in advance.
    Last edited by sniper; 10-24-2016, 11:16 AM.

    #2
    Hello Sniper,

    Thank you for your note.

    What you could do is add an if statement which checks to see if a, b, and c are positive and if so, set the value of x equal to a+b+c.

    Under initialize(),

    X = 0;

    Under OnBarUpdate you would add,

    if (CurrentBar < 1) return;

    if(a>0 && b>0 && c>0)
    {
    X = a+b+c;
    }

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      I badly explained myself... in market action a, b and c can be +1 or -1 , i don't know which one is posive or negative.
      I can compile a little script like this :
      x=0
      if a>0
      then x=x+1
      if b>0
      then x=x+1
      etc.. etc...
      but it looks a dirty code. Is there a single command to do this ?
      Best regard .

      Comment


        #4
        Hello Sniper,

        If you only want to have 1 added to x if either a, b, or c had a positive value you could do,

        If(a>0 || b>0 || c>0)
        {
        X+=1;
        }

        However if you wanted to add 1 to x each time either a, b or c was positive than you would want to keep them as independent if statements as in your previous message.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          The second one.
          Ok thanks a lot.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sjsj2732, 03-23-2026, 04:31 AM
          0 responses
          77 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          313 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          314 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          149 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          114 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X