Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Signing a value "-" before converting

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

    Signing a value "-" before converting

    Hello all,

    how do I compute...
    (double)alSells[CurrentBar]
    ...with the negative of the actual value of alSells[CurrentBar]?

    I tried...
    (double)(- alSells[CurrentBar])
    (double) (-1)*alSells[CurrentBar])
    ...and it won't work.

    Can you help me?

    #2
    Hi marc0,

    Welcome to the NinjaTrader forums!

    Multiplying a value times -1 should do the trick.

    double myNegativeClose = Close[0] * -1;
    Print(myNegativeClose);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hey RyanM,

      it doesn't work yet as I use it in the context of...

      Values[0].Set( (double) [expression] )

      How is it done then?

      Thanks in advance.

      Comment


        #4
        This works OK, returns negative Close.

        Values[0].Set(Close[0] * -1);

        If you are having issues, please let us know exactly what is wrong (doesn't compile, value not what you expect) and the code snippet you're using. You can also share the file from:
        My Documents\bin\custom\indicator
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X