Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Fill Order on Secondary Timeframe- Backtest

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

    Fill Order on Secondary Timeframe- Backtest

    I would like to calculate and submit a limit order based on a 5 minute timeframe but have the fill occur based on a more granular 1 minute time frame for backtesting.

    protected override void Initialize()

    Add(PeriodType.Minute, 1); //5min timeframe chosen for chart, adding secondary timeframe

    protected override void OnBarUpdate()

    if (BarsInProgress==0)

    EnterLongLimit(0 or 1?,false,contracts,buy,"buy");

    if (BarsInProgress==1)

    //(this is the part i need help with, how to fill on 1 minute OHLCV not 5min OHLCV timeframe

    #2
    Hello Megbers,
    To do this, specify the int barsInProgressIndex parameter for you EnterLongLimit method.
    Here is the BarsInProgress and EnterLongLimit()Help Guide to assist you further.
    Here is an example of this.
    Code:
    protected override void Initialize()
    {
    Add(PeriodType.Minute, 1);}
    
    
    protected override void OnBarUpdate()
    if (BarsInProgress == 1)
        {
    [LEFT][FONT=Courier New][SIZE=2]EnterLongLimit([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000FF]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], Close[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]],[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800000]"myOrder1"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT][/LEFT]
        }
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your response, so if I understand correctly that will enter an order every 1 min at the price specified by the 5min chart is that correct?

      Comment


        #4
        Hello Megbers,


        "so if I understand correctly that will enter an order every 1 min at the price specified by the 5min chart is that correct?"


        Yes this is correct. This will enter an order every 1 min at the price specified by the 5min chart. However, the number of entries that can be submitted is limited by Entry Handling.


        The EntriesPerDirection and EntryHandling are there to help you control how many trades you are entering at a time. EntriesPerDirection Indicates the maximum number of entries allowed per direction while a position is active based on the EntryHandling property.


        EntryHandling sets the manner in how entry orders are handled. If set to "EntryHandling.AllEntries", NinjaScript will process all order entry methods until the maximum allowable entries set by the EntriesPerDirection property has been reached while in an open position.


        If set to "EntryHandling.UniqueEntries", NinjaScript will process order entry methods until the maximum allowable entries set by the EntriesPerDirection property per each uniquely named entry.


        Here is the EntryHandling and EntriesPerDirection Help Guides to assist you further.
        Shawn B.NinjaTrader Customer Service

        Comment


          #5
          This does not work, in the backtest the profit targets are taken after the 5min bar close regardless of order entry time and the orders are not executed in order (not at all realistic). I think I will need to use a 1min chart as the base and add a 5min period type to create the buy/sell signals.

          I have attached an image to show the problem, I created a 1 second period to illustrate.
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          61 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          9 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          18 views
          0 likes
          Last Post traderqz  
          Started by algospoke, 04-17-2024, 06:40 PM
          5 responses
          48 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X