Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ZeroKuhl, Today, 04:31 PM
            0 responses
            7 views
            0 likes
            Last Post ZeroKuhl  
            Started by Vulgoth_t_Destroyer, 05-09-2022, 04:45 PM
            54 responses
            5,336 views
            0 likes
            Last Post Gaterz
            by Gaterz
             
            Started by ETFVoyageur, 05-07-2024, 07:05 PM
            11 responses
            73 views
            0 likes
            Last Post -=Edge=-  
            Started by _Zero_, 04-10-2020, 03:21 PM
            145 responses
            7,899 views
            6 likes
            Last Post johng2
            by johng2
             
            Started by TheTradingMantis, 01-19-2023, 02:05 AM
            43 responses
            921 views
            0 likes
            Last Post jmagaia
            by jmagaia
             
            Working...
            X