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

EntryLong() / ExitLong() Execution

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

    EntryLong() / ExitLong() Execution

    Hi,

    I do not understand how EntryLong()/ExitLong() are functioning. For example when I open a position with EntryLong() on wich price Open/Close is the trade executed? How can I control the bahivior? For example I want to open a position on the open of the bar and I want to close the trade at the close of the bar. How could I realize this.

    Thanks

    Best Regards

    Andi

    #2
    Hello Andi,

    Thank you for your post.

    EnterLong() and ExitLong() are market orders, so when they are submitted they are filled at the next available price.

    If you wanted to submit orders to specific levels you can use EnterLongLimit(), EnterLongStop(), or EnterLongStopLimit() as well as ExitLontLimit(), ExitLongSTop(), or ExitLongStopLimit().

    If you wanted to enter on the open of a bar you could use if(FirstTickOfBar) EnterLong();, and to exit on the close you could also use FirstTickOfBar as this is the same tick that closes the previous bar.

    For information on the Enter() methods please visit the following link: http://www.ninjatrader.com/support/h...d_approach.htm

    For information on FirstTickOfBar please visit the following link: http://www.ninjatrader.com/support/h...ttickofbar.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Backtest

      Hi,

      actually I want to backtest. Now the Question is, when I do not have Tick Data (Just 5 Minute Data) what is the market price when I EnterLong() / ExitLong() on a bar? Because of Gaps I cannot use FirstTickOfBar of the next bar to exit a position on the close of a bar.

      Thanks for your answer

      Best Regards

      Andi

      Comment


        #4
        Hello Andi,

        Thank you for your response.

        In backtesting FirstTickOfBar would not work as historical data is just the Open, High, Low and Close. You can use EnterLongLimit(), EnterLongStop(), or EnterLongStopLimit() as well as ExitLongLimit(), ExitLongStop(), or ExitLongStopLimit() to submit to the level of the Open or Close.
        Last edited by NinjaTrader_PatrickH; 11-05-2013, 05:42 PM.

        Comment


          #5
          Hello,

          I tested it on a backtest to open a position on the open of a bar, but the trades some times do not execute. The Drawtext is drawn on the chart but the trade is not execute immediately but a bar later. I backtestet it on a 60 minute Chart with 5 minute data.

          Why is the trade executed one bar later?

          Thanks for your replays

          Best Regards

          Andi

          .
          CalculateOnBarClose = false;
          .
          // Condition set 1
          if (Open[0]> PriorDayPivot().PivotR02[0])
          {
          Counter=Counter+1;
          EnterLong(DefaultQuantity, "");
          DrawText("LONG" + Counter.ToString(), Open[0].ToString(), 0, Open[0], Color.Black);
          }

          Comment


            #6
            Hello Andi,

            Thank you for your update.

            The calculations are done on bar close as well as the executions. if you wish to simulate intra-bar fills you can implement the logic presented in our backtesting with intra-bar granularity reference sample: http://www.ninjatrader.com/support/f...ead.php?t=6652

            Please let me know if I may be of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by PhillT, Today, 02:16 PM
            1 response
            2 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by Kaledus, Today, 01:29 PM
            3 responses
            9 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by frankthearm, Yesterday, 09:08 AM
            14 responses
            47 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by gentlebenthebear, Today, 01:30 AM
            2 responses
            13 views
            0 likes
            Last Post gentlebenthebear  
            Started by PaulMohn, Today, 12:36 PM
            2 responses
            17 views
            0 likes
            Last Post PaulMohn  
            Working...
            X