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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        39 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        290 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        289 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        135 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        96 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X