Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Multi timeframe - StopLimit order

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

    Multi timeframe - StopLimit order

    Hi NT support team
    I am using the Multi timeframe for the first time so I'm sure I'm doing something wrong.
    I have
    - primary bars = Daily
    CalculateOnBarClose = true (I have also tried with false)
    and seconday bars = 1 minute for example

    I place a stopLimit order with SubmitOrder at close of Primary Bars.
    I want to process some information at the exact time within 1minute bar when the order is potentially executed.
    However I can't have the exact execution time properly at 1min level. It seems at the close of the daily bar, we check for the nextLow and nextHigh (within daily timeframe) and therefore we know the order was filled at the first minute bar following the closure of the daily bar. How to avoid this and oblige the order to be filled at the right time at minute bar level?

    In term of code within class DefaultFillType : FillType


    Code:
    else if (order.OrderType == OrderType.StopLimit)
    			{
    				// Stop limit orders are triggered when traded at the stop price and traded through the limit price
    				double nextLow	= NextLow;
    				double nextHigh = NextHigh;
    				if (!order.StopTriggered
    					&& ((order.OrderAction == Cbi.OrderAction.Buy				&& order.StopPrice <= nextHigh + epsilon)
    						|| (order.OrderAction == Cbi.OrderAction.BuyToCover	&& order.StopPrice <= nextHigh + epsilon)
    						|| (order.OrderAction == Cbi.OrderAction.Sell			&& order.StopPrice >= nextLow - epsilon)
    						|| (order.OrderAction == Cbi.OrderAction.SellShort	&& order.StopPrice >= nextLow - epsilon)))
    					order.StopTriggered = true;
    we check the order is filled by using the nextLow and nextHigh of daily bars.
    So we don't move in time minute by minute for checking the orders are executed.

    So basically how to force that?

    Thanks

    #2
    Code:
    [FONT=Fixedsys]// http://ninjatrader.com/support/helpGuides/nt7/totime.htm
    if (null == entryOrder && BarsInProgress == 1 && 110000 <= ToTime(Time[0]) && ToTime(Time[0]) <= 110500)
    {
      // http://ninjatrader.com/support/helpGuides/nt7/submitorder.htm
      entryOrder = SubmitOrder(1, OrderAction.Buy, OrderType.Market, DefaultQuantity, 0.0, 0.0, "", "")
    }Hello jakjak74, and thank you for your question. SubmitOrder's first argument, the BarsInProgressIndex, is the trade clock your order is submitted against. You will want this to be 1 for your 1 minute bars. You will also want to call this when BarsInProgress == 1, using ToTime(Time[0]) to convert your time to an integer you can check against to restrict order processing to desired times of day. An example that would place orders against your minute bars during 11 AM and 11:05 AM,
    
    
    [/FONT]
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kujista, Today, 06:23 AM
    0 responses
    1 view
    0 likes
    Last Post kujista
    by kujista
     
    Started by traderqz, Yesterday, 04:32 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by f.saeidi, Today, 05:56 AM
    1 response
    4 views
    0 likes
    Last Post Jltarrau  
    Started by Jltarrau, Today, 05:57 AM
    0 responses
    4 views
    0 likes
    Last Post Jltarrau  
    Started by Stanfillirenfro, Yesterday, 09:19 AM
    7 responses
    53 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X