Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

First Bar of the week

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

    First Bar of the week

    Hi,

    I am trying to create a strategy using the first bar of the week as a fix range.

    If the first 1 hour bar is green I`ll go long.

    Can someone tell me how can I refer to this 1st bar?

    IF I want to place a hard Stop Loss in the low of this first bar, Do I Place the order in the initialize() or on the OnBarUpdate?

    Thanks in advance

    #2
    ok,

    More or less I am making this to work.

    Well, how can I place a hard stop righ at the low of this first of week candle?

    Thanks a lot

    Comment


      #3
      Hello CJS,

      You can work with DayOfWeek function to identify a specific day of the week. GetBar() can be used to get the bars ago value for a given date time.

      If you are coding a stop loss based on bar objects, then this must be set in OnBarUpdate(), not Initialize.

      The following reference samples may help you with a lot of this.

      Manipulating DateTime objects
      Getting indicator values from a specified time

      Example of this (assumes you have viewed samples and declared variables where appropriate):

      Code:
       
      if (Time[0].DayOfWeek == DayOfWeek.Monday)
      myDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, Time[0].Hour, Time[0].Minute, Time[0].Second);
       
      myBarsAgo = GetBar(myDateTime);
       
      Print (Low[myBarsAgo]);
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        What about using: Bars.FirstBarOfSession

        Don't you think it would work ok in order to built the strategy around this first bar of the wek?

        if (Time[0].DayOfWeek==DayOfWeek.Monday)
        {
        if (Bars.FirstBarOfSession)
        {
        if (Close[0]>=Open[0])
        {......

        Comment


          #5
          Yeah, that should work well for identifying Monday's first bar.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Hi,

            Once I have de FirstBarOfSession, the variables mylow & myhigh get the values of the low and the high of this bar. At that moment I want to send two stop orders (one at the high and the other at low). What I am trying to do is a kind of bracket to this bar. So if price breaks the high I am long using the EnterlongStop order and viceversa.

            The problem is that just the first order is working. If the price breaks the low, the EnterShortStop is being ignored.

            Can you tell me the best way to "bracket" a fix range with stop orders? (not market orders). Of course, if price breaks the high, the EnterShortStop must be canceled.

            Thanks in advance.

            Comment


              #7
              CJS, this approach will not work on NT 6.5 as you would into the Internal Order Handling rules, in NT7 there's a unmanaged order submission approach now that would allow you to place this entry bracket then -





              For NT 6.5 a workaround would be monitoring the breakout and then just submitting one needed order.

              Comment


                #8
                ok, just to be sure. Let`s put it in a more simpler manner:

                EURUSD.

                Price is at 1,3000

                Can I place 2 stops orders?:

                - Fisrt. at 1,4000 (to enter long in price breaks that level)
                - Second, at 1,2000 (to enter short in price breaks that level).

                This do not seem to be complicated trading. And seems quite simple and common.

                Thanks a lot, I just want to be sure I sent my doubt correctly.

                Comment


                  #9
                  CJS, no this is not possible, if you run with TraceOrders = true (http://www.ninjatrader.com/support/f...ead.php?t=3627) you would see ignored orders in your outputs, please check the first link I posted for the scenarios in which you would run into those internal order handling rules...to workaround either monitor for a breakout and submit one order then, cancel the unneeded order before submitting the other or work in NT7's unmanaged mode.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by CarlTrading, 03-31-2026, 09:41 PM
                  1 response
                  64 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by CarlTrading, 04-01-2026, 02:41 AM
                  0 responses
                  35 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CaptainJack, 03-31-2026, 11:44 PM
                  0 responses
                  59 views
                  1 like
                  Last Post CaptainJack  
                  Started by CarlTrading, 03-30-2026, 11:51 AM
                  0 responses
                  62 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CarlTrading, 03-30-2026, 11:48 AM
                  0 responses
                  51 views
                  0 likes
                  Last Post CarlTrading  
                  Working...
                  X