Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can I create a condition where I enter a trade before the current bar closes?

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

    Can I create a condition where I enter a trade before the current bar closes?

    For example, Let's say I am on the current bar, and it is a 2K tick chart. I want to enter a long position as soon as the current bar breaks the high of the previous bar. I have set the default properties to calculate on each tick, and I have set various conditions where the current bar crosses over the high of the previous bar. Most of my condition attempts never fire. Could you give me some examples of how to get this to work?

    thanks!

    #2
    Hello Josh615,

    Thanks for your post and welcome to the Ninjatrader forums.

    In NinjaTrader8 you would need to set Calculate.OnEachtick or Calculate.OnPriceChange to provide the calculate on each (relative) tick functionality.

    An example of a condition would be:

    if (High[0] > High[1] && Doitonce == true)
    {
    // entry order here
    Doitonce = false; // set false to prevent additional orders
    }

    In the above example, a user created bool called Doitonce is used as a control to prevent the condition from placing multiple orders. On the first tick where the condition is met, the entry order is placed and the bool is set false. You would need to create another condition where you "reset" the bool back to true when you are ready for a new entry.

    If you are backtesting in the strategy analyzer or are looking at historical trades please note that the bars do not contain all of the ticks that made up the bar but only the OHLC values so historical data can only be processed as if you are using CalculateOnBarClose is true. You can always use the Market replay with Calculate.OnPriceChange or Calculate.OnEachTick


    Last edited by NinjaTrader_PaulH; 12-15-2020, 09:54 AM. Reason: Moved topic from NinjaTrader7 and adjusted response for Ninjatrader8
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I am sorry, I am creating this in NinjaTrader8 and posted in the wrong section! Is there a better way of doing this in the NinjaTrader8 Strategy builder?

      thanks!

      Comment


        #4
        Hello Josh615,

        Thanks for your reply.

        No worries, I'll move this thread to NT8 strategies and then will rework my 2nd post to fit that.

        Knowing that you are wanting to work in the strategy builder is important info as well.

        In the NinjaTrader8 Strategy builder, set its calculate setting to Calculate.OnPriceChange.

        Create an int variable (maybe call it EntryBar)

        In a set create the condition Price>High (bars ago of 0), greater, Price>High bars ago 1)

        In the same set create the condition Misc>Current bar, Not Equal, User variables>EntryBar

        In the same set, in the "do the following" section, place your entry order and :
        Misc>Set EntryBar
        in the field of EntryBar click "set" then select Misc>Current bar

        This will limit the order to once per bar
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          So under the "do the following" section. I have selected "Enter long position" from order management. Do I add a second action that sets the Entry Bar? I am not seeing a field of EntryBar to set to the Current bar? Should be entering all of this within the order entry action? If so, under the "Enter long position" I am only given Quantity and Signal name to edit under Misc.

          Comment


            #6
            [B]I'm going to assume that the original poster already figured this out by now, but I'm responding because this thread helped me (and in case others have a similar question).[/B]

            [I]So under the "do the following" section. I have selected "Enter long position" from order management. Do I add a second action that sets the Entry Bar?[/I]
            [B]Yes.[/B]

            [I]I am not seeing a field of EntryBar to set to the Current bar? Should be entering all of this within the order entry action? If so, under the "Enter long position" I am only given Quantity and Signal name to edit under Misc.[/I]

            [B]You appear to be missing the step for creating the variable. If you closely review the post above, the initial step was to create a variable called EntryBar. [/B]

            [B]You're basically looking to add these to your strategy to prevent multiple entries on the same bar:
            1. Create a variable
            2. Condition: current bar IS NOT variable.
            3. Action: Set variable = current bar[/B]

            [B]See attached, the variable can be named whatever you want (I used MyJosh615Entry in the example attached here.)

            Prior to reading this thread, I had a strategy (pre-change) that would submit 3592 orders in a single day (it was submitting numerous orders in the same bar). After the change, the strategy submitted 25 orders in a single day.[/B]

            Disclaimer: Past performance is not an indicator of future results. (And don't take trading advice from a piece of farm equipment.)
            Attached Files

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Brevo, Today, 01:45 AM
            0 responses
            3 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            3 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            239 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            384 views
            1 like
            Last Post Gavini
            by Gavini
             
            Started by oviejo, Today, 12:28 AM
            0 responses
            6 views
            0 likes
            Last Post oviejo
            by oviejo
             
            Working...
            X