Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trading 5 min bars but using 15 minute intervals

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

    Trading 5 min bars but using 15 minute intervals

    I have a strategy that uses the 5 minute bar time frame but I only wish to enter a new trade at the open of the 5 minute bar but only if the bar is opening at 9:00, 9:15, 9:30, 9:45, 10:00 etc.

    Can I reference the bar open minutes in my code to check for this.

    i.e. buy at the open of the 5 minute bar if the open price of the bar is greater than the 25 period SMA and bar minutes = 00, 15, 30 or 45. Is that possible or is there another way?

    I don't want the trade to open during the open of any other 5 minute bar, only at the quarter hour.

    Thanks

    #2
    Hello WCmaria,

    Thank you for your note.

    You can use the .Minute property of the DateTime structure of Time[0] and compare that to your values of interest.
    Code:
    if(Time[0].Minute == 00 || Time[0].Minute == 15 || Time[0].Minute == 30 || Time[0].Minute == 45)
    EnterLong();
    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I tried implemented the .Minute code as suggested in my strategy as follows:

      if
      (mp==MarketPosition.Flat)
      {
      if (tradesThisBar<1)
      {
      if(Time[0].Minute == 00 || Time[0].Minute == 15 || Time[0].Minute == 30 || Time[0].Minute == 45)
      {
      if (allowLong && barDir==1 && Open[0=]=>sma[1])
      _long.SendEntry(OrderAction.Buy,tradeSize,
      "LE");
      elseif (allowShort && barDir==-1 && Open[0]<sma[1])
      _short.SendEntry(OrderAction.SellShort,tradeSize,
      "SE");
      }


      Does the .Minute code reference the computer clock or the Ninjatrader bar time?

      In the strategy above I ran it on a 5 minute bar chart beginning at 8:59:55 a.m.. So the first trade of the day should occur at the open of the 9:00 a.m. bar. Since this bar begins with :00 I assumed it should open the trade. But my strategy is only opening a trade at the open of the 9:10 bar which doesn't end in :00 or :15 or :30 or :45.

      Is my code wrong for the purpose I intended?

      thanks

      Comment


        #4
        Wcmaria,

        The code works on my end.

        Are you able to test using just a basic indicator and draw a dot when the condition is true?

        Can you add TraceOrders to your Initialize() method in the strategy and open up Tools -> Output Window...
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by George21, Today, 10:07 AM
        0 responses
        2 views
        0 likes
        Last Post George21  
        Started by Stanfillirenfro, Today, 07:23 AM
        8 responses
        23 views
        0 likes
        Last Post Stanfillirenfro  
        Started by DayTradingDEMON, Today, 09:28 AM
        2 responses
        16 views
        0 likes
        Last Post DayTradingDEMON  
        Started by navyguy06, Today, 09:28 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        8 responses
        32 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X