Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating a limit entry

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

    Calculating a limit entry

    Can someone help me code the following limit entry...

    For a long limit entry, I want the entry order to be placed at the closest tick above the 15 period EMA. For example if the EMA is at 828.35 I want the limit order to be placed at 828.50. If the EMA is at 828.50, I want the limit order to be placed at 828.75. I just need it to work on the ES at the moment but I'd like it to work on all markets eventually.

    My current code that doesn't give the correct entry is...

    myEntryOrder = EnterLongLimit(DefaultQuantity, EMA(Close, 15)[0] + 1 * TickSize , "Long Entry");

    Thanks for any help.

    Kevin

    span.jajahWrapper { font-size:1em; color:#B11196; text-decoration:underline; } a.jajahLink { color:#000000; text-decoration:none; } span.jajahInLink:hover { background-color:#B11196; }

    #2
    Try this:

    myEntryOrder = EnterLongLimit(DefaultQuantity, Instrument.MasterInstrument.Round2TickSize(EMA(15)[0] + TickSize), "Long Entry");


    More information - http://www.ninjatrader-support.com/H...2TickSize.html
    RayNinjaTrader Customer Service

    Comment


      #3
      Thank you Ray for the response but it's not exactly what I'm looking for.

      The Instrument.MasterInstrument.Round2TickSize seems to be rounding to the closest tick, be it lower or higher.

      For my long entry, I only want to round up. So if the EMA is at 872.05, I want it to round to 872.25 not 872.00.

      Any suggestions?

      Thanks again.

      Kevin

      Comment


        #4
        Would adding some additional logic like this work?

        if (value < EMA value) value = value + TickSize;
        RayNinjaTrader Customer Service

        Comment


          #5
          That might work but I don't know how to incorporate that code into my program. I'm not sure where to put it.

          Would I have to create a new variable?

          I'm still pretty new to programming.

          Thanks Ray.

          Kevin

          Comment


            #6
            Hi Kevin,

            Yes, it would be best to create a new variable where you calculate your limit order entry value based on your conditions.

            Before moving on, please take a look at our indicator and strategy creating tutorials, which give you a great start for custom coding on your own -





            Here is a link to more advanced Reference Samples and NinjaScript Tips on this forum - http://www.ninjatrader-support.com/H...ceSamples.html

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            338 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 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
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X