Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Newbie question: immediate entry if prior days high is touched

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

    Newbie question: immediate entry if prior days high is touched

    Hello,

    I have been searching for the answer of the following problem for quite a while, but I couldn't find one.

    It is a simple breakout strategy: I want to buy the breakout over prior days high. I am testing on a 1 Minute chart.

    As of now, I enter the position on the next bar open. But I want to enter as soon as the prior day high is hit. Here is my entry condition:

    // Condition set 1 Long Entry
    if (ToTime(Time[0])>=91500 && ToTime(Time[0])<=220000 && High[0] >= PriorDayOHLC().PriorHigh[1]&& hasEnteredLong1 == false)
    {
    hasEnteredLong1 = true;
    EnterLongLimit(DefaultQuantity,PriorDayOHLC().Prio rHigh[1], "Long V1H1");
    }


    Is there something like a buystop function?

    Thanks in advance
    PokerPaul

    #2
    Hello,

    Yes you can use a buy stop limit order or a buy stop order to do this:

    This example may be of help: http://www.ninjatrader.com/support/f...ead.php?t=3223

    Also these are the two most common orders you could use for the long side in this case



    Also let me know if you're looking to do an OCO entry breakout as this requires more advanced coding to have two entry OCO orders.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Hello,

      I have tried to update my script based on the sample breakout strategy. However, no trades are executed.

      Could you have a short look on my file?

      Thanks in advance
      Attached Files

      Comment


        #4
        Hello,

        If we look into the logic you've used, there will be frequent times when the EnterLongStop() cannot be hit.

        This is because you're setting the hasEnteredLong1 = false at an earlier time

        Code:
        if (ToTime(Time[0])>80000 && ToTime(Time[0])<91500 && High[0] >=PriorDayOHLC().PriorHigh[1] && hasEnteredLong1 == false)
        			{
        				hasEnteredLong1 = true;
        			}
        is the same as your following condition with a different time. Notice in the above you set your variable to true. So if the above is triggered your enter long will never happen in the following statement because it requires this to be set to false.

        Code:
        if (ToTime(Time[0])>=91500 && ToTime(Time[0])<=220000 && High[0]>=PriorDayOHLC().PriorHigh[1] && hasEnteredLong1 == false)
                    {
                        hasEnteredLong1 = true;
        				EnterLongStop(highestHigh + TickSize, "Long V1H1");
                    }
        Let me know if I can be of further assistance.
        LanceNinjaTrader Customer Service

        Comment


          #5
          Hello,

          I have found a way to trade the breakout over the previous high (PreviousHigh[0]). Now I want to trade the previousHigh[1] in the same strategy.

          But the trade for the high before yesterday is not made.

          Attached is the code (tested on a 5 Minute chart).

          protected override void OnBarUpdate()
          {
          // Resets the highest high at the start of every new session
          if (Bars.FirstBarOfSession)
          H1 = PriorDayOHLC().PriorHigh[0];
          H2 = PriorDayOHLC().PriorHigh[1];
          L1 = PriorDayOHLC().PriorLow[0];
          L2 = PriorDayOHLC().PriorLow[1];

          // Entry Condition H1: Buy breakout over H1
          if (Bars.BarsSinceSession > 15 && CurrentDayOHL().CurrentHigh[0]<H1)
          {
          EnterLongStop(H1,"H1");
          }

          // Entry Condition H2: Buy breakout over H2
          if (Bars.BarsSinceSession > 15 && CurrentDayOHL().CurrentHigh[0]<H2)
          {
          EnterLongStop(H2,"H2");
          }

          if (Bars.BarsSinceSession > 15 && CurrentDayOHL().CurrentLow[0]<L1)
          {
          EnterShortStop(L1,"L1");
          }

          if (Bars.BarsSinceSession > 15 && CurrentDayOHL().CurrentLow[0]<L2)
          {
          EnterShortStop(L2,"L2");
          }

          Thanks for your comments

          Comment


            #6
            First two things to check are the days loaded on the chart and the entries per direction

            Right click the chart -> data series ensure you have at least 10 days or so being loaded (for this 5 minute chart). Without doing this it could be that your chart doesn't have enough historical data to see the accurate high from 2 days back.

            Next go in to your strategy settings and locate entries per direction. Because I see you have two different entry names you will likely want to change this from "All Entries" to "Unique entries"
            Doing so will allow each signal name to trigger based on the number specified.


            Let me know if I can be of further assistance.
            LanceNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Brevo, Today, 01:45 AM
            0 responses
            2 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
            238 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
            4 views
            0 likes
            Last Post oviejo
            by oviejo
             
            Working...
            X