Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Where to start if I want to create a strategy on a trading set-up?

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

    Thanks Lance. Night-night.

    Beth

    Comment


      Hi Lance

      I went through some samples tonight and started working on my first breakout strategy based on minute interval setting. Did compile the strategy successfully though it does not trigger any trades. It's a simple breakout strategy to place a long order 1 tick above the High of the 2nd 15-minute bar upon the market opens at 9:30 am.

      Appreciate your help in pointing out my coding errors:

      // Resets the highest high at the start of every new session
      if (Bars.FirstBarOfSession)
      highestHigh = High[0];

      // Stores the highest high of the 2nd 15-minute bar
      if (High[1] > highestHigh)
      highestHigh = High[1];

      // Entry Condition: Submit a buy stop order one tick above the High of the 2nd 15-minute bar. Cancel if not filled within 2 hours (8 bars).
      if (Bars.BarsSinceSession > highestHigh && Bars.BarsSinceSession < 8)
      {
      // EnterLongStop
      EnterLongStop(highestHigh + TickSize);
      DrawArrowUp("Long" + CurrentBar, true, 0, Low[0] - (4*TickSize), Color.Lime);
      }

      Sorry that my coding may consist some stupid programming mistakes as I am a novice. Thank you!

      Beth

      Comment


        Originally posted by belecona View Post
        // Resets the highest high at the start of every new session
        if (Bars.FirstBarOfSession)
        highestHigh = High[0];

        // Stores the highest high of the 2nd 15-minute bar
        if (High[1] > highestHigh)
        highestHigh = High[1];
        Hello,



        First of all you would want to use Print() statements to verify values are what you expect - Debugging your NinjaScript code.


        For strategies add TraceOrders = true to your Initialize() method and you can then view valuable output related to strategy submitted orders through Tools > Output window - TraceOrders


        It may also help to add drawing objects to your chart for signal and condition confirmation - Drawing Objects.


        From what I can see here it looks as thought the high condition is not true in the beginning where you expect it to be.

        Code:
        // Try the following. In your example, you're comparing the previous bar to the previous bar at the start of the session. (so they would be equal)
        if (High[0] > highestHigh)
        highestHigh = High[0];
        Please let me know if I can be of further assistance.
        LanceNinjaTrader Customer Service

        Comment


          Good morning Lance

          I had a breakout indicator on 2 charts (1- and 4-minute ones). Since the start/end time on both charts were the same, I expect to see the same breakout prices (High/Low). Unfortunately, the 4-minute prices did not match the 1-minute ones (per enclosed).

          During my trouble-shooting, I noticed the candles on the 4-minute chart did not align with the 9:30 am market open. I am thinking if I can somehow change that, the breakout prices on the 4-minute chart will match the 1-minute ones (which are the correct prices). How can I do that? Or if my logic is wrong, appreciate your guidance on resolving this myth. Thank you.

          Have a nice day.

          Beth
          Attached Files

          Comment


            Originally posted by belecona View Post
            Good morning Lance

            I had a breakout indicator on 2 charts (1- and 4-minute ones). Since the start/end time on both charts were the same, I expect to see the same breakout prices (High/Low). Unfortunately, the 4-minute prices did not match the 1-minute ones (per enclosed).

            During my trouble-shooting, I noticed the candles on the 4-minute chart did not align with the 9:30 am market open. I am thinking if I can somehow change that, the breakout prices on the 4-minute chart will match the 1-minute ones (which are the correct prices). How can I do that? Or if my logic is wrong, appreciate your guidance on resolving this myth. Thank you.

            Have a nice day.

            Beth
            I did verify that multiples of 4 don't align on 9:30

            (at least 4 and 8)..I did not try 12 and 16.... 2 and 6 were fine.
            Attached Files

            Comment


              Beth,

              Keep in mind that the Time represents the end of the bar. So the Open on a 4 minute bar, isn't going to be the same as a 1 minute bar.

              What you would want to do on the 4 minute chart is Add() a 1 minute data series and calculate the open from that time.
              MatthewNinjaTrader Product Management

              Comment


                Originally posted by sledge View Post
                I did verify that multiples of 4 don't align on 9:30

                (at least 4 and 8)..I did not try 12 and 16.... 2 and 6 were fine.
                "30" is not an integer multiple of "4" or "8". Ergo, bars based on those minute time frames will not align with a 30 minute time frame.

                The factors of 30 are 2,3,5. Only their minute charts, and their multiples thereof will align with a 30 minute chart. I guess 1 minute is a trivial case of alignment.

                Comment


                  Hi Sledge, Matthew and Koganam

                  Thanks for your kind suggestion and sharing. I added a 1-minute data series to a 4-minute chart. My chart looked weird. Will find other alternatives to resolve my myth.

                  Have a great weekend.

                  Beth

                  Comment


                    Originally posted by koganam View Post
                    "30" is not an integer multiple of "4" or "8". Ergo, bars based on those minute time frames will not align with a 30 minute time frame.

                    The factors of 30 are 2,3,5. Only their minute charts, and their multiples thereof will align with a 30 minute chart. I guess 1 minute is a trivial case of alignment.
                    There should be a way to "force" alignment of all bars with "market open" (9:30am)... and let people complain about no alignment at 4 pm on 4 or 8 minute charts..

                    Comment


                      Originally posted by sledge View Post
                      There should be a way to "force" alignment of all bars with "market open" (9:30am)... and let people complain about no alignment at 4 pm on 4 or 8 minute charts..
                      There is. It is called a custom session template.

                      Comment


                        Originally posted by koganam View Post
                        There is. It is called a custom session template.
                        Thanks. I just deal with 1 minute/3 minute and 4 range bars .... 4/8 is strange to me.

                        Comment


                          Hello

                          I spent the whole morning to go through more threads. The good news is I compiled my new-born strategy successfully and it did trigger trades. Unfortunately, the trade signals did not match my predetermined entry condition. Supposed to be a simple strategy .. sigh ..

                          Entry Conditions:

                          1. Wait until 10:00 am to identify 9:45-10:00 am HH/LL (15-minute timeframe)
                          2. Place a buy/sell limit order (1 tick above/below) when price breaks up/down based on 9:45-10:00 am HH/LL

                          I had the SampleGetHighLowbyTrueRange indicator on the chart to have the 9:45-10:00 am HH/LL on the chart to validate my strategy. You can tell from the screenshot that my strategy did not trigger a buy @1.3083 when price broke 1.3082. It triggered a buy @1.3102.

                          I defined the Breakout Range and Entry Condition under OnBarUpdate()
                          if (ToTime(Time[0])>94500 && ToTime(Time[0])<100000)
                          {
                          highestHigh=CurrentDayOHL().CurrentHigh[0];
                          lowestLow=CurrentDayOHL().CurrentLow[0];
                          }

                          //Condition set 1 Go Long
                          if (High[0]>=highestHigh)
                          {
                          debug ("Entering LongLimit");
                          longEntryPrice = (highestHigh+TickSize);
                          longSignalBar = CurrentBar;
                          DrawText("longEntryPrice"+longSignalBar,true,Forma tPrice(longEntryPrice),6,longEntryPrice+1*TickSize ,0,Color.Green,textFont_8,StringAlignment.Near,Col or.Black,Color.Black,10);
                          EnterLongLimit(DefaultQuantity, highestHigh+TickSize,"");
                          }

                          I must have missed something important. Appreciate any tips to fix my strategy. Thank you. Have a great weekend.

                          Beth
                          Attached Files

                          Comment


                            Originally posted by belecona View Post
                            Hello

                            I spent the whole morning to go through more threads. The good news is I compiled my new-born strategy successfully and it did trigger trades. Unfortunately, the trade signals did not match my predetermined entry condition. Supposed to be a simple strategy .. sigh ..

                            Entry Conditions:

                            1. Wait until 10:00 am to identify 9:45-10:00 am HH/LL (15-minute timeframe)
                            2. Place a buy/sell limit order (1 tick above/below) when price breaks up/down based on 9:45-10:00 am HH/LL

                            I had the SampleGetHighLowbyTrueRange indicator on the chart to have the 9:45-10:00 am HH/LL on the chart to validate my strategy. You can tell from the screenshot that my strategy did not trigger a buy @1.3083 when price broke 1.3082. It triggered a buy @1.3102.

                            I defined the Breakout Range and Entry Condition under OnBarUpdate()
                            if (ToTime(Time[0])>94500 && ToTime(Time[0])<100000)
                            {
                            highestHigh=CurrentDayOHL().CurrentHigh[0];
                            lowestLow=CurrentDayOHL().CurrentLow[0];
                            }

                            //Condition set 1 Go Long
                            if (High[0]>=highestHigh)
                            {
                            debug ("Entering LongLimit");
                            longEntryPrice = (highestHigh+TickSize);
                            longSignalBar = CurrentBar;
                            DrawText("longEntryPrice"+longSignalBar,true,Forma tPrice(longEntryPrice),6,longEntryPrice+1*TickSize ,0,Color.Green,textFont_8,StringAlignment.Near,Col or.Black,Color.Black,10);
                            EnterLongLimit(DefaultQuantity, highestHigh+TickSize,"");
                            }

                            I must have missed something important. Appreciate any tips to fix my strategy. Thank you. Have a great weekend.

                            Beth
                            It is not clear what your chart purports to show. You wrote this: "1. Wait until 10:00 am to identify 9:45-10:00 am HH/LL (15-minute timeframe)" (emphasis mine), implying that you are using a 15-minute chart, but you then show a 1-minute chart.
                            Last edited by koganam; 12-15-2012, 02:00 PM.

                            Comment


                              Hi Koganam

                              I want to use the HH/LL of 9:45-10:00 am to trade their breakout on a 1-minute chart. Thank you.

                              Beth

                              Comment


                                Originally posted by belecona View Post
                                Hi Koganam

                                I want to use the HH/LL of 9:45-10:00 am to trade their breakout on a 1-minute chart. Thank you.

                                Beth
                                So what is the actual chart that you posted showing? Offhand, it looks like a trade that was executed on a 15-minute chart, and the chart was then switched to a 1-minute chart to demonstrate the seeming problem.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                649 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                370 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                109 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                574 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                576 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X