Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Round MA or other indicator to nearest valid price?

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

    Round MA or other indicator to nearest valid price?

    I have been having some trouble setting a stop price based on some kind of ATR offset from a pivot high price. Basically it never executes and I suspect it is because when I apply the ATR value to a high price it doesn't result in a number which is an even price, (800.13 versus 800.25, 800.32 versus 800.50, etc.) Is there a function in NTScript which can be used to truncate a derived number, MA, EMA, something else) to a valid price so that it can be used in a stop or limit order condition? I tried looking at the Chandelier stop which I found in another thread but when I imported it to look at and tried to open it in the editor, NT crashed so I deleted it. I don't need external assistance in crashing NT, I do that fine on my own.
    Thanks
    DaveN

    #2
    DaveN, have you check into Round2TickSize for this? - http://www.ninjatrader-support.com/H...2TickSize.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Round to nearest valid price

      Perfect!!
      I thought something like this existed but my searches didn't find it. I used truncate instead of round. Thanks for your help Bertrand.
      Have a great weekend.
      DaveN

      Comment


        #4
        You're welcome, great that did the trick for you, enjoy your weekend as well.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          number rounding

          hi i want to add a number rounding functionality to my indicator but im not familiar enough to generate the code from scratch if anyone has done this or has a code snippet i would greatly appreciate it.

          Number rounding function is so that my indicator never places a buy or sell order on an even number.
          eg; ES - if a buy order is generated on 1015 i want the script to round up to 1015.25

          if a a sell order is generated on 1015 i want the script to round down to 1014.75

          and the asme also

          ES - if a buy order is generated on 1015.50 i want the script to round up to 1015.75

          if a a sell order is generated on 1015.50 i want the script to round down to 1014.25


          thanks in advance for any assistance

          Comment


            #6
            hi andrew,
            for me the thing you search for is not a "rounding" but it is an "offset".
            you can do this in the code via "Offsetting an Item Value"
            have a look look here :


            max-td

            Comment


              #7
              Thanks for the help here max-td
              BertrandNinjaTrader Customer Service

              Comment


                #8
                thanks max,

                One last question, how do it isolate the last digit of the price?


                for the 6E price is 1.4742 how do i isolate the last digis so i can use a IF statement to ad an offset?


                eg of my code;

                if (x == 1)
                entry = SMA + 4

                now this is where i want to say IF "entry" ends with a 5 or 0 offset by +1

                Comment


                  #9
                  You can review the ideas presented in this thread - http://www.ninjatrader-support2.com/...ad.php?t=11831
                  BertrandNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by jclose, Today, 09:37 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post jclose
                  by jclose
                   
                  Started by WeyldFalcon, 08-07-2020, 06:13 AM
                  10 responses
                  1,414 views
                  0 likes
                  Last Post Traderontheroad  
                  Started by firefoxforum12, Today, 08:53 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post firefoxforum12  
                  Started by stafe, Today, 08:34 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post stafe
                  by stafe
                   
                  Started by sastrades, 01-31-2024, 10:19 PM
                  11 responses
                  169 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Working...
                  X