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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        160 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        307 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        244 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        348 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        178 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X